itest: manage context within HarnessNode

This commit removes the context as a param needed when calling methods
of HarnessNode. This change moves the context management inside
HarnessNode, aside from saving us a few lines, it makes the context
creation/timeout less error-prone.
This commit is contained in:
yyforyongyu 2021-09-14 18:40:02 +08:00
parent 6f59f41e86
commit 26ed64fa52
No known key found for this signature in database
GPG key ID: 9BCD95C4FF296868
30 changed files with 186 additions and 309 deletions

View file

@ -218,12 +218,10 @@ func (n *NetworkHarness) SetUp(t *testing.T,
} }
// Now we want to wait for the nodes to catch up. // Now we want to wait for the nodes to catch up.
ctxt, cancel := context.WithTimeout(ctxb, DefaultTimeout) if err := n.Alice.WaitForBlockchainSync(); err != nil {
defer cancel()
if err := n.Alice.WaitForBlockchainSync(ctxt); err != nil {
return err return err
} }
if err := n.Bob.WaitForBlockchainSync(ctxt); err != nil { if err := n.Bob.WaitForBlockchainSync(); err != nil {
return err return err
} }
@ -403,7 +401,7 @@ func (n *NetworkHarness) newNodeWithSeed(name string, extraArgs []string,
// Pass the init request via rpc to finish unlocking the node. This will // Pass the init request via rpc to finish unlocking the node. This will
// also initialize the macaroon-authenticated LightningClient. // also initialize the macaroon-authenticated LightningClient.
response, err := node.Init(ctxb, initReq) response, err := node.Init(initReq)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
@ -429,8 +427,6 @@ func (n *NetworkHarness) NewNodeRemoteSigner(name string, extraArgs []string,
return nil, err return nil, err
} }
ctxb := context.Background()
// With the seed created, construct the init request to the node, // With the seed created, construct the init request to the node,
// including the newly generated seed. // including the newly generated seed.
initReq := &lnrpc.InitWalletRequest{ initReq := &lnrpc.InitWalletRequest{
@ -440,7 +436,7 @@ func (n *NetworkHarness) NewNodeRemoteSigner(name string, extraArgs []string,
// Pass the init request via rpc to finish unlocking the node. This will // Pass the init request via rpc to finish unlocking the node. This will
// also initialize the macaroon-authenticated LightningClient. // also initialize the macaroon-authenticated LightningClient.
_, err = node.Init(ctxb, initReq) _, err = node.Init(initReq)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -478,7 +474,7 @@ func (n *NetworkHarness) RestoreNodeWithSeed(name string, extraArgs []string,
ChannelBackups: chanBackups, ChannelBackups: chanBackups,
} }
_, err = node.Init(context.Background(), initReq) _, err = node.Init(initReq)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -828,15 +824,13 @@ func (n *NetworkHarness) RestartNode(node *HarnessNode, callback func() error,
unlockReq.RecoveryWindow = 1000 unlockReq.RecoveryWindow = 1000
} }
if err := node.Unlock(context.Background(), unlockReq); err != nil { if err := node.Unlock(unlockReq); err != nil {
return err return err
} }
// Give the node some time to catch up with the chain before we continue // Give the node some time to catch up with the chain before we
// with the tests. // continue with the tests.
ctxc, done := context.WithTimeout(context.Background(), DefaultTimeout) return node.WaitForBlockchainSync()
defer done()
return node.WaitForBlockchainSync(ctxc)
} }
// RestartNodeNoUnlock attempts to restart a lightning node by shutting it down // RestartNodeNoUnlock attempts to restart a lightning node by shutting it down
@ -1057,10 +1051,10 @@ func (n *NetworkHarness) OpenChannel(srcNode, destNode *HarnessNode,
// Otherwise, we may run into a check within the funding manager that // Otherwise, we may run into a check within the funding manager that
// prevents any funding workflows from being kicked off if the chain // prevents any funding workflows from being kicked off if the chain
// isn't yet synced. // isn't yet synced.
if err := srcNode.WaitForBlockchainSync(ctx); err != nil { if err := srcNode.WaitForBlockchainSync(); err != nil {
return nil, fmt.Errorf("unable to sync srcNode chain: %v", err) return nil, fmt.Errorf("unable to sync srcNode chain: %v", err)
} }
if err := destNode.WaitForBlockchainSync(ctx); err != nil { if err := destNode.WaitForBlockchainSync(); err != nil {
return nil, fmt.Errorf("unable to sync destNode chain: %v", err) return nil, fmt.Errorf("unable to sync destNode chain: %v", err)
} }
@ -1133,10 +1127,10 @@ func (n *NetworkHarness) OpenPendingChannel(srcNode, destNode *HarnessNode,
defer cancel() defer cancel()
// Wait until srcNode and destNode have blockchain synced // Wait until srcNode and destNode have blockchain synced
if err := srcNode.WaitForBlockchainSync(ctx); err != nil { if err := srcNode.WaitForBlockchainSync(); err != nil {
return nil, fmt.Errorf("unable to sync srcNode chain: %v", err) return nil, fmt.Errorf("unable to sync srcNode chain: %v", err)
} }
if err := destNode.WaitForBlockchainSync(ctx); err != nil { if err := destNode.WaitForBlockchainSync(); err != nil {
return nil, fmt.Errorf("unable to sync destNode chain: %v", err) return nil, fmt.Errorf("unable to sync destNode chain: %v", err)
} }

View file

@ -1783,13 +1783,9 @@ func assertChannelPolicyUpdate(t *testing.T, node *lntest.HarnessNode,
advertisingNode string, policy *lnrpc.RoutingPolicy, advertisingNode string, policy *lnrpc.RoutingPolicy,
chanPoint *lnrpc.ChannelPoint, includeUnannounced bool) { chanPoint *lnrpc.ChannelPoint, includeUnannounced bool) {
ctxb := context.Background()
ctxt, cancel := context.WithTimeout(ctxb, lntest.DefaultTimeout)
defer cancel()
require.NoError( require.NoError(
t, node.WaitForChannelPolicyUpdate( t, node.WaitForChannelPolicyUpdate(
ctxt, advertisingNode, policy, advertisingNode, policy,
chanPoint, includeUnannounced, chanPoint, includeUnannounced,
), "error while waiting for channel update", ), "error while waiting for channel update",
) )

View file

@ -245,11 +245,9 @@ func testSendPaymentAMPInvoiceRepeat(net *lntest.NetworkHarness,
Amt: chanAmt, Amt: chanAmt,
}, },
) )
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPoint)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(t.t, err, "carol didn't report channel") require.NoError(t.t, err, "carol didn't report channel")
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = dave.WaitForNetworkChannelOpen(chanPoint)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(t.t, err, "dave didn't report channel") require.NoError(t.t, err, "dave didn't report channel")
// Create an AMP invoice of a trivial amount, that we'll pay repeatedly // Create an AMP invoice of a trivial amount, that we'll pay repeatedly

View file

@ -982,12 +982,11 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
) )
// Wait for both sides to see the opened channel. // Wait for both sides to see the opened channel.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = dave.WaitForNetworkChannelOpen(chanPoint)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("dave didn't report channel: %v", err) t.Fatalf("dave didn't report channel: %v", err)
} }
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint) err = carol.WaitForNetworkChannelOpen(chanPoint)
if err != nil { if err != nil {
t.Fatalf("carol didn't report channel: %v", err) t.Fatalf("carol didn't report channel: %v", err)
} }
@ -1327,11 +1326,9 @@ func createLegacyRevocationChannel(net *lntest.NetworkHarness, t *harnessTest,
} }
_ = mineBlocks(t, net, 6, 1) _ = mineBlocks(t, net, 6, 1)
ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout) err = from.WaitForNetworkChannelOpen(chanPoint)
defer cancel()
err = from.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(t.t, err) require.NoError(t.t, err)
err = to.WaitForNetworkChannelOpen(ctxt, chanPoint) err = to.WaitForNetworkChannelOpen(chanPoint)
require.NoError(t.t, err) require.NoError(t.t, err)
} }

View file

