mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-12 14:12:27 +02:00
itest: manage context inside SendCoins
This commit is contained in:
@ -104,8 +104,7 @@ func testSingleHopSendToRouteCase(net *lntest.NetworkHarness, t *harnessTest,
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
net.ConnectNodes(t.t, carol, dave)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
|
||||
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
|
||||
|
||||
// Open a channel with 100k satoshis between Carol and Dave with Carol
|
||||
// being the sole funder of the channel.
|
||||
@ -139,7 +138,7 @@ func testSingleHopSendToRouteCase(net *lntest.NetworkHarness, t *harnessTest,
|
||||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d): timeout waiting for "+
|
||||
@ -467,8 +466,7 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
net.ConnectNodes(t.t, carol, net.Bob)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, net.Bob)
|
||||
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, net.Bob)
|
||||
|
||||
chanPointBob := openChannelAndAssert(
|
||||
t, net, net.Bob, carol,
|
||||
@ -500,7 +498,7 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d): timeout waiting for "+
|
||||
@ -532,7 +530,7 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
Amt: paymentAmt,
|
||||
FinalCltvDelta: chainreg.DefaultBitcoinTimeLockDelta,
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
routes, err := net.Alice.QueryRoutes(ctxt, routesReq)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to get route: %v", err)
|
||||
@ -636,14 +634,12 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest)
|
||||
carol := net.NewNode(t.t, "Carol", nil)
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
|
||||
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
|
||||
|
||||
charlie := net.NewNode(t.t, "Charlie", nil)
|
||||
defer shutdownAndAssert(net, t, charlie)
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, charlie)
|
||||
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, charlie)
|
||||
|
||||
net.ConnectNodes(t.t, carol, charlie)
|
||||
|
||||
@ -759,8 +755,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
net.ConnectNodes(t.t, dave, net.Alice)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
|
||||
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, dave)
|
||||
|
||||
chanPointDave := openChannelAndAssert(
|
||||
t, net, dave, net.Alice,
|
||||
@ -784,8 +779,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
net.ConnectNodes(t.t, carol, dave)
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
|
||||
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
|
||||
|
||||
chanPointCarol := openChannelAndAssert(
|
||||
t, net, carol, dave,
|
||||
@ -819,7 +813,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d): timeout waiting for "+
|
||||
@ -831,7 +825,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
// Now create a _private_ channel directly between Carol and
|
||||
// Alice of 100k.
|
||||
net.ConnectNodes(t.t, carol, net.Alice)
|
||||
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, channelOpenTimeout)
|
||||
chanOpenUpdate := openChannelStream(
|
||||
ctxt, t, net, carol, net.Alice,
|
||||
lntest.OpenChannelParams{
|
||||
@ -1459,8 +1453,7 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
net.ConnectNodes(t.t, carol, dave)
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
|
||||
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
|
||||
|
||||
chanPointCarol := openChannelAndAssert(
|
||||
t, net, carol, dave,
|
||||
@ -1594,8 +1587,7 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
net.ConnectNodes(t.t, carol, net.Bob)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, net.Bob)
|
||||
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, net.Bob)
|
||||
|
||||
chanPointBob := openChannelAndAssert(
|
||||
t, net, net.Bob, carol,
|
||||
@ -1610,8 +1602,7 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
net.ConnectNodes(t.t, dave, carol)
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
|
||||
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
|
||||
|
||||
chanPointCarol := openChannelAndAssert(
|
||||
t, net, carol, dave,
|
||||
@ -1635,7 +1626,7 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
Index: chanPoint.OutputIndex,
|
||||
}
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||
if err != nil {
|
||||
t.Fatalf("%s(%d): timeout waiting for "+
|
||||
@ -1651,7 +1642,7 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
PubKey: dave.PubKeyStr,
|
||||
Amt: paymentAmt,
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
routesRes, err := net.Alice.QueryRoutes(ctxt, routesReq)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to get route: %v", err)
|
||||
@ -1881,8 +1872,7 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
net.ConnectNodes(t.t, carol, net.Alice)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
|
||||
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
|
||||
|
||||
chanPointAliceCarol := openChannelAndAssert(
|
||||
t, net, net.Alice, carol,
|
||||
@ -1969,7 +1959,7 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
ChanPoint: chanPointCarolDave,
|
||||
},
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||
if _, err := carol.UpdateChannelPolicy(ctxt, updateFeeReq); err != nil {
|
||||
t.Fatalf("unable to update chan policy: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user