mirror of
https://github.com/aljazceru/breez-lnd.git
synced 2025-12-18 22:54:26 +01:00
itest: manage context timeout in utils.go
This commit finishes moving the context management into utils.go.
This commit is contained in:
@@ -227,8 +227,7 @@ func testChannelUnsettledBalance(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// Check each nodes UnsettledBalance field.
|
// Check each nodes UnsettledBalance field.
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
// Get channel info for the node.
|
// Get channel info for the node.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
chanInfo, err := getChanInfo(node)
|
||||||
chanInfo, err := getChanInfo(ctxt, node)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
unsettledErr = err
|
unsettledErr = err
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -413,8 +413,7 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
aliceChan, err := getChanInfo(alice)
|
||||||
aliceChan, err := getChanInfo(ctxt, alice)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get alice's channel info: %v", err)
|
t.Fatalf("unable to get alice's channel info: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -491,8 +491,6 @@ func testExternalFundingChanPoint(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// testFundingPersistence mirrors testBasicChannelFunding, but adds restarts
|
// testFundingPersistence mirrors testBasicChannelFunding, but adds restarts
|
||||||
// and checks for the state of channels with unconfirmed funding transactions.
|
// and checks for the state of channels with unconfirmed funding transactions.
|
||||||
func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
||||||
ctxb := context.Background()
|
|
||||||
|
|
||||||
chanAmt := funding.MaxBtcFundingAmount
|
chanAmt := funding.MaxBtcFundingAmount
|
||||||
pushAmt := btcutil.Amount(0)
|
pushAmt := btcutil.Amount(0)
|
||||||
|
|
||||||
@@ -570,8 +568,7 @@ func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// Assert that our wallet has our opening transaction with a label
|
// Assert that our wallet has our opening transaction with a label
|
||||||
// that does not have a channel ID set yet, because we have not
|
// that does not have a channel ID set yet, because we have not
|
||||||
// reached our required confirmations.
|
// reached our required confirmations.
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
tx := findTxAtHeight(t, height, fundingTxStr, net.Alice)
|
||||||
tx := findTxAtHeight(ctxt, t, height, fundingTxStr, net.Alice)
|
|
||||||
|
|
||||||
// At this stage, we expect the transaction to be labelled, but not with
|
// At this stage, we expect the transaction to be labelled, but not with
|
||||||
// our channel ID because our transaction has not yet confirmed.
|
// our channel ID because our transaction has not yet confirmed.
|
||||||
@@ -600,7 +597,7 @@ func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Re-lookup our transaction in the block that it confirmed in.
|
// Re-lookup our transaction in the block that it confirmed in.
|
||||||
tx = findTxAtHeight(ctxt, t, height, fundingTxStr, net.Alice)
|
tx = findTxAtHeight(t, height, fundingTxStr, net.Alice)
|
||||||
|
|
||||||
// Create an additional check for our channel assertion that will
|
// Create an additional check for our channel assertion that will
|
||||||
// check that our label is as expected.
|
// check that our label is as expected.
|
||||||
|
|||||||
@@ -105,8 +105,7 @@ func testHoldInvoiceForceClose(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// Our channel should not have been force closed, instead we expect our
|
// Our channel should not have been force closed, instead we expect our
|
||||||
// channel to still be open and our invoice to have been canceled before
|
// channel to still be open and our invoice to have been canceled before
|
||||||
// expiry.
|
// expiry.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
chanInfo, err := getChanInfo(net.Alice)
|
||||||
chanInfo, err := getChanInfo(ctxt, net.Alice)
|
|
||||||
require.NoError(t.t, err)
|
require.NoError(t.t, err)
|
||||||
|
|
||||||
fundingTxID, err := lnrpc.GetChanPointFundingTxid(chanPoint)
|
fundingTxID, err := lnrpc.GetChanPointFundingTxid(chanPoint)
|
||||||
|
|||||||
@@ -897,8 +897,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
var nodeChan *lnrpc.Channel
|
var nodeChan *lnrpc.Channel
|
||||||
var predErr error
|
var predErr error
|
||||||
err = wait.Predicate(func() bool {
|
err = wait.Predicate(func() bool {
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
bChan, err := getChanInfo(node)
|
||||||
bChan, err := getChanInfo(ctxt, node)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get channel info: %v", err)
|
t.Fatalf("unable to get channel info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -937,8 +936,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
t.Fatalf("unable to send payments: %v", err)
|
t.Fatalf("unable to send payments: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
nodeChan, err = getChanInfo(node)
|
||||||
nodeChan, err = getChanInfo(ctxt, node)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get dave chan info: %v", err)
|
t.Fatalf("unable to get dave chan info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -960,8 +958,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Now query for the channel state, it should show that it's at
|
// Now query for the channel state, it should show that it's at
|
||||||
// a state number in the past, not the *latest* state.
|
// a state number in the past, not the *latest* state.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
nodeChan, err = getChanInfo(node)
|
||||||
nodeChan, err = getChanInfo(ctxt, node)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get dave chan info: %v", err)
|
t.Fatalf("unable to get dave chan info: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,8 +125,7 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get current blockheight %v", err)
|
t.Fatalf("unable to get current blockheight %v", err)
|
||||||
}
|
}
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
err = waitForNodeBlockHeight(net.Alice, minerHeight)
|
||||||
err = waitForNodeBlockHeight(ctxt, net.Alice, minerHeight)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to sync to chain: %v", err)
|
t.Fatalf("unable to sync to chain: %v", err)
|
||||||
}
|
}
|
||||||
@@ -143,7 +142,7 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Wait for Alice and Bob to recognize and advertise the new channel
|
// Wait for Alice and Bob to recognize and advertise the new channel
|
||||||
// generated above.
|
// generated above.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("alice didn't advertise channel before "+
|
t.Fatalf("alice didn't advertise channel before "+
|
||||||
@@ -217,8 +216,7 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get current blockheight %v", err)
|
t.Fatalf("unable to get current blockheight %v", err)
|
||||||
}
|
}
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
err = waitForNodeBlockHeight(net.Alice, tempMinerHeight)
|
||||||
err = waitForNodeBlockHeight(ctxt, net.Alice, tempMinerHeight)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to sync to chain: %v", err)
|
t.Fatalf("unable to sync to chain: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,8 +260,7 @@ func testAsyncPayments(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
info, err := getChanInfo(net.Alice)
|
||||||
info, err := getChanInfo(ctxt, net.Alice)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get alice channel info: %v", err)
|
t.Fatalf("unable to get alice channel info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -286,7 +285,7 @@ func testAsyncPayments(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for Alice to receive the channel edge from the funding manager.
|
// Wait for Alice to receive the channel edge from the funding manager.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("alice didn't see the alice->bob channel before "+
|
t.Fatalf("alice didn't see the alice->bob channel before "+
|
||||||
@@ -345,8 +344,7 @@ func testAsyncPayments(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// htlcs listed and has correct balances. This is needed due to the fact
|
// htlcs listed and has correct balances. This is needed due to the fact
|
||||||
// that we now pipeline the settles.
|
// that we now pipeline the settles.
|
||||||
err = wait.Predicate(func() bool {
|
err = wait.Predicate(func() bool {
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
aliceChan, err := getChanInfo(net.Alice)
|
||||||
aliceChan, err := getChanInfo(ctxt, net.Alice)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -368,8 +366,7 @@ func testAsyncPayments(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Wait for Bob to receive revocation from Alice.
|
// Wait for Bob to receive revocation from Alice.
|
||||||
err = wait.NoError(func() error {
|
err = wait.NoError(func() error {
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
bobChan, err := getChanInfo(net.Bob)
|
||||||
bobChan, err := getChanInfo(ctxt, net.Bob)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get bob's channel info: %v", err)
|
t.Fatalf("unable to get bob's channel info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -425,8 +422,7 @@ func testBidirectionalAsyncPayments(net *lntest.NetworkHarness, t *harnessTest)
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
info, err := getChanInfo(net.Alice)
|
||||||
info, err := getChanInfo(ctxt, net.Alice)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get alice channel info: %v", err)
|
t.Fatalf("unable to get alice channel info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -462,7 +458,7 @@ func testBidirectionalAsyncPayments(net *lntest.NetworkHarness, t *harnessTest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for Alice to receive the channel edge from the funding manager.
|
// Wait for Alice to receive the channel edge from the funding manager.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
if err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint); err != nil {
|
if err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint); err != nil {
|
||||||
t.Fatalf("alice didn't see the alice->bob channel before "+
|
t.Fatalf("alice didn't see the alice->bob channel before "+
|
||||||
"timeout: %v", err)
|
"timeout: %v", err)
|
||||||
@@ -534,8 +530,7 @@ func testBidirectionalAsyncPayments(net *lntest.NetworkHarness, t *harnessTest)
|
|||||||
// Wait for Alice and Bob to receive revocations messages, and update
|
// Wait for Alice and Bob to receive revocations messages, and update
|
||||||
// states, i.e. balance info.
|
// states, i.e. balance info.
|
||||||
err = wait.NoError(func() error {
|
err = wait.NoError(func() error {
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
aliceInfo, err := getChanInfo(net.Alice)
|
||||||
aliceInfo, err := getChanInfo(ctxt, net.Alice)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get alice's channel info: %v", err)
|
t.Fatalf("unable to get alice's channel info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -565,8 +560,7 @@ func testBidirectionalAsyncPayments(net *lntest.NetworkHarness, t *harnessTest)
|
|||||||
// Next query for Bob's and Alice's channel states, in order to confirm
|
// Next query for Bob's and Alice's channel states, in order to confirm
|
||||||
// that all payment have been successful transmitted.
|
// that all payment have been successful transmitted.
|
||||||
err = wait.NoError(func() error {
|
err = wait.NoError(func() error {
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
bobInfo, err := getChanInfo(net.Bob)
|
||||||
bobInfo, err := getChanInfo(ctxt, net.Bob)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get bob's channel info: %v", err)
|
t.Fatalf("unable to get bob's channel info: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ func testGetRecoveryInfo(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get current blockheight %v", err)
|
t.Fatalf("unable to get current blockheight %v", err)
|
||||||
}
|
}
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
err = waitForNodeBlockHeight(node, minerHeight)
|
||||||
err = waitForNodeBlockHeight(ctxt, node, minerHeight)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to sync to chain: %v", err)
|
t.Fatalf("unable to sync to chain: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,8 +91,7 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
var bobChan *lnrpc.Channel
|
var bobChan *lnrpc.Channel
|
||||||
var predErr error
|
var predErr error
|
||||||
err = wait.Predicate(func() bool {
|
err = wait.Predicate(func() bool {
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
bChan, err := getChanInfo(net.Bob)
|
||||||
bChan, err := getChanInfo(ctxt, net.Bob)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get bob's channel info: %v", err)
|
t.Fatalf("unable to get bob's channel info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -131,8 +130,7 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
t.Fatalf("unable to send payments: %v", err)
|
t.Fatalf("unable to send payments: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
bobChan, err = getChanInfo(net.Bob)
|
||||||
bobChan, err = getChanInfo(ctxt, net.Bob)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get bob chan info: %v", err)
|
t.Fatalf("unable to get bob chan info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -149,8 +147,7 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Now query for Bob's channel state, it should show that he's at a
|
// Now query for Bob's channel state, it should show that he's at a
|
||||||
// state number in the past, not the *latest* state.
|
// state number in the past, not the *latest* state.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
bobChan, err = getChanInfo(net.Bob)
|
||||||
bobChan, err = getChanInfo(ctxt, net.Bob)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get bob chan info: %v", err)
|
t.Fatalf("unable to get bob chan info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -330,8 +327,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
|
|||||||
|
|
||||||
// Next query for Carol's channel state, as we sent 0 payments, Carol
|
// Next query for Carol's channel state, as we sent 0 payments, Carol
|
||||||
// should now see her balance as being 0 satoshis.
|
// should now see her balance as being 0 satoshis.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
carolChan, err := getChanInfo(carol)
|
||||||
carolChan, err := getChanInfo(ctxt, carol)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get carol's channel info: %v", err)
|
t.Fatalf("unable to get carol's channel info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -361,8 +357,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
|
|||||||
t.Fatalf("unable to send payments: %v", err)
|
t.Fatalf("unable to send payments: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
_, err = getChanInfo(carol)
|
||||||
_, err = getChanInfo(ctxt, carol)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get carol chan info: %v", err)
|
t.Fatalf("unable to get carol chan info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -379,8 +374,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
|
|||||||
|
|
||||||
// Now query for Carol's channel state, it should show that he's at a
|
// Now query for Carol's channel state, it should show that he's at a
|
||||||
// state number in the past, not the *latest* state.
|
// state number in the past, not the *latest* state.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
carolChan, err = getChanInfo(carol)
|
||||||
carolChan, err = getChanInfo(ctxt, carol)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get carol chan info: %v", err)
|
t.Fatalf("unable to get carol chan info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -551,8 +545,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
|
|||||||
// We'll introduce a closure to validate that Carol's current balance
|
// We'll introduce a closure to validate that Carol's current balance
|
||||||
// matches the given expected amount.
|
// matches the given expected amount.
|
||||||
checkCarolBalance := func(expectedAmt int64) {
|
checkCarolBalance := func(expectedAmt int64) {
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
carolChan, err := getChanInfo(carol)
|
||||||
carolChan, err := getChanInfo(ctxt, carol)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get carol's channel info: %v", err)
|
t.Fatalf("unable to get carol's channel info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -567,8 +560,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
|
|||||||
// number of updates is at least as large as the provided minimum
|
// number of updates is at least as large as the provided minimum
|
||||||
// number.
|
// number.
|
||||||
checkCarolNumUpdatesAtLeast := func(minimum uint64) {
|
checkCarolNumUpdatesAtLeast := func(minimum uint64) {
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
carolChan, err := getChanInfo(carol)
|
||||||
carolChan, err := getChanInfo(ctxt, carol)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get carol's channel info: %v", err)
|
t.Fatalf("unable to get carol's channel info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -621,8 +613,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
|
|||||||
// Next query for Carol's channel state, as we sent 3 payments of 10k
|
// Next query for Carol's channel state, as we sent 3 payments of 10k
|
||||||
// satoshis each, however Carol should now see her balance as being
|
// satoshis each, however Carol should now see her balance as being
|
||||||
// equal to the push amount in satoshis since she has not settled.
|
// equal to the push amount in satoshis since she has not settled.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
carolChan, err := getChanInfo(carol)
|
||||||
carolChan, err := getChanInfo(ctxt, carol)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get carol's channel info: %v", err)
|
t.Fatalf("unable to get carol's channel info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -689,8 +680,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
|
|||||||
|
|
||||||
// Now query for Carol's channel state, it should show that she's at a
|
// Now query for Carol's channel state, it should show that she's at a
|
||||||
// state number in the past, *not* the latest state.
|
// state number in the past, *not* the latest state.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
carolChan, err = getChanInfo(carol)
|
||||||
carolChan, err = getChanInfo(ctxt, carol)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get carol chan info: %v", err)
|
t.Fatalf("unable to get carol chan info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1046,8 +1036,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(
|
|||||||
// Next query for Carol's channel state, as we sent 0 payments, Carol
|
// Next query for Carol's channel state, as we sent 0 payments, Carol
|
||||||
// should still see her balance as the push amount, which is 1/4 of the
|
// should still see her balance as the push amount, which is 1/4 of the
|
||||||
// capacity.
|
// capacity.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
carolChan, err := getChanInfo(carol)
|
||||||
carolChan, err := getChanInfo(ctxt, carol)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get carol's channel info: %v", err)
|
t.Fatalf("unable to get carol's channel info: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1130,8 +1119,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(
|
|||||||
|
|
||||||
// Now query for Carol's channel state, it should show that he's at a
|
// Now query for Carol's channel state, it should show that he's at a
|
||||||
// state number in the past, not the *latest* state.
|
// state number in the past, not the *latest* state.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
carolChan, err = getChanInfo(carol)
|
||||||
carolChan, err = getChanInfo(ctxt, carol)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get carol chan info: %v", err)
|
t.Fatalf("unable to get carol chan info: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,10 +179,8 @@ func testSingleHopSendToRouteCase(net *lntest.NetworkHarness, t *harnessTest,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get best height: %v", err)
|
t.Fatalf("unable to get best height: %v", err)
|
||||||
}
|
}
|
||||||
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
|
require.NoError(t.t, waitForNodeBlockHeight(carol, minerHeight))
|
||||||
defer cancel()
|
require.NoError(t.t, waitForNodeBlockHeight(dave, minerHeight))
|
||||||
require.NoError(t.t, waitForNodeBlockHeight(ctxt, carol, minerHeight))
|
|
||||||
require.NoError(t.t, waitForNodeBlockHeight(ctxt, dave, minerHeight))
|
|
||||||
|
|
||||||
// Query for routes to pay from Carol to Dave using the default CLTV
|
// Query for routes to pay from Carol to Dave using the default CLTV
|
||||||
// config.
|
// config.
|
||||||
@@ -190,7 +188,7 @@ func testSingleHopSendToRouteCase(net *lntest.NetworkHarness, t *harnessTest,
|
|||||||
PubKey: dave.PubKeyStr,
|
PubKey: dave.PubKeyStr,
|
||||||
Amt: paymentAmtSat,
|
Amt: paymentAmtSat,
|
||||||
}
|
}
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
routes, err := carol.QueryRoutes(ctxt, routesReq)
|
routes, err := carol.QueryRoutes(ctxt, routesReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get route from %s: %v",
|
t.Fatalf("unable to get route from %s: %v",
|
||||||
|
|||||||
@@ -190,8 +190,11 @@ func createPayReqs(node *lntest.HarnessNode, paymentAmt btcutil.Amount,
|
|||||||
|
|
||||||
// getChanInfo is a helper method for getting channel info for a node's sole
|
// getChanInfo is a helper method for getting channel info for a node's sole
|
||||||
// channel.
|
// channel.
|
||||||
func getChanInfo(ctx context.Context, node *lntest.HarnessNode) (
|
func getChanInfo(node *lntest.HarnessNode) (*lnrpc.Channel, error) {
|
||||||
*lnrpc.Channel, error) {
|
|
||||||
|
ctxb := context.Background()
|
||||||
|
ctx, cancel := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
req := &lnrpc.ListChannelsRequest{}
|
req := &lnrpc.ListChannelsRequest{}
|
||||||
channelInfo, err := node.ListChannels(ctx, req)
|
channelInfo, err := node.ListChannels(ctx, req)
|
||||||
@@ -326,8 +329,12 @@ func calculateMaxHtlc(chanCap btcutil.Amount) uint64 {
|
|||||||
|
|
||||||
// waitForNodeBlockHeight queries the node for its current block height until
|
// waitForNodeBlockHeight queries the node for its current block height until
|
||||||
// it reaches the passed height.
|
// it reaches the passed height.
|
||||||
func waitForNodeBlockHeight(ctx context.Context, node *lntest.HarnessNode,
|
func waitForNodeBlockHeight(node *lntest.HarnessNode, height int32) error {
|
||||||
height int32) error {
|
|
||||||
|
ctxb := context.Background()
|
||||||
|
ctx, cancel := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
var predErr error
|
var predErr error
|
||||||
err := wait.Predicate(func() bool {
|
err := wait.Predicate(func() bool {
|
||||||
ctxt, _ := context.WithTimeout(ctx, defaultTimeout)
|
ctxt, _ := context.WithTimeout(ctx, defaultTimeout)
|
||||||
@@ -465,9 +472,13 @@ func subscribeChannelNotifications(ctxb context.Context, t *harnessTest,
|
|||||||
// findTxAtHeight gets all of the transactions that a node's wallet has a record
|
// findTxAtHeight gets all of the transactions that a node's wallet has a record
|
||||||
// of at the target height, and finds and returns the tx with the target txid,
|
// of at the target height, and finds and returns the tx with the target txid,
|
||||||
// failing if it is not found.
|
// failing if it is not found.
|
||||||
func findTxAtHeight(ctx context.Context, t *harnessTest, height int32,
|
func findTxAtHeight(t *harnessTest, height int32,
|
||||||
target string, node *lntest.HarnessNode) *lnrpc.Transaction {
|
target string, node *lntest.HarnessNode) *lnrpc.Transaction {
|
||||||
|
|
||||||
|
ctxb := context.Background()
|
||||||
|
ctx, cancel := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
txns, err := node.LightningClient.GetTransactions(
|
txns, err := node.LightningClient.GetTransactions(
|
||||||
ctx, &lnrpc.GetTransactionsRequest{
|
ctx, &lnrpc.GetTransactionsRequest{
|
||||||
StartHeight: height,
|
StartHeight: height,
|
||||||
|
|||||||
Reference in New Issue
Block a user