@ -18,8 +18,6 @@ import (
// testChannelBalance creates a new channel between Alice and Bob, then checks // testChannelBalance creates a new channel between Alice and Bob, then checks
// channel balance to be equal amount specified while creation of channel. // channel balance to be equal amount specified while creation of channel.
func testChannelBalance(net *lntest.NetworkHarness, t *harnessTest) { func testChannelBalance(net *lntest.NetworkHarness, t *harnessTest) {
ctxb := context.Background()
// Open a channel with 0.16 BTC between Alice and Bob, ensuring the // Open a channel with 0.16 BTC between Alice and Bob, ensuring the
// channel has been opened properly. // channel has been opened properly.
amount := funding.MaxBtcFundingAmount amount := funding.MaxBtcFundingAmount
@ -61,14 +59,12 @@ func testChannelBalance(net *lntest.NetworkHarness, t *harnessTest) {
) )
// Wait for both Alice and Bob to recognize this new channel. // Wait for both Alice and Bob to recognize this new channel.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err := net.Alice.WaitForNetworkChannelOpen(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 "+
"timeout: %v", err) "timeout: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = net.Bob.WaitForNetworkChannelOpen(chanPoint)
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("bob didn't advertise channel before "+ t.Fatalf("bob didn't advertise channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -155,15 +151,13 @@ func testChannelUnsettledBalance(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Alice and Carol to receive the channel edge from the // Wait for Alice and Carol to receive the channel edge from the
// funding manager. // funding manager.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err := net.Alice.WaitForNetworkChannelOpen(chanPointAlice)
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
if err != nil { if err != nil {
t.Fatalf("alice didn't see the alice->carol channel before "+ t.Fatalf("alice didn't see the alice->carol channel before "+
"timeout: %v", err) "timeout: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPointAlice)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
if err != nil { if err != nil {
t.Fatalf("alice didn't see the alice->carol channel before "+ t.Fatalf("alice didn't see the alice->carol channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -191,7 +185,7 @@ func testChannelUnsettledBalance(net *lntest.NetworkHarness, t *harnessTest) {
errChan := make(chan error) errChan := make(chan error)
for i := 0; i < numInvoices; i++ { for i := 0; i < numInvoices; i++ {
go func() { go func() {
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
_, err := net.Alice.RouterClient.SendPaymentV2(ctxt, _, err := net.Alice.RouterClient.SendPaymentV2(ctxt,
&routerrpc.SendPaymentRequest{ &routerrpc.SendPaymentRequest{
Dest: carolPubKey, Dest: carolPubKey,

View file

@ -335,13 +335,12 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
// Wait for Alice and Carol to receive the channel edge from the // Wait for Alice and Carol to receive the channel edge from the
// funding manager. // funding manager.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = alice.WaitForNetworkChannelOpen(chanPoint)
err = alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("alice didn't see the alice->carol channel before "+ t.Fatalf("alice didn't see the alice->carol channel before "+
"timeout: %v", err) "timeout: %v", err)
} }
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint) err = carol.WaitForNetworkChannelOpen(chanPoint)
if err != nil { if err != nil {
t.Fatalf("alice didn't see the alice->carol channel before "+ t.Fatalf("alice didn't see the alice->carol channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -1430,8 +1429,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) {
carolPayReqs := []string{resp.PaymentRequest} carolPayReqs := []string{resp.PaymentRequest}
// 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) err = net.Alice.WaitForNetworkChannelOpen(chanPoint)
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("alice didn't see the alice->carol channel before "+ t.Fatalf("alice didn't see the alice->carol channel before "+
"timeout: %v", err) "timeout: %v", err)

View file

@ -58,12 +58,10 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Alice and Bob to receive the channel edge from the // Wait for Alice and Bob to receive the channel edge from the
// funding manager. // funding manager.
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout) err := alice.WaitForNetworkChannelOpen(chanPoint)
defer cancel()
err := alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(t.t, err, "alice didn't see the alice->bob channel") require.NoError(t.t, err, "alice didn't see the alice->bob channel")
err = bob.WaitForNetworkChannelOpen(ctxt, chanPoint) err = bob.WaitForNetworkChannelOpen(chanPoint)
require.NoError(t.t, err, "bob didn't see the alice->bob channel") require.NoError(t.t, err, "bob didn't see the alice->bob channel")
// Launch a node for Carol which will connect to Alice and Bob in order // Launch a node for Carol which will connect to Alice and Bob in order
@ -83,12 +81,9 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) {
assertChannelUpdate := func(node *lntest.HarnessNode, assertChannelUpdate := func(node *lntest.HarnessNode,
policy *lnrpc.RoutingPolicy) { policy *lnrpc.RoutingPolicy) {
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel()
require.NoError( require.NoError(
t.t, carol.WaitForChannelPolicyUpdate( t.t, carol.WaitForChannelPolicyUpdate(
ctxt, node.PubKeyStr, policy, chanPoint, false, node.PubKeyStr, policy, chanPoint, false,
), "error while waiting for channel update", ), "error while waiting for channel update",
) )
} }

View file

@ -85,12 +85,11 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
) )
} }
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err := net.Alice.WaitForNetworkChannelOpen(chanPoint)
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("alice didn't report channel: %v", err) t.Fatalf("alice didn't report channel: %v", err)
} }
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint) err = net.Bob.WaitForNetworkChannelOpen(chanPoint)
if err != nil { if err != nil {
t.Fatalf("bob didn't report channel: %v", err) t.Fatalf("bob didn't report channel: %v", err)
} }
@ -163,18 +162,15 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
) )
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = net.Alice.WaitForNetworkChannelOpen(chanPoint2)
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint2)
if err != nil { if err != nil {
t.Fatalf("alice didn't report channel: %v", err) t.Fatalf("alice didn't report channel: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = net.Bob.WaitForNetworkChannelOpen(chanPoint2)
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint2)
if err != nil { if err != nil {
t.Fatalf("bob didn't report channel: %v", err) t.Fatalf("bob didn't report channel: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPoint2)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint2)
if err != nil { if err != nil {
t.Fatalf("carol didn't report channel: %v", err) t.Fatalf("carol didn't report channel: %v", err)
} }
@ -187,7 +183,7 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
Memo: "testing", Memo: "testing",
Value: int64(payAmt), Value: int64(payAmt),
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
resp, err := carol.AddInvoice(ctxt, invoice) resp, err := carol.AddInvoice(ctxt, invoice)
if err != nil { if err != nil {
t.Fatalf("unable to add invoice: %v", err) t.Fatalf("unable to add invoice: %v", err)
@ -387,13 +383,11 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
) )
defer closeChannelAndAssert(t, net, net.Alice, chanPoint3, false) defer closeChannelAndAssert(t, net, net.Alice, chanPoint3, false)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = net.Alice.WaitForNetworkChannelOpen(chanPoint3)
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint3)
if err != nil { if err != nil {
t.Fatalf("alice didn't report channel: %v", err) t.Fatalf("alice didn't report channel: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPoint3)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint3)
if err != nil { if err != nil {
t.Fatalf("bob didn't report channel: %v", err) t.Fatalf("bob didn't report channel: %v", err)
} }
@ -505,8 +499,6 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
// flag set is sent once a channel has been either unilaterally or cooperatively // flag set is sent once a channel has been either unilaterally or cooperatively
// closed. // closed.
func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) { func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
ctxb := context.Background()
const ( const (
chanAmt = 100000 chanAmt = 100000
) )
@ -588,12 +580,9 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
assertPolicyUpdate := func(node *lntest.HarnessNode, assertPolicyUpdate := func(node *lntest.HarnessNode,
policy *lnrpc.RoutingPolicy, chanPoint *lnrpc.ChannelPoint) { policy *lnrpc.RoutingPolicy, chanPoint *lnrpc.ChannelPoint) {
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel()
require.NoError( require.NoError(
t.t, dave.WaitForChannelPolicyUpdate( t.t, dave.WaitForChannelPolicyUpdate(
ctxt, node.PubKeyStr, policy, chanPoint, false, node.PubKeyStr, policy, chanPoint, false,
), "error while waiting for channel update", ), "error while waiting for channel update",
) )
} }

View file

@ -161,8 +161,7 @@ func testEtcdFailoverCase(net *lntest.NetworkHarness, ht *harnessTest,
assertLeader(ht, observer, "Carol-2") assertLeader(ht, observer, "Carol-2")
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol2.Unlock(&lnrpc.UnlockWalletRequest{
err = carol2.Unlock(ctxt, &lnrpc.UnlockWalletRequest{
WalletPassword: password, WalletPassword: password,
}) })
if err != nil { if err != nil {

View file

@ -534,8 +534,6 @@ func (c *interceptorTestContext) closeChannels() {
} }
func (c *interceptorTestContext) waitForChannels() { func (c *interceptorTestContext) waitForChannels() {
ctxb := context.Background()
// Wait for all nodes to have seen all channels. // Wait for all nodes to have seen all channels.
for _, chanPoint := range c.networkChans { for _, chanPoint := range c.networkChans {
for _, node := range c.nodes { for _, node := range c.nodes {
@ -547,8 +545,7 @@ func (c *interceptorTestContext) waitForChannels() {
Index: chanPoint.OutputIndex, Index: chanPoint.OutputIndex,
} }
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = node.WaitForNetworkChannelOpen(chanPoint)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(c.t.t, err, fmt.Sprintf("(%d): timeout "+ require.NoError(c.t.t, err, fmt.Sprintf("(%d): timeout "+
"waiting for channel(%s) open", node.NodeID, "waiting for channel(%s) open", node.NodeID,
point)) point))

View file

@ -196,7 +196,6 @@ func basicChannelFundingTest(t *harnessTest, net *lntest.NetworkHarness,
// open or an error occurs in the funding process. A series of // open or an error occurs in the funding process. A series of
// assertions will be executed to ensure the funding process completed // assertions will be executed to ensure the funding process completed
// successfully. // successfully.
ctxb := context.Background()
chanPoint := openChannelAndAssert( chanPoint := openChannelAndAssert(
t, net, alice, bob, t, net, alice, bob,
lntest.OpenChannelParams{ lntest.OpenChannelParams{
@ -207,12 +206,10 @@ func basicChannelFundingTest(t *harnessTest, net *lntest.NetworkHarness,
}, },
) )
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err := alice.WaitForNetworkChannelOpen(chanPoint)
err := alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(t.t, err, "alice didn't report channel") require.NoError(t.t, err, "alice didn't report channel")
err = bob.WaitForNetworkChannelOpen(ctxt, chanPoint) err = bob.WaitForNetworkChannelOpen(chanPoint)
require.NoError(t.t, err, "bob didn't report channel") require.NoError(t.t, err, "bob didn't report channel")
cType, err := channelCommitType(alice, chanPoint) cType, err := channelCommitType(alice, chanPoint)
@ -816,13 +813,11 @@ func testBatchChanFunding(net *lntest.NetworkHarness, t *harnessTest) {
block := mineBlocks(t, net, 6, 1)[0] block := mineBlocks(t, net, 6, 1)[0]
assertTxInBlock(t, block, txHash) assertTxInBlock(t, block, txHash)
ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout) err = net.Alice.WaitForNetworkChannelOpen(chanPoint1)
defer cancel()
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint1)
require.NoError(t.t, err) require.NoError(t.t, err)
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint2) err = net.Alice.WaitForNetworkChannelOpen(chanPoint2)
require.NoError(t.t, err) require.NoError(t.t, err)
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint3) err = net.Alice.WaitForNetworkChannelOpen(chanPoint3)
require.NoError(t.t, err) require.NoError(t.t, err)
// With the channel open, ensure that it is counted towards Carol's // With the channel open, ensure that it is counted towards Carol's

View file

@ -74,8 +74,8 @@ func testHoldInvoiceForceClose(net *lntest.NetworkHarness, t *harnessTest) {
require.Len(t.t, chans.Channels[0].PendingHtlcs, 1) require.Len(t.t, chans.Channels[0].PendingHtlcs, 1)
activeHtlc := chans.Channels[0].PendingHtlcs[0] activeHtlc := chans.Channels[0].PendingHtlcs[0]
require.NoError(t.t, net.Alice.WaitForBlockchainSync(ctxb)) require.NoError(t.t, net.Alice.WaitForBlockchainSync())
require.NoError(t.t, net.Bob.WaitForBlockchainSync(ctxb)) require.NoError(t.t, net.Bob.WaitForBlockchainSync())
info, err := net.Alice.GetInfo(ctxb, &lnrpc.GetInfoRequest{}) info, err := net.Alice.GetInfo(ctxb, &lnrpc.GetInfoRequest{})
require.NoError(t.t, err) require.NoError(t.t, err)
@ -99,8 +99,8 @@ func testHoldInvoiceForceClose(net *lntest.NetworkHarness, t *harnessTest) {
mineBlocksSlow(t, net, blocksTillForce, 0) mineBlocksSlow(t, net, blocksTillForce, 0)
require.NoError(t.t, net.Alice.WaitForBlockchainSync(ctxb)) require.NoError(t.t, net.Alice.WaitForBlockchainSync())
require.NoError(t.t, net.Bob.WaitForBlockchainSync(ctxb)) require.NoError(t.t, net.Bob.WaitForBlockchainSync())
// 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

View file

@ -48,15 +48,13 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Alice and Carol to receive the channel edge from the // Wait for Alice and Carol to receive the channel edge from the
// funding manager. // funding manager.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err := net.Alice.WaitForNetworkChannelOpen(chanPointAlice)
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
if err != nil { if err != nil {
t.Fatalf("alice didn't see the alice->carol channel before "+ t.Fatalf("alice didn't see the alice->carol channel before "+
"timeout: %v", err) "timeout: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPointAlice)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
if err != nil { if err != nil {
t.Fatalf("carol didn't see the carol->alice channel before "+ t.Fatalf("carol didn't see the carol->alice channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -92,7 +90,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
Hash: payHash[:], Hash: payHash[:],
Private: true, Private: true,
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
resp, err := carol.AddHoldInvoice(ctxt, invoiceReq) resp, err := carol.AddHoldInvoice(ctxt, invoiceReq)
if err != nil { if err != nil {
t.Fatalf("unable to add invoice: %v", err) t.Fatalf("unable to add invoice: %v", err)
@ -165,7 +163,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
req := &lnrpc.ListPaymentsRequest{ req := &lnrpc.ListPaymentsRequest{
IncludeIncomplete: true, IncludeIncomplete: true,
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
paymentsResp, err := net.Alice.ListPayments(ctxt, req) paymentsResp, err := net.Alice.ListPayments(ctxt, req)
if err != nil { if err != nil {
return fmt.Errorf("error when obtaining payments: %v", return fmt.Errorf("error when obtaining payments: %v",
@ -299,7 +297,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
for i, preimage := range preimages { for i, preimage := range preimages {
var expectedState lnrpc.Invoice_InvoiceState var expectedState lnrpc.Invoice_InvoiceState
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
if i%2 == 0 { if i%2 == 0 {
settle := &invoicesrpc.SettleInvoiceMsg{ settle := &invoicesrpc.SettleInvoiceMsg{
Preimage: preimage[:], Preimage: preimage[:],
@ -368,7 +366,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
req := &lnrpc.ListPaymentsRequest{ req := &lnrpc.ListPaymentsRequest{
IncludeIncomplete: true, IncludeIncomplete: true,
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
paymentsResp, err := net.Alice.ListPayments(ctxt, req) paymentsResp, err := net.Alice.ListPayments(ctxt, req)
if err != nil { if err != nil {
t.Fatalf("error when obtaining Alice payments: %v", err) t.Fatalf("error when obtaining Alice payments: %v", err)

View file

@ -665,8 +665,7 @@ func testStatelessInit(net *lntest.NetworkHarness, t *harnessTest) {
NewPassword: newPw, NewPassword: newPw,
StatelessInit: true, StatelessInit: true,
} }
ctxb := context.Background() response, err := carol.InitChangePassword(changePwReq)
response, err := carol.InitChangePassword(ctxb, changePwReq)
require.NoError(t.t, err) require.NoError(t.t, err)
// Again, make sure no macaroon files have been created by the node // Again, make sure no macaroon files have been created by the node

View file

@ -34,12 +34,10 @@ func testMaxHtlcPathfind(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Alice and Bob to receive the channel edge from the // Wait for Alice and Bob to receive the channel edge from the
// funding manager. // funding manager.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err := net.Alice.WaitForNetworkChannelOpen(chanPoint)
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(t.t, err, "alice does not have open channel") require.NoError(t.t, err, "alice does not have open channel")
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = net.Bob.WaitForNetworkChannelOpen(chanPoint)
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(t.t, err, "bob does not have open channel") require.NoError(t.t, err, "bob does not have open channel")
// Alice and bob should have one channel open with each other now. // Alice and bob should have one channel open with each other now.
@ -87,7 +85,7 @@ func testMaxHtlcPathfind(net *lntest.NetworkHarness, t *harnessTest) {
// Now, we're going to try to send another payment from Bob -> Alice. // Now, we're going to try to send another payment from Bob -> Alice.
// We've hit our max remote htlcs, so we expect this payment to spin // We've hit our max remote htlcs, so we expect this payment to spin
// out dramatically with pathfinding. // out dramatically with pathfinding.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
payment, err := net.Bob.RouterClient.SendPaymentV2( payment, err := net.Bob.RouterClient.SendPaymentV2(
ctxt, &routerrpc.SendPaymentRequest{ ctxt, &routerrpc.SendPaymentRequest{
Amt: 1000, Amt: 1000,

View file

@ -236,23 +236,22 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) {
} }
// Wait for all channels to be recognized and advertized. // Wait for all channels to be recognized and advertized.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPoint)
err = carol.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 "+
"timeout: %v", err) "timeout: %v", err)
} }
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint) err = dave.WaitForNetworkChannelOpen(chanPoint)
if err != nil { if err != nil {
t.Fatalf("bob didn't advertise channel before "+ t.Fatalf("bob didn't advertise channel before "+
"timeout: %v", err) "timeout: %v", err)
} }
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointFC) err = carol.WaitForNetworkChannelOpen(chanPointFC)
if err != nil { if err != nil {
t.Fatalf("alice didn't advertise channel before "+ t.Fatalf("alice didn't advertise channel before "+
"timeout: %v", err) "timeout: %v", err)
} }
err = fred.WaitForNetworkChannelOpen(ctxt, chanPointFC) err = fred.WaitForNetworkChannelOpen(chanPointFC)
if err != nil { if err != nil {
t.Fatalf("bob didn't advertise channel before "+ t.Fatalf("bob didn't advertise channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -386,15 +385,13 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Alice and Bob to receive the channel edge from the // Wait for Alice and Bob to receive the channel edge from the
// funding manager. // funding manager.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err := alice.WaitForNetworkChannelOpen(chanPoint)
err := 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 "+
"timeout: %v", err) "timeout: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = bob.WaitForNetworkChannelOpen(chanPoint)
err = bob.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("bob didn't see the bob->alice channel before "+ t.Fatalf("bob didn't see the bob->alice channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -407,8 +404,7 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
// Get the ListChannel response from Alice. // Get the ListChannel response from Alice.
listReq := &lnrpc.ListChannelsRequest{} listReq := &lnrpc.ListChannelsRequest{}
ctxb = context.Background() ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
resp, err := alice.ListChannels(ctxt, listReq) resp, err := alice.ListChannels(ctxt, listReq)
if err != nil { if err != nil {
t.Fatalf("unable to query for %s's channel list: %v", t.Fatalf("unable to query for %s's channel list: %v",
@ -484,8 +480,6 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
// max pending channel number was exceeded and that '--maxpendingchannels' flag // max pending channel number was exceeded and that '--maxpendingchannels' flag
// exists and works properly. // exists and works properly.
func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) { func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
ctxb := context.Background()
maxPendingChannels := lncfg.DefaultMaxPendingChannels + 1 maxPendingChannels := lncfg.DefaultMaxPendingChannels + 1
amount := funding.MaxBtcFundingAmount amount := funding.MaxBtcFundingAmount
@ -557,8 +551,7 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
// Ensure that the funding transaction enters a block, and is // Ensure that the funding transaction enters a block, and is
// properly advertised by Alice. // properly advertised by Alice.
assertTxInBlock(t, block, fundingTxID) assertTxInBlock(t, block, fundingTxID)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = net.Alice.WaitForNetworkChannelOpen(fundingChanPoint)
err = net.Alice.WaitForNetworkChannelOpen(ctxt, fundingChanPoint)
if err != nil { if err != nil {
t.Fatalf("channel not seen on network before "+ t.Fatalf("channel not seen on network before "+
"timeout: %v", err) "timeout: %v", err)
@ -878,8 +871,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Carol to receive the channel edge from the funding // Wait for Carol to receive the channel edge from the funding
// manager. // manager.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPoint)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("carol didn't see the carol->%s channel "+ t.Fatalf("carol didn't see the carol->%s channel "+
"before timeout: %v", node.Name(), err) "before timeout: %v", node.Name(), err)
@ -975,7 +967,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
} }
balReq := &lnrpc.WalletBalanceRequest{} balReq := &lnrpc.WalletBalanceRequest{}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
balResp, err := node.WalletBalance(ctxt, balReq) balResp, err := node.WalletBalance(ctxt, balReq)
if err != nil { if err != nil {
t.Fatalf("unable to get dave's balance: %v", err) t.Fatalf("unable to get dave's balance: %v", err)
@ -1352,16 +1344,15 @@ func testAbandonChannel(net *lntest.NetworkHarness, t *harnessTest) {
chanPointStr := fmt.Sprintf("%v:%v", txid, chanPoint.OutputIndex) chanPointStr := fmt.Sprintf("%v:%v", txid, chanPoint.OutputIndex)
// Wait for channel to be confirmed open. // Wait for channel to be confirmed open.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = net.Alice.WaitForNetworkChannelOpen(chanPoint)
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(t.t, err, "alice wait for network channel open") require.NoError(t.t, err, "alice wait for network channel open")
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint) err = net.Bob.WaitForNetworkChannelOpen(chanPoint)
require.NoError(t.t, err, "bob wait for network channel open") require.NoError(t.t, err, "bob wait for network channel open")
// Now that the channel is open, we'll obtain its channel ID real quick // Now that the channel is open, we'll obtain its channel ID real quick
// so we can use it to query the graph below. // so we can use it to query the graph below.
listReq := &lnrpc.ListChannelsRequest{} listReq := &lnrpc.ListChannelsRequest{}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
aliceChannelList, err := net.Alice.ListChannels(ctxt, listReq) aliceChannelList, err := net.Alice.ListChannels(ctxt, listReq)
require.NoError(t.t, err) require.NoError(t.t, err)
var chanID uint64 var chanID uint64

View file

@ -319,8 +319,6 @@ func (c *mppTestContext) shutdownNodes() {
} }
func (c *mppTestContext) waitForChannels() { func (c *mppTestContext) waitForChannels() {
ctxb := context.Background()
// Wait for all nodes to have seen all channels. // Wait for all nodes to have seen all channels.
for _, chanPoint := range c.networkChans { for _, chanPoint := range c.networkChans {
for _, node := range c.nodes { for _, node := range c.nodes {
@ -333,8 +331,7 @@ func (c *mppTestContext) waitForChannels() {
Index: chanPoint.OutputIndex, Index: chanPoint.OutputIndex,
} }
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = node.WaitForNetworkChannelOpen(chanPoint)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
c.t.Fatalf("(%v:%d): timeout waiting for "+ c.t.Fatalf("(%v:%d): timeout waiting for "+
"channel(%s) open: %v", "channel(%s) open: %v",

View file

@ -29,8 +29,7 @@ func testHtlcErrorPropagation(net *lntest.NetworkHarness, t *harnessTest) {
Amt: chanAmt, Amt: chanAmt,
}, },
) )
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) if err := net.Alice.WaitForNetworkChannelOpen(chanPointAlice); err != nil {
if err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice); err != nil {
t.Fatalf("channel not seen by alice before timeout: %v", err) t.Fatalf("channel not seen by alice before timeout: %v", err)
} }
@ -115,7 +114,7 @@ out:
for { for {
select { select {
case <-checkTableTicker.C: case <-checkTableTicker.C:
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
_, err := net.Alice.GetNodeInfo(ctxt, nodeInfoReq) _, err := net.Alice.GetNodeInfo(ctxt, nodeInfoReq)
if err != nil && strings.Contains(err.Error(), if err != nil && strings.Contains(err.Error(),
"unable to find") { "unable to find") {
@ -138,7 +137,7 @@ out:
Memo: "kek99", Memo: "kek99",
Value: payAmt, Value: payAmt,
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
carolInvoice, err := carol.AddInvoice(ctxt, invoiceReq) carolInvoice, err := carol.AddInvoice(ctxt, invoiceReq)
if err != nil { if err != nil {
t.Fatalf("unable to generate carol invoice: %v", err) t.Fatalf("unable to generate carol invoice: %v", err)
@ -154,8 +153,7 @@ out:
// Before we send the payment, ensure that the announcement of the new // Before we send the payment, ensure that the announcement of the new
// channel has been processed by Alice. // channel has been processed by Alice.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) if err := net.Alice.WaitForNetworkChannelOpen(chanPointBob); err != nil {
if err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointBob); err != nil {
t.Fatalf("channel not seen by alice before timeout: %v", err) t.Fatalf("channel not seen by alice before timeout: %v", err)
} }

View file

@ -107,8 +107,7 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
Index: chanPoint.OutputIndex, Index: chanPoint.OutputIndex,
} }
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = node.WaitForNetworkChannelOpen(chanPoint)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+ t.Fatalf("%s(%d): timeout waiting for "+
"channel(%s) open: %v", nodeNames[i], "channel(%s) open: %v", nodeNames[i],
@ -130,13 +129,11 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
// We'll wait for all parties to recognize the new channels within the // We'll wait for all parties to recognize the new channels within the
// network. // network.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = dave.WaitForNetworkChannelOpen(chanPointDave)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
if err != nil { if err != nil {
t.Fatalf("dave didn't advertise his channel: %v", err) t.Fatalf("dave didn't advertise his channel: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPointCarol)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
if err != nil { if err != nil {
t.Fatalf("carol didn't advertise her channel in time: %v", t.Fatalf("carol didn't advertise her channel in time: %v",
err) err)

View file

@ -210,8 +210,6 @@ func createThreeHopNetwork(t *harnessTest, net *lntest.NetworkHarness,
alice, bob *lntest.HarnessNode, carolHodl bool, c lnrpc.CommitmentType) ( alice, bob *lntest.HarnessNode, carolHodl bool, c lnrpc.CommitmentType) (
*lnrpc.ChannelPoint, *lnrpc.ChannelPoint, *lntest.HarnessNode) { *lnrpc.ChannelPoint, *lnrpc.ChannelPoint, *lntest.HarnessNode) {
ctxb := context.Background()
net.EnsureConnected(t.t, alice, bob) net.EnsureConnected(t.t, alice, bob)
// Make sure there are enough utxos for anchoring. // Make sure there are enough utxos for anchoring.
@ -242,14 +240,12 @@ func createThreeHopNetwork(t *harnessTest, net *lntest.NetworkHarness,
}, },
) )
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err := alice.WaitForNetworkChannelOpen(aliceChanPoint)
err := alice.WaitForNetworkChannelOpen(ctxt, aliceChanPoint)
if err != nil { if err != nil {
t.Fatalf("alice didn't report channel: %v", err) t.Fatalf("alice didn't report channel: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = bob.WaitForNetworkChannelOpen(aliceChanPoint)
err = bob.WaitForNetworkChannelOpen(ctxt, aliceChanPoint)
if err != nil { if err != nil {
t.Fatalf("bob didn't report channel: %v", err) t.Fatalf("bob didn't report channel: %v", err)
} }
@ -289,18 +285,15 @@ func createThreeHopNetwork(t *harnessTest, net *lntest.NetworkHarness,
FundingShim: bobFundingShim, FundingShim: bobFundingShim,
}, },
) )
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = bob.WaitForNetworkChannelOpen(bobChanPoint)
err = bob.WaitForNetworkChannelOpen(ctxt, bobChanPoint)
if err != nil { if err != nil {
t.Fatalf("alice didn't report channel: %v", err) t.Fatalf("alice didn't report channel: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(bobChanPoint)
err = carol.WaitForNetworkChannelOpen(ctxt, bobChanPoint)
if err != nil { if err != nil {
t.Fatalf("bob didn't report channel: %v", err) t.Fatalf("bob didn't report channel: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = alice.WaitForNetworkChannelOpen(bobChanPoint)
err = alice.WaitForNetworkChannelOpen(ctxt, bobChanPoint)
if err != nil { if err != nil {
t.Fatalf("bob didn't report channel: %v", err) t.Fatalf("bob didn't report channel: %v", err)
} }

View file

@ -237,12 +237,10 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) {
aliceChanPoint1, aliceChanPoint2, aliceChanPoint3, aliceChanPoint1, aliceChanPoint2, aliceChanPoint3,
} }
for _, chanPoint := range chanPoints { for _, chanPoint := range chanPoints {
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = alice.WaitForNetworkChannelOpen(chanPoint)
err = alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(t.t, err) require.NoError(t.t, err)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = bob.WaitForNetworkChannelOpen(chanPoint)
err = bob.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(t.t, err) require.NoError(t.t, err)
} }

View file

@ -142,14 +142,12 @@ 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) err = net.Alice.WaitForNetworkChannelOpen(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 "+
"timeout: %v", err) "timeout: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = net.Bob.WaitForNetworkChannelOpen(chanPoint)
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("bob didn't advertise channel before "+ t.Fatalf("bob didn't advertise channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -159,7 +157,7 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) {
req := &lnrpc.ChannelGraphRequest{ req := &lnrpc.ChannelGraphRequest{
IncludeUnannounced: true, IncludeUnannounced: true,
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
chanGraph, err := net.Alice.DescribeGraph(ctxt, req) chanGraph, err := net.Alice.DescribeGraph(ctxt, req)
if err != nil { if err != nil {
t.Fatalf("unable to query for alice's routing table: %v", err) t.Fatalf("unable to query for alice's routing table: %v", err)

View file

@ -69,12 +69,11 @@ func testListPayments(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Alice to recognize and advertise the new channel generated // Wait for Alice to recognize and advertise the new channel generated
// above. // above.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) if err = net.Alice.WaitForNetworkChannelOpen(chanPoint); err != nil {
if err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint); err != nil {
t.Fatalf("alice didn't advertise channel before "+ t.Fatalf("alice didn't advertise channel before "+
"timeout: %v", err) "timeout: %v", err)
} }
if err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint); err != nil { if err = net.Bob.WaitForNetworkChannelOpen(chanPoint); err != nil {
t.Fatalf("bob didn't advertise channel before "+ t.Fatalf("bob didn't advertise channel before "+
"timeout: %v", err) "timeout: %v", err)
} }
@ -292,8 +291,7 @@ func runAsyncPayments(net *lntest.NetworkHarness, t *harnessTest, alice,
} }
// 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) err = alice.WaitForNetworkChannelOpen(chanPoint)
err = 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 "+
"timeout: %v", err) "timeout: %v", err)
@ -307,7 +305,7 @@ func runAsyncPayments(net *lntest.NetworkHarness, t *harnessTest, alice,
for i := 0; i < numInvoices; i++ { for i := 0; i < numInvoices; i++ {
payReq := bobPayReqs[i] payReq := bobPayReqs[i]
go func() { go func() {
ctxt, _ = context.WithTimeout(ctxb, lntest.AsyncBenchmarkTimeout) ctxt, _ := context.WithTimeout(ctxb, lntest.AsyncBenchmarkTimeout)
stream, err := alice.RouterClient.SendPaymentV2( stream, err := alice.RouterClient.SendPaymentV2(
ctxt, ctxt,
&routerrpc.SendPaymentRequest{ &routerrpc.SendPaymentRequest{
@ -465,12 +463,11 @@ 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) if err = net.Alice.WaitForNetworkChannelOpen(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)
} }
if err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint); err != nil { if err = net.Bob.WaitForNetworkChannelOpen(chanPoint); err != nil {
t.Fatalf("bob didn't see the bob->alice channel before "+ t.Fatalf("bob didn't see the bob->alice channel before "+
"timeout: %v", err) "timeout: %v", err)
} }
@ -478,7 +475,7 @@ func testBidirectionalAsyncPayments(net *lntest.NetworkHarness, t *harnessTest)
// Reset mission control to prevent previous payment results from // Reset mission control to prevent previous payment results from
// interfering with this test. A new channel has been opened, but // interfering with this test. A new channel has been opened, but
// mission control operates on node pairs. // mission control operates on node pairs.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
_, err = net.Alice.RouterClient.ResetMissionControl( _, err = net.Alice.RouterClient.ResetMissionControl(
ctxt, &routerrpc.ResetMissionControlRequest{}, ctxt, &routerrpc.ResetMissionControlRequest{},
) )
@ -680,8 +677,7 @@ func testInvoiceSubscriptions(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for the channel to be recognized by both Alice and Bob before // Wait for the channel to be recognized by both Alice and Bob before
// continuing the rest of the test. // continuing the rest of the test.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = net.Alice.WaitForNetworkChannelOpen(chanPoint)
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
// TODO(roasbeef): will need to make num blocks to advertise a // TODO(roasbeef): will need to make num blocks to advertise a
// node param // node param

View file

@ -215,11 +215,9 @@ func runPsbtChanFunding(net *lntest.NetworkHarness, t *harnessTest, carol,
txHash := finalTx.TxHash() txHash := finalTx.TxHash()
block := mineBlocks(t, net, 6, 1)[0] block := mineBlocks(t, net, 6, 1)[0]
assertTxInBlock(t, block, &txHash) assertTxInBlock(t, block, &txHash)
ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPoint)
defer cancel()
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(t.t, err) require.NoError(t.t, err)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint2) err = carol.WaitForNetworkChannelOpen(chanPoint2)
require.NoError(t.t, err) require.NoError(t.t, err)
// With the channel open, ensure that it is counted towards Carol's // With the channel open, ensure that it is counted towards Carol's
@ -431,11 +429,9 @@ func testPsbtChanFundingExternal(net *lntest.NetworkHarness, t *harnessTest) {
// for the new channel to be propagated through the network. // for the new channel to be propagated through the network.
block := mineBlocks(t, net, 6, 1)[0] block := mineBlocks(t, net, 6, 1)[0]
assertTxInBlock(t, block, &txHash) assertTxInBlock(t, block, &txHash)
ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPoint)
defer cancel()
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(t.t, err) require.NoError(t.t, err)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint2) err = carol.WaitForNetworkChannelOpen(chanPoint2)
require.NoError(t.t, err) require.NoError(t.t, err)
// With the channel open, ensure that it is counted towards Carol's // With the channel open, ensure that it is counted towards Carol's
@ -483,11 +479,11 @@ func openChannelPsbt(ctx context.Context, srcNode, destNode *lntest.HarnessNode,
// Otherwise, we may run into a check within the funding manager that // Otherwise, we may run into a check within the funding manager that
// prevents any funding workflows from being kicked off if the chain // prevents any funding workflows from being kicked off if the chain
// isn't yet synced. // isn't yet synced.
if err := srcNode.WaitForBlockchainSync(ctx); err != nil { if err := srcNode.WaitForBlockchainSync(); err != nil {
return nil, nil, fmt.Errorf("unable to sync srcNode chain: %v", return nil, nil, fmt.Errorf("unable to sync srcNode chain: %v",
err) err)
} }
if err := destNode.WaitForBlockchainSync(ctx); err != nil { if err := destNode.WaitForBlockchainSync(); err != nil {
return nil, nil, fmt.Errorf("unable to sync destNode chain: %v", return nil, nil, fmt.Errorf("unable to sync destNode chain: %v",
err) err)
} }

View file

@ -24,8 +24,6 @@ import (
// retribution in the event that she fails immediately after detecting Bob's // retribution in the event that she fails immediately after detecting Bob's
// breach txn in the mempool. // breach txn in the mempool.
func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) { func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
ctxb := context.Background()
const ( const (
chanAmt = funding.MaxBtcFundingAmount chanAmt = funding.MaxBtcFundingAmount
paymentAmt = 10000 paymentAmt = 10000
@ -71,8 +69,7 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
} }
// Wait for Carol to receive the channel edge from the funding manager. // Wait for Carol to receive the channel edge from the funding manager.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPoint)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("carol didn't see the carol->bob channel before "+ t.Fatalf("carol didn't see the carol->bob channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -260,7 +257,6 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
// commitment output has zero-value. // commitment output has zero-value.
func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness, func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness,
t *harnessTest) { t *harnessTest) {
ctxb := context.Background()
const ( const (
chanAmt = funding.MaxBtcFundingAmount chanAmt = funding.MaxBtcFundingAmount
@ -312,8 +308,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
} }
// Wait for Dave to receive the channel edge from the funding manager. // Wait for Dave to receive the channel edge from the funding manager.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = dave.WaitForNetworkChannelOpen(chanPoint)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("dave didn't see the dave->carol channel before "+ t.Fatalf("dave didn't see the dave->carol channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -475,7 +470,6 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
// remote party breaches before settling extended HTLCs. // remote party breaches before settling extended HTLCs.
func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness, func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
t *harnessTest) { t *harnessTest) {
ctxb := context.Background()
const ( const (
chanAmt = funding.MaxBtcFundingAmount chanAmt = funding.MaxBtcFundingAmount
@ -559,8 +553,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
} }
// Wait for Dave to receive the channel edge from the funding manager. // Wait for Dave to receive the channel edge from the funding manager.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = dave.WaitForNetworkChannelOpen(chanPoint)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("dave didn't see the dave->carol channel before "+ t.Fatalf("dave didn't see the dave->carol channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -1017,8 +1010,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(
} }
// Wait for Dave to receive the channel edge from the funding manager. // Wait for Dave to receive the channel edge from the funding manager.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = dave.WaitForNetworkChannelOpen(chanPoint)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("dave didn't see the dave->carol channel before "+ t.Fatalf("dave didn't see the dave->carol channel before "+
"timeout: %v", err) "timeout: %v", err)

View file

@ -138,8 +138,7 @@ func testSingleHopSendToRouteCase(net *lntest.NetworkHarness, t *harnessTest,
Index: chanPoint.OutputIndex, Index: chanPoint.OutputIndex,
} }
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = node.WaitForNetworkChannelOpen(chanPoint)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+ t.Fatalf("%s(%d): timeout waiting for "+
"channel(%s) open: %v", node.Name(), "channel(%s) open: %v", node.Name(),
@ -527,8 +526,7 @@ func runMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest,
Index: chanPoint.OutputIndex, Index: chanPoint.OutputIndex,
} }
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = node.WaitForNetworkChannelOpen(chanPoint)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+ t.Fatalf("%s(%d): timeout waiting for "+
"channel(%s) open: %v", nodeNames[i], "channel(%s) open: %v", nodeNames[i],
@ -567,8 +565,7 @@ func runMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest,
// We'll wait for all parties to recognize the new channels within the // We'll wait for all parties to recognize the new channels within the
// network. // network.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPointBob)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointBob)
if err != nil { if err != nil {
t.Fatalf("bob didn't advertise his channel in time: %v", err) t.Fatalf("bob didn't advertise his channel in time: %v", err)
} }
@ -647,8 +644,7 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest)
}, },
) )
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err := net.Alice.WaitForNetworkChannelOpen(chanPointAlice)
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
if err != nil { if err != nil {
t.Fatalf("alice didn't advertise her channel: %v", err) t.Fatalf("alice didn't advertise her channel: %v", err)
} }
@ -678,8 +674,7 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest)
Amt: chanAmt, Amt: chanAmt,
}, },
) )
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPointCarol)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
if err != nil { if err != nil {
t.Fatalf("carol didn't advertise her channel: %v", err) t.Fatalf("carol didn't advertise her channel: %v", err)
} }
@ -690,7 +685,7 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest)
PubKey: charlie.PubKeyStr, PubKey: charlie.PubKeyStr,
Amt: int64(1), Amt: int64(1),
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
fakeRoute, err := carol.QueryRoutes(ctxt, fakeReq) fakeRoute, err := carol.QueryRoutes(ctxt, fakeReq)
if err != nil { if err != nil {
t.Fatalf("unable get fake route: %v", err) t.Fatalf("unable get fake route: %v", err)
@ -842,8 +837,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
Index: chanPoint.OutputIndex, Index: chanPoint.OutputIndex,
} }
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = node.WaitForNetworkChannelOpen(chanPoint)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+ t.Fatalf("%s(%d): timeout waiting for "+
"channel(%s) open: %v", nodeNames[i], "channel(%s) open: %v", nodeNames[i],
@ -1142,8 +1136,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) {
chanPointEve, chanPointEve,
} }
for i, chanPoint := range aliceChans { for i, chanPoint := range aliceChans {
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err := net.Alice.WaitForNetworkChannelOpen(chanPoint)
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("timed out waiting for channel open %s: %v", t.Fatalf("timed out waiting for channel open %s: %v",
chanNames[i], err) chanNames[i], err)
@ -1263,14 +1256,12 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
}, },
) )
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err := net.Alice.WaitForNetworkChannelOpen(chanPointAlice)
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
if err != nil { if err != nil {
t.Fatalf("alice didn't see the channel alice <-> bob before "+ t.Fatalf("alice didn't see the channel alice <-> bob before "+
"timeout: %v", err) "timeout: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = net.Bob.WaitForNetworkChannelOpen(chanPointAlice)
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
if err != nil { if err != nil {
t.Fatalf("bob didn't see the channel alice <-> bob before "+ t.Fatalf("bob didn't see the channel alice <-> bob before "+
"timeout: %v", err) "timeout: %v", err)
@ -1299,20 +1290,17 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
}, },
) )
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = net.Bob.WaitForNetworkChannelOpen(chanPointBob)
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPointBob)
if err != nil { if err != nil {
t.Fatalf("bob didn't see the channel bob <-> carol before "+ t.Fatalf("bob didn't see the channel bob <-> carol before "+
"timeout: %v", err) "timeout: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPointBob)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointBob)
if err != nil { if err != nil {
t.Fatalf("carol didn't see the channel bob <-> carol before "+ t.Fatalf("carol didn't see the channel bob <-> carol before "+
"timeout: %v", err) "timeout: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = net.Alice.WaitForNetworkChannelOpen(chanPointBob)
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointBob)
if err != nil { if err != nil {
t.Fatalf("alice didn't see the channel bob <-> carol before "+ t.Fatalf("alice didn't see the channel bob <-> carol before "+
"timeout: %v", err) "timeout: %v", err)
@ -1344,20 +1332,17 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
}, },
) )
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPointCarol)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
if err != nil { if err != nil {
t.Fatalf("carol didn't see the channel carol <-> dave before "+ t.Fatalf("carol didn't see the channel carol <-> dave before "+
"timeout: %v", err) "timeout: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = dave.WaitForNetworkChannelOpen(chanPointCarol)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
if err != nil { if err != nil {
t.Fatalf("dave didn't see the channel carol <-> dave before "+ t.Fatalf("dave didn't see the channel carol <-> dave before "+
"timeout: %v", err) "timeout: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = dave.WaitForNetworkChannelOpen(chanPointBob)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointBob)
if err != nil { if err != nil {
t.Fatalf("dave didn't see the channel bob <-> carol before "+ t.Fatalf("dave didn't see the channel bob <-> carol before "+
"timeout: %v", err) "timeout: %v", err)
@ -1387,7 +1372,7 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
Private: true, Private: true,
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
resp, err := dave.AddInvoice(ctxt, invoice) resp, err := dave.AddInvoice(ctxt, invoice)
if err != nil { if err != nil {
t.Fatalf("unable to add invoice for dave: %v", err) t.Fatalf("unable to add invoice for dave: %v", err)
@ -1506,8 +1491,7 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
Index: chanPoint.OutputIndex, Index: chanPoint.OutputIndex,
} }
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = node.WaitForNetworkChannelOpen(chanPoint)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+ t.Fatalf("%s(%d): timeout waiting for "+
"channel(%s) open: %v", nodeNames[i], "channel(%s) open: %v", nodeNames[i],
@ -1802,8 +1786,7 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) {
Index: chanPoint.OutputIndex, Index: chanPoint.OutputIndex,
} }
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = node.WaitForNetworkChannelOpen(chanPoint)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("%s(%d) timed out waiting for "+ t.Fatalf("%s(%d) timed out waiting for "+
"channel(%s) open: %v", nodeNames[i], "channel(%s) open: %v", nodeNames[i],

View file

@ -48,13 +48,12 @@ func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Alice to recognize and advertise the new channel generated // Wait for Alice to recognize and advertise the new channel generated
// above. // above.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = net.Alice.WaitForNetworkChannelOpen(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 "+
"timeout: %v", err) "timeout: %v", err)
} }
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint) err = net.Bob.WaitForNetworkChannelOpen(chanPoint)
if err != nil { if err != nil {
t.Fatalf("bob didn't advertise channel before "+ t.Fatalf("bob didn't advertise channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -78,7 +77,7 @@ func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) {
payHash := &lnrpc.PaymentHash{ payHash := &lnrpc.PaymentHash{
RHash: invoiceResp.RHash, RHash: invoiceResp.RHash,
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
dbInvoice, err := net.Bob.LookupInvoice(ctxt, payHash) dbInvoice, err := net.Bob.LookupInvoice(ctxt, payHash)
if err != nil { if err != nil {
t.Fatalf("unable to lookup invoice: %v", err) t.Fatalf("unable to lookup invoice: %v", err)

View file

@ -118,8 +118,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
Index: chanPoint.OutputIndex, Index: chanPoint.OutputIndex,
} }
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = node.WaitForNetworkChannelOpen(chanPoint)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+ t.Fatalf("%s(%d): timeout waiting for "+
"channel(%s) open: %v", nodeNames[i], "channel(%s) open: %v", nodeNames[i],
@ -141,13 +140,11 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
// We'll wait for all parties to recognize the new channels within the // We'll wait for all parties to recognize the new channels within the
// network. // network.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = dave.WaitForNetworkChannelOpen(chanPointDave)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
if err != nil { if err != nil {
t.Fatalf("dave didn't advertise his channel: %v", err) t.Fatalf("dave didn't advertise his channel: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPointCarol)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
if err != nil { if err != nil {
t.Fatalf("carol didn't advertise her channel in time: %v", t.Fatalf("carol didn't advertise her channel in time: %v",
err) err)
@ -251,7 +248,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
Memo: "testing", Memo: "testing",
Value: paymentAmt, Value: paymentAmt,
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
resp, err := carol.AddInvoice(ctxt, finalInvoice) resp, err := carol.AddInvoice(ctxt, finalInvoice)
if err != nil { if err != nil {
t.Fatalf("unable to add invoice: %v", err) t.Fatalf("unable to add invoice: %v", err)
@ -396,8 +393,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
Index: chanPoint.OutputIndex, Index: chanPoint.OutputIndex,
} }
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = node.WaitForNetworkChannelOpen(chanPoint)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+ t.Fatalf("%s(%d): timeout waiting for "+
"channel(%s) open: %v", nodeNames[i], "channel(%s) open: %v", nodeNames[i],
@ -419,23 +415,19 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
// We'll wait for all parties to recognize the new channels within the // We'll wait for all parties to recognize the new channels within the
// network. // network.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = dave.WaitForNetworkChannelOpen(chanPointDave)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
if err != nil { if err != nil {
t.Fatalf("dave didn't advertise his channel: %v", err) t.Fatalf("dave didn't advertise his channel: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPointCarol)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
if err != nil { if err != nil {
t.Fatalf("carol didn't advertise her channel in time: %v", t.Fatalf("carol didn't advertise her channel in time: %v",
err) err)
} }
// Make sure all nodes are fully synced before we continue. // Make sure all nodes are fully synced before we continue.
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel()
for _, node := range nodes { for _, node := range nodes {
err := node.WaitForBlockchainSync(ctxt) err := node.WaitForBlockchainSync()
if err != nil { if err != nil {
t.Fatalf("unable to wait for sync: %v", err) t.Fatalf("unable to wait for sync: %v", err)
} }
@ -503,10 +495,8 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
} }
// Make sure all nodes are fully synced again. // Make sure all nodes are fully synced again.
ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout)
defer cancel()
for _, node := range nodes { for _, node := range nodes {
err := node.WaitForBlockchainSync(ctxt) err := node.WaitForBlockchainSync()
if err != nil { if err != nil {
t.Fatalf("unable to wait for sync: %v", err) t.Fatalf("unable to wait for sync: %v", err)
} }
@ -555,7 +545,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
Memo: "testing", Memo: "testing",
Value: paymentAmt, Value: paymentAmt,
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
resp, err := carol.AddInvoice(ctxt, finalInvoice) resp, err := carol.AddInvoice(ctxt, finalInvoice)
if err != nil { if err != nil {
t.Fatalf("unable to add invoice: %v", err) t.Fatalf("unable to add invoice: %v", err)
@ -702,8 +692,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
Index: chanPoint.OutputIndex, Index: chanPoint.OutputIndex,
} }
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = node.WaitForNetworkChannelOpen(chanPoint)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+ t.Fatalf("%s(%d): timeout waiting for "+
"channel(%s) open: %v", nodeNames[i], "channel(%s) open: %v", nodeNames[i],
@ -725,13 +714,11 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
// We'll wait for all parties to recognize the new channels within the // We'll wait for all parties to recognize the new channels within the
// network. // network.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = dave.WaitForNetworkChannelOpen(chanPointDave)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
if err != nil { if err != nil {
t.Fatalf("dave didn't advertise his channel: %v", err) t.Fatalf("dave didn't advertise his channel: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPointCarol)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
if err != nil { if err != nil {
t.Fatalf("carol didn't advertise her channel in time: %v", t.Fatalf("carol didn't advertise her channel in time: %v",
err) err)
@ -842,7 +829,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
Memo: "testing", Memo: "testing",
Value: paymentAmt, Value: paymentAmt,
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
resp, err := carol.AddInvoice(ctxt, finalInvoice) resp, err := carol.AddInvoice(ctxt, finalInvoice)
if err != nil { if err != nil {
t.Fatalf("unable to add invoice: %v", err) t.Fatalf("unable to add invoice: %v", err)
@ -896,7 +883,6 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
// 5. Carol <-- Dave <-- Alice X expect settle to propagate // 5. Carol <-- Dave <-- Alice X expect settle to propagate
func testSwitchOfflineDeliveryOutgoingOffline( func testSwitchOfflineDeliveryOutgoingOffline(
net *lntest.NetworkHarness, t *harnessTest) { net *lntest.NetworkHarness, t *harnessTest) {
ctxb := context.Background()
const chanAmt = btcutil.Amount(1000000) const chanAmt = btcutil.Amount(1000000)
const pushAmt = btcutil.Amount(900000) const pushAmt = btcutil.Amount(900000)
@ -991,8 +977,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(
Index: chanPoint.OutputIndex, Index: chanPoint.OutputIndex,
} }
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = node.WaitForNetworkChannelOpen(chanPoint)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+ t.Fatalf("%s(%d): timeout waiting for "+
"channel(%s) open: %v", nodeNames[i], "channel(%s) open: %v", nodeNames[i],
@ -1014,13 +999,11 @@ func testSwitchOfflineDeliveryOutgoingOffline(
// We'll wait for all parties to recognize the new channels within the // We'll wait for all parties to recognize the new channels within the
// network. // network.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err = dave.WaitForNetworkChannelOpen(chanPointDave)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
if err != nil { if err != nil {
t.Fatalf("dave didn't advertise his channel: %v", err) t.Fatalf("dave didn't advertise his channel: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) err = carol.WaitForNetworkChannelOpen(chanPointCarol)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
if err != nil { if err != nil {
t.Fatalf("carol didn't advertise her channel in time: %v", t.Fatalf("carol didn't advertise her channel in time: %v",
err) err)

View file

@ -496,11 +496,9 @@ func fundChanAndCloseFromImportedAccount(t *harnessTest, srcNode, destNode,
}, },
OutputIndex: upd.ChanPending.OutputIndex, OutputIndex: upd.ChanPending.OutputIndex,
} }
ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout) err = srcNode.WaitForNetworkChannelOpen(chanPoint)
defer cancel()
err = srcNode.WaitForNetworkChannelOpen(ctxt, chanPoint)
require.NoError(t.t, err) require.NoError(t.t, err)
err = destNode.WaitForNetworkChannelOpen(ctxt, chanPoint) err = destNode.WaitForNetworkChannelOpen(chanPoint)
require.NoError(t.t, err) require.NoError(t.t, err)
// Send a test payment to ensure the channel is operating as normal. // Send a test payment to ensure the channel is operating as normal.

View file

@ -924,13 +924,13 @@ func (hn *HarnessNode) initClientWhenReady(timeout time.Duration) error {
// Init initializes a harness node by passing the init request via rpc. After // Init initializes a harness node by passing the init request via rpc. After
// the request is submitted, this method will block until a // the request is submitted, this method will block until a
// macaroon-authenticated RPC connection can be established to the harness node. // macaroon-authenticated RPC connection can be established to the harness
// Once established, the new connection is used to initialize the // node. Once established, the new connection is used to initialize the
// LightningClient and subscribes the HarnessNode to topology changes. // LightningClient and subscribes the HarnessNode to topology changes.
func (hn *HarnessNode) Init(ctx context.Context, func (hn *HarnessNode) Init(
initReq *lnrpc.InitWalletRequest) (*lnrpc.InitWalletResponse, error) { initReq *lnrpc.InitWalletRequest) (*lnrpc.InitWalletResponse, error) {
ctxt, cancel := context.WithTimeout(ctx, DefaultTimeout) ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
defer cancel() defer cancel()
response, err := hn.InitWallet(ctxt, initReq) response, err := hn.InitWallet(ctxt, initReq)
if err != nil { if err != nil {
@ -969,11 +969,11 @@ func (hn *HarnessNode) Init(ctx context.Context,
// a macaroon-authenticated RPC connection can be established to the harness // a macaroon-authenticated RPC connection can be established to the harness
// node. Once established, the new connection is used to initialize the // node. Once established, the new connection is used to initialize the
// LightningClient and subscribes the HarnessNode to topology changes. // LightningClient and subscribes the HarnessNode to topology changes.
func (hn *HarnessNode) InitChangePassword(ctx context.Context, func (hn *HarnessNode) InitChangePassword(
chngPwReq *lnrpc.ChangePasswordRequest) (*lnrpc.ChangePasswordResponse, chngPwReq *lnrpc.ChangePasswordRequest) (*lnrpc.ChangePasswordResponse,
error) { error) {
ctxt, cancel := context.WithTimeout(ctx, DefaultTimeout) ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
defer cancel() defer cancel()
response, err := hn.ChangePassword(ctxt, chngPwReq) response, err := hn.ChangePassword(ctxt, chngPwReq)
if err != nil { if err != nil {
@ -1011,10 +1011,9 @@ func (hn *HarnessNode) InitChangePassword(ctx context.Context,
// should be called after the restart of a HarnessNode that was created with a // should be called after the restart of a HarnessNode that was created with a
// seed+password. Once this method returns, the HarnessNode will be ready to // seed+password. Once this method returns, the HarnessNode will be ready to
// accept normal gRPC requests and harness command. // accept normal gRPC requests and harness command.
func (hn *HarnessNode) Unlock(ctx context.Context, func (hn *HarnessNode) Unlock(unlockReq *lnrpc.UnlockWalletRequest) error {
unlockReq *lnrpc.UnlockWalletRequest) error { ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
defer cancel()
ctxt, _ := context.WithTimeout(ctx, DefaultTimeout)
// Otherwise, we'll need to unlock the node before it's able to start // Otherwise, we'll need to unlock the node before it's able to start
// up properly. // up properly.
@ -1404,12 +1403,12 @@ func getChanPointFundingTxid(chanPoint *lnrpc.ChannelPoint) ([]byte, error) {
return txid, nil return txid, nil
} }
func checkChanPointInGraph(ctx context.Context, func (hn *HarnessNode) checkChanPointInGraph(chanPoint wire.OutPoint) bool {
node *HarnessNode, chanPoint wire.OutPoint) bool {
ctxt, cancel := context.WithTimeout(ctx, DefaultTimeout) ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
defer cancel() defer cancel()
chanGraph, err := node.DescribeGraph(ctxt, &lnrpc.ChannelGraphRequest{})
chanGraph, err := hn.DescribeGraph(ctxt, &lnrpc.ChannelGraphRequest{})
if err != nil { if err != nil {
return false return false
} }
@ -1484,9 +1483,12 @@ func (hn *HarnessNode) lightningNetworkWatcher() {
// outpoint is seen as being fully advertised within the network. A channel is // outpoint is seen as being fully advertised within the network. A channel is
// considered "fully advertised" once both of its directional edges has been // considered "fully advertised" once both of its directional edges has been
// advertised within the test Lightning Network. // advertised within the test Lightning Network.
func (hn *HarnessNode) WaitForNetworkChannelOpen(ctx context.Context, func (hn *HarnessNode) WaitForNetworkChannelOpen(
chanPoint *lnrpc.ChannelPoint) error { chanPoint *lnrpc.ChannelPoint) error {
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
defer cancel()
eventChan := make(chan struct{}) eventChan := make(chan struct{})
op, err := MakeOutpoint(chanPoint) op, err := MakeOutpoint(chanPoint)
@ -1504,7 +1506,7 @@ func (hn *HarnessNode) WaitForNetworkChannelOpen(ctx context.Context,
select { select {
case <-eventChan: case <-eventChan:
return nil return nil
case <-ctx.Done(): case <-ctxt.Done():
return fmt.Errorf("channel:%s not opened before timeout: %s", return fmt.Errorf("channel:%s not opened before timeout: %s",
op, hn) op, hn)
} }
@ -1514,9 +1516,12 @@ func (hn *HarnessNode) WaitForNetworkChannelOpen(ctx context.Context,
// outpoint is seen as closed within the network. A channel is considered // outpoint is seen as closed within the network. A channel is considered
// closed once a transaction spending the funding outpoint is seen within a // closed once a transaction spending the funding outpoint is seen within a
// confirmed block. // confirmed block.
func (hn *HarnessNode) WaitForNetworkChannelClose(ctx context.Context, func (hn *HarnessNode) WaitForNetworkChannelClose(
chanPoint *lnrpc.ChannelPoint) error { chanPoint *lnrpc.ChannelPoint) error {
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
defer cancel()
eventChan := make(chan struct{}) eventChan := make(chan struct{})
op, err := MakeOutpoint(chanPoint) op, err := MakeOutpoint(chanPoint)
@ -1534,7 +1539,7 @@ func (hn *HarnessNode) WaitForNetworkChannelClose(ctx context.Context,
select { select {
case <-eventChan: case <-eventChan:
return nil return nil
case <-ctx.Done(): case <-ctxt.Done():
return fmt.Errorf("channel:%s not closed before timeout: "+ return fmt.Errorf("channel:%s not closed before timeout: "+
"%s", op, hn) "%s", op, hn)
} }
@ -1542,10 +1547,13 @@ func (hn *HarnessNode) WaitForNetworkChannelClose(ctx context.Context,
// WaitForChannelPolicyUpdate will block until a channel policy with the target // WaitForChannelPolicyUpdate will block until a channel policy with the target
// outpoint and advertisingNode is seen within the network. // outpoint and advertisingNode is seen within the network.
func (hn *HarnessNode) WaitForChannelPolicyUpdate(ctx context.Context, func (hn *HarnessNode) WaitForChannelPolicyUpdate(
advertisingNode string, policy *lnrpc.RoutingPolicy, advertisingNode string, policy *lnrpc.RoutingPolicy,
chanPoint *lnrpc.ChannelPoint, includeUnannounced bool) error { chanPoint *lnrpc.ChannelPoint, includeUnannounced bool) error {
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
defer cancel()
eventChan := make(chan struct{}) eventChan := make(chan struct{})
op, err := MakeOutpoint(chanPoint) op, err := MakeOutpoint(chanPoint)
@ -1582,7 +1590,7 @@ func (hn *HarnessNode) WaitForChannelPolicyUpdate(ctx context.Context,
case <-eventChan: case <-eventChan:
return nil return nil
case <-ctx.Done(): case <-ctxt.Done():
return fmt.Errorf("channel:%s policy not updated "+ return fmt.Errorf("channel:%s policy not updated "+
"before timeout: [%s:%v] %s", op, "before timeout: [%s:%v] %s", op,
advertisingNode, policy, hn.String()) advertisingNode, policy, hn.String())
@ -1594,12 +1602,15 @@ func (hn *HarnessNode) WaitForChannelPolicyUpdate(ctx context.Context,
// the blockchain. If the passed context object has a set timeout, it will // the blockchain. If the passed context object has a set timeout, it will
// continually poll until the timeout has elapsed. In the case that the chain // continually poll until the timeout has elapsed. In the case that the chain
// isn't synced before the timeout is up, this function will return an error. // isn't synced before the timeout is up, this function will return an error.
func (hn *HarnessNode) WaitForBlockchainSync(ctx context.Context) error { func (hn *HarnessNode) WaitForBlockchainSync() error {
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
defer cancel()
ticker := time.NewTicker(time.Millisecond * 100) ticker := time.NewTicker(time.Millisecond * 100)
defer ticker.Stop() defer ticker.Stop()
for { for {
resp, err := hn.GetInfo(ctx, &lnrpc.GetInfoRequest{}) resp, err := hn.GetInfo(ctxt, &lnrpc.GetInfoRequest{})
if err != nil { if err != nil {
return err return err
} }
@ -1608,7 +1619,7 @@ func (hn *HarnessNode) WaitForBlockchainSync(ctx context.Context) error {
} }
select { select {
case <-ctx.Done(): case <-ctxt.Done():
return fmt.Errorf("timeout while waiting for " + return fmt.Errorf("timeout while waiting for " +
"blockchain sync") "blockchain sync")
case <-hn.runCtx.Done(): case <-hn.runCtx.Done():
@ -1740,7 +1751,7 @@ func (hn *HarnessNode) handleOpenChannelWatchRequest(req *chanWatchRequest) {
// node. This lets us handle the case where a node has already seen a // node. This lets us handle the case where a node has already seen a
// channel before a notification has been requested, causing us to miss // channel before a notification has been requested, causing us to miss
// it. // it.
chanFound := checkChanPointInGraph(hn.runCtx, hn, targetChan) chanFound := hn.checkChanPointInGraph(targetChan)
if chanFound { if chanFound {
close(req.eventChan) close(req.eventChan)
return return