itest: initialize context inside ConnectNodes

This commit is contained in:
yyforyongyu 2021-08-19 20:30:33 +08:00
parent dca20d80a7
commit 8de495b96b
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868
17 changed files with 94 additions and 155 deletions

View File

@ -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(

View File

@ -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.

View File

@ -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 "+

View File

@ -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)

View File

@ -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.

View File

@ -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{

View File

@ -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.

View File

@ -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 {

View File

@ -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 "+

View File

@ -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)

View File

@ -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,

View File

@ -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)

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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{

View File

@ -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)