diff --git a/lntest/harness.go b/lntest/harness.go index 68ce2f83e..c43a9357d 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -178,7 +178,7 @@ func (n *NetworkHarness) SetUp(t *testing.T, // both nodes are fully started since the Connect RPC is guarded behind // the server.Started() flag that waits for all subsystems to be ready. ctxb := context.Background() - n.ConnectNodes(ctxb, t, n.Alice, n.Bob) + n.ConnectNodes(t, n.Alice, n.Bob) // Load up the wallets of the seeder nodes with 10 outputs of 1 BTC // each. @@ -670,8 +670,10 @@ func (n *NetworkHarness) EnsureConnected(ctx context.Context, // // NOTE: This function may block for up to 15-seconds as it will not return // until the new connection is detected as being known to both nodes. -func (n *NetworkHarness) ConnectNodes(ctx context.Context, t *testing.T, - a, b *HarnessNode) { +func (n *NetworkHarness) ConnectNodes(t *testing.T, a, b *HarnessNode) { + ctxb := context.Background() + ctx, cancel := context.WithTimeout(ctxb, DefaultTimeout) + defer cancel() bobInfo, err := b.GetInfo(ctx, &lnrpc.GetInfoRequest{}) require.NoErrorf( diff --git a/lntest/itest/lnd_channel_backup_test.go b/lntest/itest/lnd_channel_backup_test.go index 14dea02ac..c44206aab 100644 --- a/lntest/itest/lnd_channel_backup_test.go +++ b/lntest/itest/lnd_channel_backup_test.go @@ -505,8 +505,7 @@ func testChannelBackupUpdates(net *lntest.NetworkHarness, t *harnessTest) { // With Carol up, we'll now connect her to Alice, and open a channel // between them. - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, net.Alice) + net.ConnectNodes(t.t, carol, net.Alice) // Next, we'll open two channels between Alice and Carol back to back. var chanPoints []*lnrpc.ChannelPoint @@ -641,8 +640,7 @@ func testExportChannelBackup(net *lntest.NetworkHarness, t *harnessTest) { // With Carol up, we'll now connect her to Alice, and open a channel // between them. - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, net.Alice) + net.ConnectNodes(t.t, carol, net.Alice) // Next, we'll open two channels between Alice and Carol back to back. var chanPoints []*lnrpc.ChannelPoint @@ -899,7 +897,7 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness, // Next, we'll connect Dave to Carol, and open a new channel to her // with a portion pushed. - net.ConnectNodes(ctxt, t.t, dave, carol) + net.ConnectNodes(t.t, dave, carol) // We will either open a confirmed or unconfirmed channel, depending on // the requirements of the test case. diff --git a/lntest/itest/lnd_channel_balance_test.go b/lntest/itest/lnd_channel_balance_test.go index 4c88dad57..db531179a 100644 --- a/lntest/itest/lnd_channel_balance_test.go +++ b/lntest/itest/lnd_channel_balance_test.go @@ -144,8 +144,7 @@ func testChannelUnsettledBalance(net *lntest.NetworkHarness, t *harnessTest) { defer shutdownAndAssert(net, t, carol) // Connect Alice to Carol. - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxb, t.t, net.Alice, carol) + net.ConnectNodes(t.t, net.Alice, carol) // Open a channel between Alice and Carol. chanPointAlice := openChannelAndAssert( @@ -157,7 +156,7 @@ func testChannelUnsettledBalance(net *lntest.NetworkHarness, t *harnessTest) { // Wait for Alice and Carol to receive the channel edge from the // funding manager. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice) if err != nil { t.Fatalf("alice didn't see the alice->carol channel before "+ diff --git a/lntest/itest/lnd_channel_force_close.go b/lntest/itest/lnd_channel_force_close.go index 65b8c7150..7bc2468c3 100644 --- a/lntest/itest/lnd_channel_force_close.go +++ b/lntest/itest/lnd_channel_force_close.go @@ -105,7 +105,7 @@ func testCommitmentTransactionDeadline(net *lntest.NetworkHarness, defer shutdownAndAssert(net, t, bob) // Connect Alice to Bob. - net.ConnectNodes(ctxt, t.t, alice, bob) + net.ConnectNodes(t.t, alice, bob) // Open a channel between Alice and Bob. chanPoint := openChannelAndAssert( @@ -317,10 +317,10 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest, // We must let Alice have an open channel before she can send a node // announcement, so we open a channel with Carol, - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, alice, carol) + net.ConnectNodes(t.t, alice, carol) // We need one additional UTXO for sweeping the remote anchor. + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, alice) // Before we start, obtain Carol's current wallet balance, we'll check @@ -1418,8 +1418,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) { defer shutdownAndAssert(net, t, carol) // Let Alice connect and open a channel to Carol, - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, net.Alice, carol) + net.ConnectNodes(t.t, net.Alice, carol) chanPoint := openChannelAndAssert( t, net, net.Alice, carol, lntest.OpenChannelParams{ @@ -1435,7 +1434,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) { RPreimage: preimage, Value: paymentAmt, } - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) resp, err := carol.AddInvoice(ctxt, invoice) if err != nil { t.Fatalf("unable to add invoice: %v", err) diff --git a/lntest/itest/lnd_channel_graph_test.go b/lntest/itest/lnd_channel_graph_test.go index 858aad262..2ae39ebe5 100644 --- a/lntest/itest/lnd_channel_graph_test.go +++ b/lntest/itest/lnd_channel_graph_test.go @@ -45,7 +45,7 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) { defer shutdownAndAssert(net, t, bob) // Connect Alice to Bob. - net.ConnectNodes(ctxb, t.t, alice, bob) + net.ConnectNodes(t.t, alice, bob) // Give Alice some coins so she can fund a channel. ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) @@ -83,11 +83,8 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) { carol := net.NewNode(t.t, "Carol", nil) defer shutdownAndAssert(net, t, carol) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, alice, carol) - - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, bob, carol) + net.ConnectNodes(t.t, alice, carol) + net.ConnectNodes(t.t, bob, carol) carolSub := subscribeGraphNotifications(ctxb, t, carol) defer close(carolSub.quit) @@ -601,8 +598,7 @@ out: carol := net.NewNode(t.t, "Carol", nil) defer shutdownAndAssert(net, t, carol) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, bob, carol) + net.ConnectNodes(t.t, bob, carol) chanPoint = openChannelAndAssert( t, net, bob, carol, lntest.OpenChannelParams{ @@ -699,8 +695,7 @@ func testNodeAnnouncement(net *lntest.NetworkHarness, t *harnessTest) { // We must let Dave have an open channel before he can send a node // announcement, so we open a channel with Bob, - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, net.Bob, dave) + net.ConnectNodes(t.t, net.Bob, dave) // Alice shouldn't receive any new updates yet since the channel has yet // to be opened. diff --git a/lntest/itest/lnd_channel_policy_test.go b/lntest/itest/lnd_channel_policy_test.go index e0f7a5f29..c146d69b0 100644 --- a/lntest/itest/lnd_channel_policy_test.go +++ b/lntest/itest/lnd_channel_policy_test.go @@ -112,7 +112,7 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol) - net.ConnectNodes(ctxb, t.t, carol, net.Bob) + net.ConnectNodes(t.t, carol, net.Bob) // Open the channel Carol->Bob with a custom min_htlc value set. Since // Carol is opening the channel, she will require Bob to not forward @@ -388,7 +388,7 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) { } // We'll now open a channel from Alice directly to Carol. - net.ConnectNodes(ctxb, t.t, net.Alice, carol) + net.ConnectNodes(t.t, net.Alice, carol) chanPoint3 := openChannelAndAssert( t, net, net.Alice, carol, lntest.OpenChannelParams{ diff --git a/lntest/itest/lnd_etcd_failover_test.go b/lntest/itest/lnd_etcd_failover_test.go index 21542aad8..7dac42f2c 100644 --- a/lntest/itest/lnd_etcd_failover_test.go +++ b/lntest/itest/lnd_etcd_failover_test.go @@ -100,8 +100,7 @@ func testEtcdFailoverCase(net *lntest.NetworkHarness, ht *harnessTest, ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) info1, err := carol1.GetInfo(ctxt, &lnrpc.GetInfoRequest{}) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, ht.t, carol1, net.Alice) + net.ConnectNodes(ht.t, carol1, net.Alice) // Open a channel with 100k satoshis between Carol and Alice with Alice // being the sole funder of the channel. diff --git a/lntest/itest/lnd_funding_test.go b/lntest/itest/lnd_funding_test.go index 38512947f..b6b0bfa1e 100644 --- a/lntest/itest/lnd_funding_test.go +++ b/lntest/itest/lnd_funding_test.go @@ -292,9 +292,7 @@ func testUnconfirmedChannelFunding(net *lntest.NetworkHarness, t *harnessTest) { // Now, we'll connect her to Alice so that they can open a channel // together. The funding flow should select Carol's unconfirmed output // as she doesn't have any other funds since it's a new node. - - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, net.Alice) + net.ConnectNodes(t.t, carol, net.Alice) chanOpenUpdate := openChannelStream( ctxt, t, net, carol, net.Alice, @@ -521,12 +519,11 @@ func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) { // Clean up carol's node when the test finishes. defer shutdownAndAssert(net, t, carol) - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, net.Alice, carol) + net.ConnectNodes(t.t, net.Alice, carol) // Create a new channel that requires 5 confs before it's considered // open, then broadcast the funding transaction - ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) + ctxt, _ := context.WithTimeout(ctxb, channelOpenTimeout) pendingUpdate, err := net.OpenPendingChannel(ctxt, net.Alice, carol, chanAmt, pushAmt) if err != nil { diff --git a/lntest/itest/lnd_hold_persistence_test.go b/lntest/itest/lnd_hold_persistence_test.go index cc6c9c415..4c065cc7e 100644 --- a/lntest/itest/lnd_hold_persistence_test.go +++ b/lntest/itest/lnd_hold_persistence_test.go @@ -34,8 +34,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) { defer shutdownAndAssert(net, t, carol) // Connect Alice to Carol. - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxb, t.t, net.Alice, carol) + net.ConnectNodes(t.t, net.Alice, carol) // Open a channel between Alice and Carol which is private so that we // cover the addition of hop hints for hold invoices. @@ -49,7 +48,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) { // Wait for Alice and Carol to receive the channel edge from the // funding manager. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice) if err != nil { t.Fatalf("alice didn't see the alice->carol channel before "+ diff --git a/lntest/itest/lnd_misc_test.go b/lntest/itest/lnd_misc_test.go index aeca05041..5bb5f8ace 100644 --- a/lntest/itest/lnd_misc_test.go +++ b/lntest/itest/lnd_misc_test.go @@ -47,14 +47,13 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) { defer shutdownAndAssert(net, t, bob) // Start by connecting Alice and Bob with no channels. - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, alice, bob) + net.ConnectNodes(t.t, alice, bob) // Check existing connection. assertNumConnections(t, alice, bob, 1) // Give Alice some coins so she can fund a channel. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, alice) chanAmt := funding.MaxBtcFundingAmount @@ -109,8 +108,7 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) { assertNumOpenChannelsPending(ctxt, t, alice, bob, 0) // Reconnect the nodes so that the channel can become active. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, alice, bob) + net.ConnectNodes(t.t, alice, bob) // The channel should be listed in the peer information returned by both // peers. @@ -140,8 +138,7 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) { assertNumConnections(t, alice, bob, 0) // Reconnect both nodes before force closing the channel. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, alice, bob) + net.ConnectNodes(t.t, alice, bob) // Finally, immediately close the channel. This function will also block // until the channel is closed and will additionally assert the relevant @@ -166,8 +163,7 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) { assertNumConnections(t, alice, bob, 0) // Finally, re-connect both nodes. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, alice, bob) + net.ConnectNodes(t.t, alice, bob) // Check existing connection. assertNumConnections(t, alice, net.Bob, 1) @@ -202,9 +198,8 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) { carol := net.NewNode(t.t, "Carol", []string{"--unsafe-replay"}) defer shutdownAndAssert(net, t, carol) + net.ConnectNodes(t.t, carol, dave) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, dave) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol) chanPoint := openChannelAndAssert( @@ -222,8 +217,7 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) { fred := net.NewNode(t.t, "Fred", nil) defer shutdownAndAssert(net, t, fred) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, fred, carol) + net.ConnectNodes(t.t, fred, carol) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, fred) @@ -379,7 +373,7 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) { defer shutdownAndAssert(net, t, bob) // Connect Alice to Bob. - net.ConnectNodes(ctxb, t.t, alice, bob) + net.ConnectNodes(t.t, alice, bob) // Give Alice some coins so she can fund a channel. ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) @@ -510,10 +504,9 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) { carol := net.NewNode(t.t, "Carol", args) defer shutdownAndAssert(net, t, carol) - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, net.Alice, carol) + net.ConnectNodes(t.t, net.Alice, carol) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) carolBalance := btcutil.Amount(maxPendingChannels) * amount net.SendCoins(ctxt, t.t, carolBalance, carol) @@ -624,8 +617,7 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) { // Create Carol's node and connect Alice to her. carol := net.NewNode(t.t, "Carol", nil) defer shutdownAndAssert(net, t, carol) - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, net.Alice, carol) + net.ConnectNodes(t.t, net.Alice, carol) // Open a channel between Alice and Carol which will later be force // closed. @@ -641,7 +633,7 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) { dave := net.NewNode(t.t, "Dave", nil) defer shutdownAndAssert(net, t, dave) - net.ConnectNodes(ctxt, t.t, net.Alice, dave) + net.ConnectNodes(t.t, net.Alice, dave) persistentChanPoint := openChannelAndAssert( t, net, net.Alice, dave, lntest.OpenChannelParams{ Amt: chanAmt, @@ -652,7 +644,7 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) { // Alice. isConnected := func(pubKey string) bool { req := &lnrpc.ListPeersRequest{} - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) resp, err := net.Alice.ListPeers(ctxt, req) if err != nil { t.Fatalf("unable to retrieve alice's peers: %v", err) @@ -774,7 +766,7 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) { var predErr error pendingChansRequest := &lnrpc.PendingChannelsRequest{} err = wait.Predicate(func() bool { - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) pendingChanResp, err := net.Alice.PendingChannels( ctxt, pendingChansRequest, ) @@ -815,7 +807,7 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) { describeGraphReq := &lnrpc.ChannelGraphRequest{ IncludeUnannounced: true, } - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) channelGraph, err := net.Alice.DescribeGraph(ctxt, describeGraphReq) if err != nil { t.Fatalf("unable to query for alice's channel graph: %v", err) @@ -1155,10 +1147,10 @@ func testRejectHTLC(net *lntest.NetworkHarness, t *harnessTest) { defer shutdownAndAssert(net, t, carol) // Connect Alice to Carol. - net.ConnectNodes(ctxb, t.t, net.Alice, carol) + net.ConnectNodes(t.t, net.Alice, carol) // Connect Carol to Bob. - net.ConnectNodes(ctxb, t.t, carol, net.Bob) + net.ConnectNodes(t.t, carol, net.Bob) // Send coins to Carol. net.SendCoins(ctxb, t.t, btcutil.SatoshiPerBitcoin, carol) @@ -1390,8 +1382,7 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) { }) defer shutdownAndAssert(net, t, carol) - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, net.Alice, carol) + net.ConnectNodes(t.t, net.Alice, carol) chanPointAliceCarol := openChannelAndAssert( t, net, net.Alice, carol, lntest.OpenChannelParams{ @@ -1412,14 +1403,12 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) { defer shutdownAndAssert(net, t, eve) // Give Eve some coins. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, eve) // Connect Eve to Carol and Bob, and open a channel to carol. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, eve, carol) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, eve, net.Bob) + net.ConnectNodes(t.t, eve, carol) + net.ConnectNodes(t.t, eve, net.Bob) chanPointEveCarol := openChannelAndAssert( t, net, eve, carol, @@ -1434,8 +1423,7 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) { dave := net.NewNode(t.t, "Dave", nil) defer shutdownAndAssert(net, t, dave) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, net.Bob, dave) + net.ConnectNodes(t.t, net.Bob, dave) daveSub := subscribeGraphNotifications(ctxb, t, dave) defer close(daveSub.quit) diff --git a/lntest/itest/lnd_multi-hop-error-propagation_test.go b/lntest/itest/lnd_multi-hop-error-propagation_test.go index d893b128d..1f1168826 100644 --- a/lntest/itest/lnd_multi-hop-error-propagation_test.go +++ b/lntest/itest/lnd_multi-hop-error-propagation_test.go @@ -93,8 +93,7 @@ func testHtlcErrorPropagation(net *lntest.NetworkHarness, t *harnessTest) { // channel between them so we have the topology: Alice -> Bob -> Carol. // The channel created will be of lower capacity that the one created // above. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, net.Bob, carol) + net.ConnectNodes(t.t, net.Bob, carol) const bobChanAmt = funding.MaxBtcFundingAmount chanPointBob := openChannelAndAssert( t, net, net.Bob, carol, diff --git a/lntest/itest/lnd_multi-hop-payments_test.go b/lntest/itest/lnd_multi-hop-payments_test.go index 59e96fb8d..afecadab4 100644 --- a/lntest/itest/lnd_multi-hop-payments_test.go +++ b/lntest/itest/lnd_multi-hop-payments_test.go @@ -49,9 +49,8 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) { dave := net.NewNode(t.t, "Dave", daveArgs) defer shutdownAndAssert(net, t, dave) + net.ConnectNodes(t.t, dave, net.Alice) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, dave, net.Alice) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave) chanPointDave := openChannelAndAssert( @@ -75,8 +74,7 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) { carol := net.NewNode(t.t, "Carol", nil) defer shutdownAndAssert(net, t, carol) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, dave) + net.ConnectNodes(t.t, carol, dave) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol) diff --git a/lntest/itest/lnd_multi-hop_test.go b/lntest/itest/lnd_multi-hop_test.go index 34db606d0..d49a86602 100644 --- a/lntest/itest/lnd_multi-hop_test.go +++ b/lntest/itest/lnd_multi-hop_test.go @@ -87,9 +87,7 @@ func testMultiHopHtlcClaims(net *lntest.NetworkHarness, t *harnessTest) { bob := net.NewNode(t, "Bob", args) defer shutdownAndAssert(net, ht, bob) - ctxb := context.Background() - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t, alice, bob) + net.ConnectNodes(t, alice, bob) for _, subTest := range subTests { subTest := subTest @@ -251,8 +249,7 @@ func createThreeHopNetwork(t *harnessTest, net *lntest.NetworkHarness, } carol := net.NewNode(t.t, "Carol", carolFlags) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, bob, carol) + net.ConnectNodes(t.t, bob, carol) // Make sure Carol has enough utxos for anchoring. Because the anchor by // itself often doesn't meet the dust limit, a utxo from the wallet diff --git a/lntest/itest/lnd_onchain_test.go b/lntest/itest/lnd_onchain_test.go index 7bace73d0..33bb07236 100644 --- a/lntest/itest/lnd_onchain_test.go +++ b/lntest/itest/lnd_onchain_test.go @@ -176,8 +176,7 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) { defer shutdownAndAssert(net, t, bob) ctxb := context.Background() - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, alice, bob) + net.ConnectNodes(t.t, alice, bob) // Send just enough coins for Alice to open a channel without a change // output. @@ -186,7 +185,7 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) { feeEst = 8000 ) - ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout) + ctxt, _ := context.WithTimeout(context.Background(), defaultTimeout) net.SendCoins(ctxt, t.t, chanAmt+feeEst, alice) // wallet, without a change output. This should not be allowed. diff --git a/lntest/itest/lnd_revocation_test.go b/lntest/itest/lnd_revocation_test.go index ea2375811..1da9d9978 100644 --- a/lntest/itest/lnd_revocation_test.go +++ b/lntest/itest/lnd_revocation_test.go @@ -44,12 +44,11 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) { // We must let Bob communicate with Carol before they are able to open // channel, so we connect Bob and Carol, - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, net.Bob) + net.ConnectNodes(t.t, carol, net.Bob) // Before we make a channel, we'll load up Carol with some coins sent // directly from the miner. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol) // In order to test Carol's response to an uncooperative channel @@ -301,12 +300,11 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness // We must let Dave have an open channel before she can send a node // announcement, so we open a channel with Carol, - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, dave, carol) + net.ConnectNodes(t.t, dave, carol) // Before we make a channel, we'll load up Dave with some coins sent // directly from the miner. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave) // In order to test Dave's response to an uncooperative channel @@ -533,12 +531,11 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness, // We must let Dave communicate with Carol before they are able to open // channel, so we connect Dave and Carol, - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, dave, carol) + net.ConnectNodes(t.t, dave, carol) // Before we make a channel, we'll load up Dave with some coins sent // directly from the miner. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave) // In order to test Dave's response to an uncooperative channel closure @@ -1029,7 +1026,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase( // We must let Dave have an open channel before she can send a node // announcement, so we open a channel with Carol, - net.ConnectNodes(ctxb, t.t, dave, carol) + net.ConnectNodes(t.t, dave, carol) // Before we make a channel, we'll load up Dave with some coins sent // directly from the miner. diff --git a/lntest/itest/lnd_routing_test.go b/lntest/itest/lnd_routing_test.go index df94f50a1..317bac137 100644 --- a/lntest/itest/lnd_routing_test.go +++ b/lntest/itest/lnd_routing_test.go @@ -103,9 +103,8 @@ func testSingleHopSendToRouteCase(net *lntest.NetworkHarness, t *harnessTest, dave := net.NewNode(t.t, "Dave", nil) defer shutdownAndAssert(net, t, dave) + net.ConnectNodes(t.t, carol, dave) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, dave) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol) // Open a channel with 100k satoshis between Carol and Dave with Carol @@ -467,9 +466,8 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) { carol := net.NewNode(t.t, "Carol", nil) defer shutdownAndAssert(net, t, carol) + net.ConnectNodes(t.t, carol, net.Bob) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, net.Bob) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, net.Bob) chanPointBob := openChannelAndAssert( @@ -647,8 +645,7 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, charlie) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, charlie) + net.ConnectNodes(t.t, carol, charlie) chanPointCarol := openChannelAndAssert( t, net, carol, charlie, @@ -761,9 +758,8 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) { dave := net.NewNode(t.t, "Dave", nil) defer shutdownAndAssert(net, t, dave) + net.ConnectNodes(t.t, dave, net.Alice) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, dave, net.Alice) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave) chanPointDave := openChannelAndAssert( @@ -787,8 +783,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) { carol := net.NewNode(t.t, "Carol", nil) defer shutdownAndAssert(net, t, carol) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, dave) + net.ConnectNodes(t.t, carol, dave) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol) @@ -835,8 +830,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) { } // Now create a _private_ channel directly between Carol and // Alice of 100k. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, net.Alice) + net.ConnectNodes(t.t, carol, net.Alice) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) chanOpenUpdate := openChannelStream( ctxt, t, net, carol, net.Alice, @@ -1079,8 +1073,7 @@ func testUpdateChannelPolicyForPrivateChannel(net *lntest.NetworkHarness, defer shutdownAndAssert(net, t, carol) // Connect Carol to Bob. - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, net.Bob) + net.ConnectNodes(t.t, carol, net.Bob) // Open a channel with 100k satoshis between Bob and Carol. chanPointBobCarol := openChannelAndAssert( @@ -1110,7 +1103,7 @@ func testUpdateChannelPolicyForPrivateChannel(net *lntest.NetworkHarness, Value: paymentAmt, Private: true, } - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) resp, err := carol.AddInvoice(ctxt, invoice) require.NoError(t.t, err, "unable to create invoice for carol") @@ -1210,8 +1203,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) { carol := net.NewNode(t.t, "Carol", nil) defer shutdownAndAssert(net, t, carol) - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, net.Alice, carol) + net.ConnectNodes(t.t, net.Alice, carol) chanPointCarol := openChannelAndAssert( t, net, net.Alice, carol, lntest.OpenChannelParams{ @@ -1225,8 +1217,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) { // we should only include routing hints for nodes that are publicly // advertised, otherwise we'd end up leaking information about nodes // that wish to stay unadvertised. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, net.Bob, carol) + net.ConnectNodes(t.t, net.Bob, carol) chanPointBobCarol := openChannelAndAssert( t, net, net.Bob, carol, lntest.OpenChannelParams{ @@ -1242,8 +1233,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) { dave := net.NewNode(t.t, "Dave", nil) defer shutdownAndAssert(net, t, dave) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, net.Alice, dave) + net.ConnectNodes(t.t, net.Alice, dave) chanPointDave := openChannelAndAssert( t, net, net.Alice, dave, lntest.OpenChannelParams{ @@ -1257,8 +1247,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) { // channel has been created to avoid populating routing hints for // inactive channels. eve := net.NewNode(t.t, "Eve", nil) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, net.Alice, eve) + net.ConnectNodes(t.t, net.Alice, eve) chanPointEve := openChannelAndAssert( t, net, net.Alice, eve, lntest.OpenChannelParams{ @@ -1301,7 +1290,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) { var predErr error var decoded *lnrpc.PayReq err := wait.Predicate(func() bool { - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) resp, err := net.Alice.AddInvoice(ctxt, invoice) if err != nil { predErr = fmt.Errorf("unable to add invoice: %v", err) @@ -1341,7 +1330,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) { // We'll need the short channel ID of the channel between Alice and Bob // to make sure the routing hint is for this channel. listReq := &lnrpc.ListChannelsRequest{} - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) listResp, err := net.Alice.ListChannels(ctxt, listReq) if err != nil { t.Fatalf("unable to retrieve alice's channels: %v", err) @@ -1427,8 +1416,7 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) carol := net.NewNode(t.t, "Carol", nil) defer shutdownAndAssert(net, t, carol) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, net.Bob, carol) + net.ConnectNodes(t.t, net.Bob, carol) chanPointBob := openChannelAndAssert( t, net, net.Bob, carol, lntest.OpenChannelParams{ @@ -1470,8 +1458,7 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) dave := net.NewNode(t.t, "Dave", nil) defer shutdownAndAssert(net, t, dave) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, dave) + net.ConnectNodes(t.t, carol, dave) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol) @@ -1606,9 +1593,8 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) { carol := net.NewNode(t.t, "Carol", nil) defer shutdownAndAssert(net, t, carol) + net.ConnectNodes(t.t, carol, net.Bob) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, net.Bob) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, net.Bob) chanPointBob := openChannelAndAssert( @@ -1623,8 +1609,7 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) { dave := net.NewNode(t.t, "Dave", nil) defer shutdownAndAssert(net, t, dave) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, dave, carol) + net.ConnectNodes(t.t, dave, carol) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol) @@ -1895,9 +1880,8 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) { carol := net.NewNode(t.t, "Carol", nil) defer shutdownAndAssert(net, t, carol) + net.ConnectNodes(t.t, carol, net.Alice) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, net.Alice) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol) chanPointAliceCarol := openChannelAndAssert( @@ -1912,8 +1896,7 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) { dave := net.NewNode(t.t, "Dave", nil) defer shutdownAndAssert(net, t, dave) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, dave, net.Bob) + net.ConnectNodes(t.t, dave, net.Bob) chanPointBobDave := openChannelAndAssert( t, net, net.Bob, dave, lntest.OpenChannelParams{ @@ -1922,8 +1905,7 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) { ) // Open a channel between Carol and Dave. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, dave) + net.ConnectNodes(t.t, carol, dave) chanPointCarolDave := openChannelAndAssert( t, net, carol, dave, lntest.OpenChannelParams{ diff --git a/lntest/itest/lnd_switch_test.go b/lntest/itest/lnd_switch_test.go index a7e556dca..279f4493d 100644 --- a/lntest/itest/lnd_switch_test.go +++ b/lntest/itest/lnd_switch_test.go @@ -57,9 +57,8 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) { dave := net.NewNode(t.t, "Dave", nil) defer shutdownAndAssert(net, t, dave) + net.ConnectNodes(t.t, dave, net.Alice) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, dave, net.Alice) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave) chanPointDave := openChannelAndAssert( @@ -85,8 +84,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) { carol := net.NewNode(t.t, "Carol", []string{"--hodl.exit-settle"}) defer shutdownAndAssert(net, t, carol) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, dave) + net.ConnectNodes(t.t, carol, dave) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol) @@ -345,9 +343,8 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) { dave := net.NewNode(t.t, "Dave", nil) defer shutdownAndAssert(net, t, dave) + net.ConnectNodes(t.t, dave, net.Alice) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, dave, net.Alice) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave) chanPointDave := openChannelAndAssert( @@ -373,8 +370,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) { carol := net.NewNode(t.t, "Carol", []string{"--hodl.exit-settle"}) defer shutdownAndAssert(net, t, carol) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, dave) + net.ConnectNodes(t.t, carol, dave) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol) @@ -482,8 +478,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) { } // Then, reconnect them to ensure Dave doesn't just fail back the htlc. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, dave, net.Alice) + net.ConnectNodes(t.t, dave, net.Alice) // Wait to ensure that the payment remain are not failed back after // reconnecting. All node should report the number payments initiated @@ -660,9 +655,8 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness dave := net.NewNode(t.t, "Dave", nil) defer shutdownAndAssert(net, t, dave) + net.ConnectNodes(t.t, dave, net.Alice) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, dave, net.Alice) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave) chanPointDave := openChannelAndAssert( @@ -689,8 +683,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness carol := net.NewNode(t.t, "Carol", []string{"--hodl.exit-settle"}) defer shutdownAndAssert(net, t, carol) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, dave) + net.ConnectNodes(t.t, carol, dave) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol) @@ -961,9 +954,8 @@ func testSwitchOfflineDeliveryOutgoingOffline( dave := net.NewNode(t.t, "Dave", nil) defer shutdownAndAssert(net, t, dave) + net.ConnectNodes(t.t, dave, net.Alice) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, dave, net.Alice) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave) chanPointDave := openChannelAndAssert( @@ -987,8 +979,7 @@ func testSwitchOfflineDeliveryOutgoingOffline( // Dave. Carol is started in htlchodl mode so that we can disconnect the // intermediary hops before starting the settle. carol := net.NewNode(t.t, "Carol", []string{"--hodl.exit-settle"}) - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - net.ConnectNodes(ctxt, t.t, carol, dave) + net.ConnectNodes(t.t, carol, dave) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)