mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 01:36:24 +01:00
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:
parent
6f59f41e86
commit
26ed64fa52
30 changed files with 186 additions and 309 deletions
|
@ -218,12 +218,10 @@ func (n *NetworkHarness) SetUp(t *testing.T,
|
|||
}
|
||||
|
||||
// Now we want to wait for the nodes to catch up.
|
||||
ctxt, cancel := context.WithTimeout(ctxb, DefaultTimeout)
|
||||
defer cancel()
|
||||
if err := n.Alice.WaitForBlockchainSync(ctxt); err != nil {
|
||||
if err := n.Alice.WaitForBlockchainSync(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := n.Bob.WaitForBlockchainSync(ctxt); err != nil {
|
||||
if err := n.Bob.WaitForBlockchainSync(); err != nil {
|
||||
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
|
||||
// also initialize the macaroon-authenticated LightningClient.
|
||||
response, err := node.Init(ctxb, initReq)
|
||||
response, err := node.Init(initReq)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
@ -429,8 +427,6 @@ func (n *NetworkHarness) NewNodeRemoteSigner(name string, extraArgs []string,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
ctxb := context.Background()
|
||||
|
||||
// With the seed created, construct the init request to the node,
|
||||
// including the newly generated seed.
|
||||
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
|
||||
// also initialize the macaroon-authenticated LightningClient.
|
||||
_, err = node.Init(ctxb, initReq)
|
||||
_, err = node.Init(initReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -478,7 +474,7 @@ func (n *NetworkHarness) RestoreNodeWithSeed(name string, extraArgs []string,
|
|||
ChannelBackups: chanBackups,
|
||||
}
|
||||
|
||||
_, err = node.Init(context.Background(), initReq)
|
||||
_, err = node.Init(initReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -828,15 +824,13 @@ func (n *NetworkHarness) RestartNode(node *HarnessNode, callback func() error,
|
|||
unlockReq.RecoveryWindow = 1000
|
||||
}
|
||||
|
||||
if err := node.Unlock(context.Background(), unlockReq); err != nil {
|
||||
if err := node.Unlock(unlockReq); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Give the node some time to catch up with the chain before we continue
|
||||
// with the tests.
|
||||
ctxc, done := context.WithTimeout(context.Background(), DefaultTimeout)
|
||||
defer done()
|
||||
return node.WaitForBlockchainSync(ctxc)
|
||||
// Give the node some time to catch up with the chain before we
|
||||
// continue with the tests.
|
||||
return node.WaitForBlockchainSync()
|
||||
}
|
||||
|
||||
// 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
|
||||
// prevents any funding workflows from being kicked off if the chain
|
||||
// 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)
|
||||
}
|
||||
if err := destNode.WaitForBlockchainSync(ctx); err != nil {
|
||||
if err := destNode.WaitForBlockchainSync(); err != nil {
|
||||
return nil, fmt.Errorf("unable to sync destNode chain: %v", err)
|
||||
}
|
||||
|
||||
|
@ -1133,10 +1127,10 @@ func (n *NetworkHarness) OpenPendingChannel(srcNode, destNode *HarnessNode,
|
|||
defer cancel()
|
||||
|
||||
// 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)
|
||||
}
|
||||
if err := destNode.WaitForBlockchainSync(ctx); err != nil {
|
||||
if err := destNode.WaitForBlockchainSync(); err != nil {
|
||||
return nil, fmt.Errorf("unable to sync destNode chain: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -1783,13 +1783,9 @@ func assertChannelPolicyUpdate(t *testing.T, node *lntest.HarnessNode,
|
|||
advertisingNode string, policy *lnrpc.RoutingPolicy,
|
||||
chanPoint *lnrpc.ChannelPoint, includeUnannounced bool) {
|
||||
|
||||
ctxb := context.Background()
|
||||
ctxt, cancel := context.WithTimeout(ctxb, lntest.DefaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
require.NoError(
|
||||
t, node.WaitForChannelPolicyUpdate(
|
||||
ctxt, advertisingNode, policy,
|
||||
advertisingNode, policy,
|
||||
chanPoint, includeUnannounced,
|
||||
), "error while waiting for channel update",
|
||||
)
|
||||
|
|
|
@ -245,11 +245,9 @@ func testSendPaymentAMPInvoiceRepeat(net *lntest.NetworkHarness,
|
|||
Amt: chanAmt,
|
||||
},
|
||||
)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPoint)
|
||||
require.NoError(t.t, err, "carol didn't report channel")
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = dave.WaitForNetworkChannelOpen(chanPoint)
|
||||
require.NoError(t.t, err, "dave didn't report channel")
|
||||
|
||||
// Create an AMP invoice of a trivial amount, that we'll pay repeatedly
|
||||
|
|
|
@ -982,12 +982,11 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
|
|||
)
|
||||
|
||||
// Wait for both sides to see the opened channel.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = dave.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("dave didn't report channel: %v", err)
|
||||
}
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
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)
|
||||
ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancel()
|
||||
err = from.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = from.WaitForNetworkChannelOpen(chanPoint)
|
||||
require.NoError(t.t, err)
|
||||
err = to.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = to.WaitForNetworkChannelOpen(chanPoint)
|
||||
require.NoError(t.t, err)
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@ import (
|
|||
// testChannelBalance creates a new channel between Alice and Bob, then checks
|
||||
// channel balance to be equal amount specified while creation of channel.
|
||||
func testChannelBalance(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
ctxb := context.Background()
|
||||
|
||||
// Open a channel with 0.16 BTC between Alice and Bob, ensuring the
|
||||
// channel has been opened properly.
|
||||
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.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't advertise channel before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("bob didn't advertise channel before "+
|
||||
"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
|
||||
// funding manager.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(chanPointAlice)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't see the alice->carol channel before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPointAlice)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't see the alice->carol channel before "+
|
||||
"timeout: %v", err)
|
||||
|
@ -191,7 +185,7 @@ func testChannelUnsettledBalance(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
errChan := make(chan error)
|
||||
for i := 0; i < numInvoices; i++ {
|
||||
go func() {
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
_, err := net.Alice.RouterClient.SendPaymentV2(ctxt,
|
||||
&routerrpc.SendPaymentRequest{
|
||||
Dest: carolPubKey,
|
||||
|
|
|
@ -335,13 +335,12 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
|
|||
|
||||
// Wait for Alice and Carol to receive the channel edge from the
|
||||
// funding manager.
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't see the alice->carol channel before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't see the alice->carol channel before "+
|
||||
"timeout: %v", err)
|
||||
|
@ -1430,8 +1429,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
carolPayReqs := []string{resp.PaymentRequest}
|
||||
|
||||
// Wait for Alice to receive the channel edge from the funding manager.
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't see the alice->carol channel before "+
|
||||
"timeout: %v", err)
|
||||
|
|
|
@ -58,12 +58,10 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
|
||||
// Wait for Alice and Bob to receive the channel edge from the
|
||||
// funding manager.
|
||||
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancel()
|
||||
err := alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err := alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
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")
|
||||
|
||||
// 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,
|
||||
policy *lnrpc.RoutingPolicy) {
|
||||
|
||||
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
require.NoError(
|
||||
t.t, carol.WaitForChannelPolicyUpdate(
|
||||
ctxt, node.PubKeyStr, policy, chanPoint, false,
|
||||
node.PubKeyStr, policy, chanPoint, false,
|
||||
), "error while waiting for channel update",
|
||||
)
|
||||
}
|
||||
|
|
|
@ -85,12 +85,11 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
)
|
||||
}
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't report channel: %v", err)
|
||||
}
|
||||
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
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(ctxt, chanPoint2)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(chanPoint2)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't report channel: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint2)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(chanPoint2)
|
||||
if err != nil {
|
||||
t.Fatalf("bob didn't report channel: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint2)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPoint2)
|
||||
if err != nil {
|
||||
t.Fatalf("carol didn't report channel: %v", err)
|
||||
}
|
||||
|
@ -187,7 +183,7 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
Memo: "testing",
|
||||
Value: int64(payAmt),
|
||||
}
|
||||
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)
|
||||
|
@ -387,13 +383,11 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
)
|
||||
defer closeChannelAndAssert(t, net, net.Alice, chanPoint3, false)
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint3)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(chanPoint3)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't report channel: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint3)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPoint3)
|
||||
if err != nil {
|
||||
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
|
||||
// closed.
|
||||
func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
ctxb := context.Background()
|
||||
|
||||
const (
|
||||
chanAmt = 100000
|
||||
)
|
||||
|
@ -588,12 +580,9 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
assertPolicyUpdate := func(node *lntest.HarnessNode,
|
||||
policy *lnrpc.RoutingPolicy, chanPoint *lnrpc.ChannelPoint) {
|
||||
|
||||
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
require.NoError(
|
||||
t.t, dave.WaitForChannelPolicyUpdate(
|
||||
ctxt, node.PubKeyStr, policy, chanPoint, false,
|
||||
node.PubKeyStr, policy, chanPoint, false,
|
||||
), "error while waiting for channel update",
|
||||
)
|
||||
}
|
||||
|
|
|
@ -161,8 +161,7 @@ func testEtcdFailoverCase(net *lntest.NetworkHarness, ht *harnessTest,
|
|||
|
||||
assertLeader(ht, observer, "Carol-2")
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol2.Unlock(ctxt, &lnrpc.UnlockWalletRequest{
|
||||
err = carol2.Unlock(&lnrpc.UnlockWalletRequest{
|
||||
WalletPassword: password,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -534,8 +534,6 @@ func (c *interceptorTestContext) closeChannels() {
|
|||
}
|
||||
|
||||
func (c *interceptorTestContext) waitForChannels() {
|
||||
ctxb := context.Background()
|
||||
|
||||
// Wait for all nodes to have seen all channels.
|
||||
for _, chanPoint := range c.networkChans {
|
||||
for _, node := range c.nodes {
|
||||
|
@ -547,8 +545,7 @@ func (c *interceptorTestContext) waitForChannels() {
|
|||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = node.WaitForNetworkChannelOpen(chanPoint)
|
||||
require.NoError(c.t.t, err, fmt.Sprintf("(%d): timeout "+
|
||||
"waiting for channel(%s) open", node.NodeID,
|
||||
point))
|
||||
|
|
|
@ -196,7 +196,6 @@ func basicChannelFundingTest(t *harnessTest, net *lntest.NetworkHarness,
|
|||
// open or an error occurs in the funding process. A series of
|
||||
// assertions will be executed to ensure the funding process completed
|
||||
// successfully.
|
||||
ctxb := context.Background()
|
||||
chanPoint := openChannelAndAssert(
|
||||
t, net, alice, bob,
|
||||
lntest.OpenChannelParams{
|
||||
|
@ -207,12 +206,10 @@ func basicChannelFundingTest(t *harnessTest, net *lntest.NetworkHarness,
|
|||
},
|
||||
)
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
|
||||
err := alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err := alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
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")
|
||||
|
||||
cType, err := channelCommitType(alice, chanPoint)
|
||||
|
@ -816,13 +813,11 @@ func testBatchChanFunding(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
|
||||
block := mineBlocks(t, net, 6, 1)[0]
|
||||
assertTxInBlock(t, block, txHash)
|
||||
ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancel()
|
||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint1)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(chanPoint1)
|
||||
require.NoError(t.t, err)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint2)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(chanPoint2)
|
||||
require.NoError(t.t, err)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint3)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(chanPoint3)
|
||||
require.NoError(t.t, err)
|
||||
|
||||
// With the channel open, ensure that it is counted towards Carol's
|
||||
|
|
|
@ -74,8 +74,8 @@ func testHoldInvoiceForceClose(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
require.Len(t.t, chans.Channels[0].PendingHtlcs, 1)
|
||||
activeHtlc := chans.Channels[0].PendingHtlcs[0]
|
||||
|
||||
require.NoError(t.t, net.Alice.WaitForBlockchainSync(ctxb))
|
||||
require.NoError(t.t, net.Bob.WaitForBlockchainSync(ctxb))
|
||||
require.NoError(t.t, net.Alice.WaitForBlockchainSync())
|
||||
require.NoError(t.t, net.Bob.WaitForBlockchainSync())
|
||||
|
||||
info, err := net.Alice.GetInfo(ctxb, &lnrpc.GetInfoRequest{})
|
||||
require.NoError(t.t, err)
|
||||
|
@ -99,8 +99,8 @@ func testHoldInvoiceForceClose(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
|
||||
mineBlocksSlow(t, net, blocksTillForce, 0)
|
||||
|
||||
require.NoError(t.t, net.Alice.WaitForBlockchainSync(ctxb))
|
||||
require.NoError(t.t, net.Bob.WaitForBlockchainSync(ctxb))
|
||||
require.NoError(t.t, net.Alice.WaitForBlockchainSync())
|
||||
require.NoError(t.t, net.Bob.WaitForBlockchainSync())
|
||||
|
||||
// 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
|
||||
|
|
|
@ -48,15 +48,13 @@ 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)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(chanPointAlice)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't see the alice->carol channel before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPointAlice)
|
||||
if err != nil {
|
||||
t.Fatalf("carol didn't see the carol->alice channel before "+
|
||||
"timeout: %v", err)
|
||||
|
@ -92,7 +90,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
Hash: payHash[:],
|
||||
Private: true,
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
resp, err := carol.AddHoldInvoice(ctxt, invoiceReq)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to add invoice: %v", err)
|
||||
|
@ -165,7 +163,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
req := &lnrpc.ListPaymentsRequest{
|
||||
IncludeIncomplete: true,
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
paymentsResp, err := net.Alice.ListPayments(ctxt, req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error when obtaining payments: %v",
|
||||
|
@ -299,7 +297,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
for i, preimage := range preimages {
|
||||
var expectedState lnrpc.Invoice_InvoiceState
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
if i%2 == 0 {
|
||||
settle := &invoicesrpc.SettleInvoiceMsg{
|
||||
Preimage: preimage[:],
|
||||
|
@ -368,7 +366,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
req := &lnrpc.ListPaymentsRequest{
|
||||
IncludeIncomplete: true,
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
paymentsResp, err := net.Alice.ListPayments(ctxt, req)
|
||||
if err != nil {
|
||||
t.Fatalf("error when obtaining Alice payments: %v", err)
|
||||
|
|
|
@ -665,8 +665,7 @@ func testStatelessInit(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
NewPassword: newPw,
|
||||
StatelessInit: true,
|
||||
}
|
||||
ctxb := context.Background()
|
||||
response, err := carol.InitChangePassword(ctxb, changePwReq)
|
||||
response, err := carol.InitChangePassword(changePwReq)
|
||||
require.NoError(t.t, err)
|
||||
|
||||
// Again, make sure no macaroon files have been created by the node
|
||||
|
|
|
@ -34,12 +34,10 @@ func testMaxHtlcPathfind(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
|
||||
// Wait for Alice and Bob to receive the channel edge from the
|
||||
// funding manager.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
require.NoError(t.t, err, "alice does not have open channel")
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(chanPoint)
|
||||
require.NoError(t.t, err, "bob does not have open channel")
|
||||
|
||||
// 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.
|
||||
// We've hit our max remote htlcs, so we expect this payment to spin
|
||||
// out dramatically with pathfinding.
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
payment, err := net.Bob.RouterClient.SendPaymentV2(
|
||||
ctxt, &routerrpc.SendPaymentRequest{
|
||||
Amt: 1000,
|
||||
|
|
|
@ -236,23 +236,22 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
}
|
||||
|
||||
// Wait for all channels to be recognized and advertized.
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't advertise channel before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = dave.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("bob didn't advertise channel before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointFC)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPointFC)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't advertise channel before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
err = fred.WaitForNetworkChannelOpen(ctxt, chanPointFC)
|
||||
err = fred.WaitForNetworkChannelOpen(chanPointFC)
|
||||
if err != nil {
|
||||
t.Fatalf("bob didn't advertise channel before "+
|
||||
"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
|
||||
// funding manager.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err := alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err := alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't see the alice->bob channel before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = bob.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = bob.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("bob didn't see the bob->alice channel before "+
|
||||
"timeout: %v", err)
|
||||
|
@ -407,8 +404,7 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
|
||||
// Get the ListChannel response from Alice.
|
||||
listReq := &lnrpc.ListChannelsRequest{}
|
||||
ctxb = context.Background()
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
resp, err := alice.ListChannels(ctxt, listReq)
|
||||
if err != nil {
|
||||
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
|
||||
// exists and works properly.
|
||||
func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
ctxb := context.Background()
|
||||
|
||||
maxPendingChannels := lncfg.DefaultMaxPendingChannels + 1
|
||||
amount := funding.MaxBtcFundingAmount
|
||||
|
||||
|
@ -557,8 +551,7 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
// Ensure that the funding transaction enters a block, and is
|
||||
// properly advertised by Alice.
|
||||
assertTxInBlock(t, block, fundingTxID)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, fundingChanPoint)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(fundingChanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("channel not seen on network before "+
|
||||
"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
|
||||
// manager.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("carol didn't see the carol->%s channel "+
|
||||
"before timeout: %v", node.Name(), err)
|
||||
|
@ -975,7 +967,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
}
|
||||
|
||||
balReq := &lnrpc.WalletBalanceRequest{}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
balResp, err := node.WalletBalance(ctxt, balReq)
|
||||
if err != nil {
|
||||
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)
|
||||
|
||||
// Wait for channel to be confirmed open.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
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")
|
||||
|
||||
// Now that the channel is open, we'll obtain its channel ID real quick
|
||||
// so we can use it to query the graph below.
|
||||
listReq := &lnrpc.ListChannelsRequest{}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
aliceChannelList, err := net.Alice.ListChannels(ctxt, listReq)
|
||||
require.NoError(t.t, err)
|
||||
var chanID uint64
|
||||
|
|
|
@ -319,8 +319,6 @@ func (c *mppTestContext) shutdownNodes() {
|
|||
}
|
||||
|
||||
func (c *mppTestContext) waitForChannels() {
|
||||
ctxb := context.Background()
|
||||
|
||||
// Wait for all nodes to have seen all channels.
|
||||
for _, chanPoint := range c.networkChans {
|
||||
for _, node := range c.nodes {
|
||||
|
@ -333,8 +331,7 @@ func (c *mppTestContext) waitForChannels() {
|
|||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = node.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
c.t.Fatalf("(%v:%d): timeout waiting for "+
|
||||
"channel(%s) open: %v",
|
||||
|
|
|
@ -29,8 +29,7 @@ func testHtlcErrorPropagation(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
Amt: chanAmt,
|
||||
},
|
||||
)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
if err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice); err != nil {
|
||||
if err := net.Alice.WaitForNetworkChannelOpen(chanPointAlice); err != nil {
|
||||
t.Fatalf("channel not seen by alice before timeout: %v", err)
|
||||
}
|
||||
|
||||
|
@ -115,7 +114,7 @@ out:
|
|||
for {
|
||||
select {
|
||||
case <-checkTableTicker.C:
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
_, err := net.Alice.GetNodeInfo(ctxt, nodeInfoReq)
|
||||
if err != nil && strings.Contains(err.Error(),
|
||||
"unable to find") {
|
||||
|
@ -138,7 +137,7 @@ out:
|
|||
Memo: "kek99",
|
||||
Value: payAmt,
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
carolInvoice, err := carol.AddInvoice(ctxt, invoiceReq)
|
||||
if err != nil {
|
||||
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
|
||||
// channel has been processed by Alice.
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
if err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointBob); err != nil {
|
||||
if err := net.Alice.WaitForNetworkChannelOpen(chanPointBob); err != nil {
|
||||
t.Fatalf("channel not seen by alice before timeout: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -107,8 +107,7 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = node.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d): timeout waiting for "+
|
||||
"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
|
||||
// network.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
|
||||
err = dave.WaitForNetworkChannelOpen(chanPointDave)
|
||||
if err != nil {
|
||||
t.Fatalf("dave didn't advertise his channel: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPointCarol)
|
||||
if err != nil {
|
||||
t.Fatalf("carol didn't advertise her channel in time: %v",
|
||||
err)
|
||||
|
|
|
@ -210,8 +210,6 @@ func createThreeHopNetwork(t *harnessTest, net *lntest.NetworkHarness,
|
|||
alice, bob *lntest.HarnessNode, carolHodl bool, c lnrpc.CommitmentType) (
|
||||
*lnrpc.ChannelPoint, *lnrpc.ChannelPoint, *lntest.HarnessNode) {
|
||||
|
||||
ctxb := context.Background()
|
||||
|
||||
net.EnsureConnected(t.t, alice, bob)
|
||||
|
||||
// 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(ctxt, aliceChanPoint)
|
||||
err := alice.WaitForNetworkChannelOpen(aliceChanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't report channel: %v", err)
|
||||
}
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = bob.WaitForNetworkChannelOpen(ctxt, aliceChanPoint)
|
||||
err = bob.WaitForNetworkChannelOpen(aliceChanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("bob didn't report channel: %v", err)
|
||||
}
|
||||
|
@ -289,18 +285,15 @@ func createThreeHopNetwork(t *harnessTest, net *lntest.NetworkHarness,
|
|||
FundingShim: bobFundingShim,
|
||||
},
|
||||
)
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = bob.WaitForNetworkChannelOpen(ctxt, bobChanPoint)
|
||||
err = bob.WaitForNetworkChannelOpen(bobChanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't report channel: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, bobChanPoint)
|
||||
err = carol.WaitForNetworkChannelOpen(bobChanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("bob didn't report channel: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = alice.WaitForNetworkChannelOpen(ctxt, bobChanPoint)
|
||||
err = alice.WaitForNetworkChannelOpen(bobChanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("bob didn't report channel: %v", err)
|
||||
}
|
||||
|
|
|
@ -237,12 +237,10 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
aliceChanPoint1, aliceChanPoint2, aliceChanPoint3,
|
||||
}
|
||||
for _, chanPoint := range chanPoints {
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
require.NoError(t.t, err)
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = bob.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = bob.WaitForNetworkChannelOpen(chanPoint)
|
||||
require.NoError(t.t, err)
|
||||
}
|
||||
|
||||
|
|
|
@ -142,14 +142,12 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
|
||||
// Wait for Alice and Bob to recognize and advertise the new channel
|
||||
// generated above.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't advertise channel before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("bob didn't advertise channel before "+
|
||||
"timeout: %v", err)
|
||||
|
@ -159,7 +157,7 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
req := &lnrpc.ChannelGraphRequest{
|
||||
IncludeUnannounced: true,
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
chanGraph, err := net.Alice.DescribeGraph(ctxt, req)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query for alice's routing table: %v", err)
|
||||
|
|
|
@ -69,12 +69,11 @@ func testListPayments(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
|
||||
// Wait for Alice to recognize and advertise the new channel generated
|
||||
// above.
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
if err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint); err != nil {
|
||||
if err = net.Alice.WaitForNetworkChannelOpen(chanPoint); err != nil {
|
||||
t.Fatalf("alice didn't advertise channel before "+
|
||||
"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 "+
|
||||
"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.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't see the alice->bob channel before "+
|
||||
"timeout: %v", err)
|
||||
|
@ -307,7 +305,7 @@ func runAsyncPayments(net *lntest.NetworkHarness, t *harnessTest, alice,
|
|||
for i := 0; i < numInvoices; i++ {
|
||||
payReq := bobPayReqs[i]
|
||||
go func() {
|
||||
ctxt, _ = context.WithTimeout(ctxb, lntest.AsyncBenchmarkTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, lntest.AsyncBenchmarkTimeout)
|
||||
stream, err := alice.RouterClient.SendPaymentV2(
|
||||
ctxt,
|
||||
&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.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
if err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint); err != nil {
|
||||
if err = net.Alice.WaitForNetworkChannelOpen(chanPoint); err != nil {
|
||||
t.Fatalf("alice didn't see the alice->bob channel before "+
|
||||
"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 "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
|
@ -478,7 +475,7 @@ func testBidirectionalAsyncPayments(net *lntest.NetworkHarness, t *harnessTest)
|
|||
// Reset mission control to prevent previous payment results from
|
||||
// interfering with this test. A new channel has been opened, but
|
||||
// mission control operates on node pairs.
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
_, err = net.Alice.RouterClient.ResetMissionControl(
|
||||
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
|
||||
// continuing the rest of the test.
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
// TODO(roasbeef): will need to make num blocks to advertise a
|
||||
// node param
|
||||
|
|
|
@ -215,11 +215,9 @@ func runPsbtChanFunding(net *lntest.NetworkHarness, t *harnessTest, carol,
|
|||
txHash := finalTx.TxHash()
|
||||
block := mineBlocks(t, net, 6, 1)[0]
|
||||
assertTxInBlock(t, block, &txHash)
|
||||
ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancel()
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPoint)
|
||||
require.NoError(t.t, err)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint2)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPoint2)
|
||||
require.NoError(t.t, err)
|
||||
|
||||
// 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.
|
||||
block := mineBlocks(t, net, 6, 1)[0]
|
||||
assertTxInBlock(t, block, &txHash)
|
||||
ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancel()
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPoint)
|
||||
require.NoError(t.t, err)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint2)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPoint2)
|
||||
require.NoError(t.t, err)
|
||||
|
||||
// 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
|
||||
// prevents any funding workflows from being kicked off if the chain
|
||||
// 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",
|
||||
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",
|
||||
err)
|
||||
}
|
||||
|
|
|
@ -24,8 +24,6 @@ import (
|
|||
// retribution in the event that she fails immediately after detecting Bob's
|
||||
// breach txn in the mempool.
|
||||
func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
ctxb := context.Background()
|
||||
|
||||
const (
|
||||
chanAmt = funding.MaxBtcFundingAmount
|
||||
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.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("carol didn't see the carol->bob channel before "+
|
||||
"timeout: %v", err)
|
||||
|
@ -260,7 +257,6 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
// commitment output has zero-value.
|
||||
func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness,
|
||||
t *harnessTest) {
|
||||
ctxb := context.Background()
|
||||
|
||||
const (
|
||||
chanAmt = funding.MaxBtcFundingAmount
|
||||
|
@ -312,8 +308,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
|
|||
}
|
||||
|
||||
// Wait for Dave to receive the channel edge from the funding manager.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = dave.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("dave didn't see the dave->carol channel before "+
|
||||
"timeout: %v", err)
|
||||
|
@ -475,7 +470,6 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
|
|||
// remote party breaches before settling extended HTLCs.
|
||||
func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
|
||||
t *harnessTest) {
|
||||
ctxb := context.Background()
|
||||
|
||||
const (
|
||||
chanAmt = funding.MaxBtcFundingAmount
|
||||
|
@ -559,8 +553,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
|
|||
}
|
||||
|
||||
// Wait for Dave to receive the channel edge from the funding manager.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = dave.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("dave didn't see the dave->carol channel before "+
|
||||
"timeout: %v", err)
|
||||
|
@ -1017,8 +1010,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(
|
|||
}
|
||||
|
||||
// Wait for Dave to receive the channel edge from the funding manager.
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = dave.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("dave didn't see the dave->carol channel before "+
|
||||
"timeout: %v", err)
|
||||
|
|
|
@ -138,8 +138,7 @@ func testSingleHopSendToRouteCase(net *lntest.NetworkHarness, t *harnessTest,
|
|||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = node.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d): timeout waiting for "+
|
||||
"channel(%s) open: %v", node.Name(),
|
||||
|
@ -527,8 +526,7 @@ func runMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest,
|
|||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = node.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d): timeout waiting for "+
|
||||
"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
|
||||
// network.
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointBob)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPointBob)
|
||||
if err != nil {
|
||||
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(ctxt, chanPointAlice)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(chanPointAlice)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't advertise her channel: %v", err)
|
||||
}
|
||||
|
@ -678,8 +674,7 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest)
|
|||
Amt: chanAmt,
|
||||
},
|
||||
)
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPointCarol)
|
||||
if err != nil {
|
||||
t.Fatalf("carol didn't advertise her channel: %v", err)
|
||||
}
|
||||
|
@ -690,7 +685,7 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest)
|
|||
PubKey: charlie.PubKeyStr,
|
||||
Amt: int64(1),
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
fakeRoute, err := carol.QueryRoutes(ctxt, fakeReq)
|
||||
if err != nil {
|
||||
t.Fatalf("unable get fake route: %v", err)
|
||||
|
@ -842,8 +837,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = node.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d): timeout waiting for "+
|
||||
"channel(%s) open: %v", nodeNames[i],
|
||||
|
@ -1142,8 +1136,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
chanPointEve,
|
||||
}
|
||||
for i, chanPoint := range aliceChans {
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("timed out waiting for channel open %s: %v",
|
||||
chanNames[i], err)
|
||||
|
@ -1263,14 +1256,12 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
|
|||
},
|
||||
)
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
|
||||
err := net.Alice.WaitForNetworkChannelOpen(chanPointAlice)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't see the channel alice <-> bob before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(chanPointAlice)
|
||||
if err != nil {
|
||||
t.Fatalf("bob didn't see the channel alice <-> bob before "+
|
||||
"timeout: %v", err)
|
||||
|
@ -1299,20 +1290,17 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
|
|||
},
|
||||
)
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPointBob)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(chanPointBob)
|
||||
if err != nil {
|
||||
t.Fatalf("bob didn't see the channel bob <-> carol before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointBob)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPointBob)
|
||||
if err != nil {
|
||||
t.Fatalf("carol didn't see the channel bob <-> carol before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointBob)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(chanPointBob)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't see the channel bob <-> carol before "+
|
||||
"timeout: %v", err)
|
||||
|
@ -1344,20 +1332,17 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
|
|||
},
|
||||
)
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPointCarol)
|
||||
if err != nil {
|
||||
t.Fatalf("carol didn't see the channel carol <-> dave before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
|
||||
err = dave.WaitForNetworkChannelOpen(chanPointCarol)
|
||||
if err != nil {
|
||||
t.Fatalf("dave didn't see the channel carol <-> dave before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointBob)
|
||||
err = dave.WaitForNetworkChannelOpen(chanPointBob)
|
||||
if err != nil {
|
||||
t.Fatalf("dave didn't see the channel bob <-> carol before "+
|
||||
"timeout: %v", err)
|
||||
|
@ -1387,7 +1372,7 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
|
|||
Private: true,
|
||||
}
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
resp, err := dave.AddInvoice(ctxt, invoice)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to add invoice for dave: %v", err)
|
||||
|
@ -1506,8 +1491,7 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = node.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d): timeout waiting for "+
|
||||
"channel(%s) open: %v", nodeNames[i],
|
||||
|
@ -1802,8 +1786,7 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = node.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d) timed out waiting for "+
|
||||
"channel(%s) open: %v", nodeNames[i],
|
||||
|
|
|
@ -48,13 +48,12 @@ func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
|
||||
// Wait for Alice to recognize and advertise the new channel generated
|
||||
// above.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = net.Alice.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("alice didn't advertise channel before "+
|
||||
"timeout: %v", err)
|
||||
}
|
||||
err = net.Bob.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = net.Bob.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("bob didn't advertise channel before "+
|
||||
"timeout: %v", err)
|
||||
|
@ -78,7 +77,7 @@ func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
payHash := &lnrpc.PaymentHash{
|
||||
RHash: invoiceResp.RHash,
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
dbInvoice, err := net.Bob.LookupInvoice(ctxt, payHash)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to lookup invoice: %v", err)
|
||||
|
|
|
@ -118,8 +118,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = node.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d): timeout waiting for "+
|
||||
"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
|
||||
// network.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
|
||||
err = dave.WaitForNetworkChannelOpen(chanPointDave)
|
||||
if err != nil {
|
||||
t.Fatalf("dave didn't advertise his channel: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPointCarol)
|
||||
if err != nil {
|
||||
t.Fatalf("carol didn't advertise her channel in time: %v",
|
||||
err)
|
||||
|
@ -251,7 +248,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
Memo: "testing",
|
||||
Value: paymentAmt,
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
resp, err := carol.AddInvoice(ctxt, finalInvoice)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to add invoice: %v", err)
|
||||
|
@ -396,8 +393,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = node.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d): timeout waiting for "+
|
||||
"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
|
||||
// network.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
|
||||
err = dave.WaitForNetworkChannelOpen(chanPointDave)
|
||||
if err != nil {
|
||||
t.Fatalf("dave didn't advertise his channel: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPointCarol)
|
||||
if err != nil {
|
||||
t.Fatalf("carol didn't advertise her channel in time: %v",
|
||||
err)
|
||||
}
|
||||
|
||||
// Make sure all nodes are fully synced before we continue.
|
||||
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancel()
|
||||
for _, node := range nodes {
|
||||
err := node.WaitForBlockchainSync(ctxt)
|
||||
err := node.WaitForBlockchainSync()
|
||||
if err != nil {
|
||||
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.
|
||||
ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancel()
|
||||
for _, node := range nodes {
|
||||
err := node.WaitForBlockchainSync(ctxt)
|
||||
err := node.WaitForBlockchainSync()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to wait for sync: %v", err)
|
||||
}
|
||||
|
@ -555,7 +545,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
|
|||
Memo: "testing",
|
||||
Value: paymentAmt,
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
resp, err := carol.AddInvoice(ctxt, finalInvoice)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to add invoice: %v", err)
|
||||
|
@ -702,8 +692,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
|
|||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = node.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d): timeout waiting for "+
|
||||
"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
|
||||
// network.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
|
||||
err = dave.WaitForNetworkChannelOpen(chanPointDave)
|
||||
if err != nil {
|
||||
t.Fatalf("dave didn't advertise his channel: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPointCarol)
|
||||
if err != nil {
|
||||
t.Fatalf("carol didn't advertise her channel in time: %v",
|
||||
err)
|
||||
|
@ -842,7 +829,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
|
|||
Memo: "testing",
|
||||
Value: paymentAmt,
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
resp, err := carol.AddInvoice(ctxt, finalInvoice)
|
||||
if err != nil {
|
||||
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
|
||||
func testSwitchOfflineDeliveryOutgoingOffline(
|
||||
net *lntest.NetworkHarness, t *harnessTest) {
|
||||
ctxb := context.Background()
|
||||
|
||||
const chanAmt = btcutil.Amount(1000000)
|
||||
const pushAmt = btcutil.Amount(900000)
|
||||
|
@ -991,8 +977,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(
|
|||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = node.WaitForNetworkChannelOpen(chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d): timeout waiting for "+
|
||||
"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
|
||||
// network.
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
|
||||
err = dave.WaitForNetworkChannelOpen(chanPointDave)
|
||||
if err != nil {
|
||||
t.Fatalf("dave didn't advertise his channel: %v", err)
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = carol.WaitForNetworkChannelOpen(ctxt, chanPointCarol)
|
||||
err = carol.WaitForNetworkChannelOpen(chanPointCarol)
|
||||
if err != nil {
|
||||
t.Fatalf("carol didn't advertise her channel in time: %v",
|
||||
err)
|
||||
|
|
|
@ -496,11 +496,9 @@ func fundChanAndCloseFromImportedAccount(t *harnessTest, srcNode, destNode,
|
|||
},
|
||||
OutputIndex: upd.ChanPending.OutputIndex,
|
||||
}
|
||||
ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancel()
|
||||
err = srcNode.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = srcNode.WaitForNetworkChannelOpen(chanPoint)
|
||||
require.NoError(t.t, err)
|
||||
err = destNode.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
err = destNode.WaitForNetworkChannelOpen(chanPoint)
|
||||
require.NoError(t.t, err)
|
||||
|
||||
// Send a test payment to ensure the channel is operating as normal.
|
||||
|
|
|
@ -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
|
||||
// the request is submitted, this method will block until a
|
||||
// macaroon-authenticated RPC connection can be established to the harness node.
|
||||
// Once established, the new connection is used to initialize the
|
||||
// macaroon-authenticated RPC connection can be established to the harness
|
||||
// node. Once established, the new connection is used to initialize the
|
||||
// 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) {
|
||||
|
||||
ctxt, cancel := context.WithTimeout(ctx, DefaultTimeout)
|
||||
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
|
||||
defer cancel()
|
||||
response, err := hn.InitWallet(ctxt, initReq)
|
||||
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
|
||||
// node. Once established, the new connection is used to initialize the
|
||||
// LightningClient and subscribes the HarnessNode to topology changes.
|
||||
func (hn *HarnessNode) InitChangePassword(ctx context.Context,
|
||||
func (hn *HarnessNode) InitChangePassword(
|
||||
chngPwReq *lnrpc.ChangePasswordRequest) (*lnrpc.ChangePasswordResponse,
|
||||
error) {
|
||||
|
||||
ctxt, cancel := context.WithTimeout(ctx, DefaultTimeout)
|
||||
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
|
||||
defer cancel()
|
||||
response, err := hn.ChangePassword(ctxt, chngPwReq)
|
||||
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
|
||||
// seed+password. Once this method returns, the HarnessNode will be ready to
|
||||
// accept normal gRPC requests and harness command.
|
||||
func (hn *HarnessNode) Unlock(ctx context.Context,
|
||||
unlockReq *lnrpc.UnlockWalletRequest) error {
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctx, DefaultTimeout)
|
||||
func (hn *HarnessNode) Unlock(unlockReq *lnrpc.UnlockWalletRequest) error {
|
||||
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
// Otherwise, we'll need to unlock the node before it's able to start
|
||||
// up properly.
|
||||
|
@ -1404,12 +1403,12 @@ func getChanPointFundingTxid(chanPoint *lnrpc.ChannelPoint) ([]byte, error) {
|
|||
return txid, nil
|
||||
}
|
||||
|
||||
func checkChanPointInGraph(ctx context.Context,
|
||||
node *HarnessNode, chanPoint wire.OutPoint) bool {
|
||||
func (hn *HarnessNode) checkChanPointInGraph(chanPoint wire.OutPoint) bool {
|
||||
|
||||
ctxt, cancel := context.WithTimeout(ctx, DefaultTimeout)
|
||||
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
|
||||
defer cancel()
|
||||
chanGraph, err := node.DescribeGraph(ctxt, &lnrpc.ChannelGraphRequest{})
|
||||
|
||||
chanGraph, err := hn.DescribeGraph(ctxt, &lnrpc.ChannelGraphRequest{})
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
@ -1484,9 +1483,12 @@ func (hn *HarnessNode) lightningNetworkWatcher() {
|
|||
// outpoint is seen as being fully advertised within the network. A channel is
|
||||
// considered "fully advertised" once both of its directional edges has been
|
||||
// advertised within the test Lightning Network.
|
||||
func (hn *HarnessNode) WaitForNetworkChannelOpen(ctx context.Context,
|
||||
func (hn *HarnessNode) WaitForNetworkChannelOpen(
|
||||
chanPoint *lnrpc.ChannelPoint) error {
|
||||
|
||||
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
eventChan := make(chan struct{})
|
||||
|
||||
op, err := MakeOutpoint(chanPoint)
|
||||
|
@ -1504,7 +1506,7 @@ func (hn *HarnessNode) WaitForNetworkChannelOpen(ctx context.Context,
|
|||
select {
|
||||
case <-eventChan:
|
||||
return nil
|
||||
case <-ctx.Done():
|
||||
case <-ctxt.Done():
|
||||
return fmt.Errorf("channel:%s not opened before timeout: %s",
|
||||
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
|
||||
// closed once a transaction spending the funding outpoint is seen within a
|
||||
// confirmed block.
|
||||
func (hn *HarnessNode) WaitForNetworkChannelClose(ctx context.Context,
|
||||
func (hn *HarnessNode) WaitForNetworkChannelClose(
|
||||
chanPoint *lnrpc.ChannelPoint) error {
|
||||
|
||||
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
eventChan := make(chan struct{})
|
||||
|
||||
op, err := MakeOutpoint(chanPoint)
|
||||
|
@ -1534,7 +1539,7 @@ func (hn *HarnessNode) WaitForNetworkChannelClose(ctx context.Context,
|
|||
select {
|
||||
case <-eventChan:
|
||||
return nil
|
||||
case <-ctx.Done():
|
||||
case <-ctxt.Done():
|
||||
return fmt.Errorf("channel:%s not closed before timeout: "+
|
||||
"%s", op, hn)
|
||||
}
|
||||
|
@ -1542,10 +1547,13 @@ func (hn *HarnessNode) WaitForNetworkChannelClose(ctx context.Context,
|
|||
|
||||
// WaitForChannelPolicyUpdate will block until a channel policy with the target
|
||||
// outpoint and advertisingNode is seen within the network.
|
||||
func (hn *HarnessNode) WaitForChannelPolicyUpdate(ctx context.Context,
|
||||
func (hn *HarnessNode) WaitForChannelPolicyUpdate(
|
||||
advertisingNode string, policy *lnrpc.RoutingPolicy,
|
||||
chanPoint *lnrpc.ChannelPoint, includeUnannounced bool) error {
|
||||
|
||||
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
eventChan := make(chan struct{})
|
||||
|
||||
op, err := MakeOutpoint(chanPoint)
|
||||
|
@ -1582,7 +1590,7 @@ func (hn *HarnessNode) WaitForChannelPolicyUpdate(ctx context.Context,
|
|||
case <-eventChan:
|
||||
return nil
|
||||
|
||||
case <-ctx.Done():
|
||||
case <-ctxt.Done():
|
||||
return fmt.Errorf("channel:%s policy not updated "+
|
||||
"before timeout: [%s:%v] %s", op,
|
||||
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
|
||||
// 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.
|
||||
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)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
resp, err := hn.GetInfo(ctx, &lnrpc.GetInfoRequest{})
|
||||
resp, err := hn.GetInfo(ctxt, &lnrpc.GetInfoRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1608,7 +1619,7 @@ func (hn *HarnessNode) WaitForBlockchainSync(ctx context.Context) error {
|
|||
}
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
case <-ctxt.Done():
|
||||
return fmt.Errorf("timeout while waiting for " +
|
||||
"blockchain sync")
|
||||
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
|
||||
// channel before a notification has been requested, causing us to miss
|
||||
// it.
|
||||
chanFound := checkChanPointInGraph(hn.runCtx, hn, targetChan)
|
||||
chanFound := hn.checkChanPointInGraph(targetChan)
|
||||
if chanFound {
|
||||
close(req.eventChan)
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue