Merge pull request #1344 from halseth/lndtest-defer-shutdown
integration tests: shut down nodes using defer
This commit is contained in:
commit
0d607f675f
289
lnd_test.go
289
lnd_test.go
@ -381,6 +381,15 @@ func assertNumConnections(ctxt context.Context, t *harnessTest,
|
||||
}
|
||||
}
|
||||
|
||||
// shutdownAndAssert shuts down the given node and asserts that no errors
|
||||
// occur.
|
||||
func shutdownAndAssert(net *lntest.NetworkHarness, t *harnessTest,
|
||||
node *lntest.HarnessNode) {
|
||||
if err := net.ShutdownNode(node); err != nil {
|
||||
t.Fatalf("unable to shutdown %v: %v", node.Name(), err)
|
||||
}
|
||||
}
|
||||
|
||||
// calcStaticFee calculates appropriate fees for commitment transactions. This
|
||||
// function provides a simple way to allow test balance assertions to take fee
|
||||
// calculations into account.
|
||||
@ -461,11 +470,7 @@ func testOnchainFundRecovery(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create node with seed; %v", err)
|
||||
}
|
||||
|
||||
err = net.ShutdownNode(carol)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
shutdownAndAssert(net, t, carol)
|
||||
|
||||
// Create a closure for testing the recovery of Carol's wallet. This
|
||||
// method takes the expected value of Carol's balance when using the
|
||||
@ -517,10 +522,7 @@ func testOnchainFundRecovery(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
|
||||
// Lastly, shutdown this Carol so we can move on to the next
|
||||
// restoration.
|
||||
err = net.ShutdownNode(node)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to shutdown node: %v", err)
|
||||
}
|
||||
shutdownAndAssert(net, t, node)
|
||||
}
|
||||
|
||||
// Create a closure-factory for building closures that can generate and
|
||||
@ -841,6 +843,10 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
|
||||
// Clean up carol's node when the test finishes.
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
carolUpdates, cQuit := subscribeGraphNotifications(t, ctxb, carol)
|
||||
defer close(cQuit)
|
||||
|
||||
@ -1017,11 +1023,6 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
closeChannelAndAssert(ctxt, t, net, net.Bob, chanPoint2, false)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPoint3, false)
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
|
||||
// Clean up carol's node.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testOpenChannelAfterReorg tests that in the case where we have an open
|
||||
@ -1368,6 +1369,10 @@ func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new node: %v", err)
|
||||
}
|
||||
|
||||
// Clean up carol's node when the test finishes.
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, timeout)
|
||||
if err := net.ConnectNodes(ctxt, net.Alice, carol); err != nil {
|
||||
t.Fatalf("unable to connect alice to carol: %v", err)
|
||||
@ -1474,11 +1479,6 @@ func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
}
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPoint, false)
|
||||
|
||||
// Clean up carol's node.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testChannelBalance creates a new channel between Alice and Bob, then
|
||||
@ -1698,6 +1698,7 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
// We must let Alice have an open channel before she can send a node
|
||||
// announcement, so we open a channel with Carol,
|
||||
@ -2282,6 +2283,11 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
|
||||
// We must remember to shutdown the nodes we created for the duration
|
||||
// of the tests, only leaving the two seed nodes (Alice and Bob) within
|
||||
// our test network.
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
// Next, we'll create Carol and establish a channel to from her to
|
||||
// Dave. Carol is started in both unsafe-replay and unsafe-disconnect,
|
||||
// which will cause her to replay any pending Adds held in memory upon
|
||||
@ -2290,6 +2296,8 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, carol, dave); err != nil {
|
||||
t.Fatalf("unable to connect carol to dave: %v", err)
|
||||
}
|
||||
@ -2426,16 +2434,6 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, carol, chanPoint, true)
|
||||
|
||||
// Finally, shutdown the nodes we created for the duration of the
|
||||
// tests, only leaving the two seed nodes (Alice and Bob) within our
|
||||
// test network.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
if err := net.ShutdownNode(dave); err != nil {
|
||||
t.Fatalf("unable to shutdown dave: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
@ -2813,6 +2811,8 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, dave, net.Alice); err != nil {
|
||||
t.Fatalf("unable to connect dave to alice: %v", err)
|
||||
}
|
||||
@ -2844,6 +2844,8 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, carol, dave); err != nil {
|
||||
t.Fatalf("unable to connect carol to dave: %v", err)
|
||||
}
|
||||
@ -3016,16 +3018,6 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
closeChannelAndAssert(ctxt, t, net, dave, chanPointDave, false)
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, carol, chanPointCarol, false)
|
||||
|
||||
// Finally, shutdown the nodes we created for the duration of the
|
||||
// tests, only leaving the two seed nodes (Alice and Bob) within our
|
||||
// test network.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
if err := net.ShutdownNode(dave); err != nil {
|
||||
t.Fatalf("unable to shutdown dave: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testSingleHopSendToRoute tests that payments are properly processed
|
||||
@ -3214,6 +3206,8 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, carol, net.Bob); err != nil {
|
||||
t.Fatalf("unable to connect carol to alice: %v", err)
|
||||
}
|
||||
@ -3364,13 +3358,6 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPointAlice, false)
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, carol, chanPointBob, false)
|
||||
|
||||
// Finally, shutdown the nodes we created for the duration of the tests,
|
||||
// only leaving the two seed nodes (Alice and Bob) within our test
|
||||
// network.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testSendToRouteErrorPropagation tests propagation of errors that occur
|
||||
@ -3401,6 +3388,8 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
err = net.SendCoins(ctxb, btcutil.SatoshiPerBitcoin, carol)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to send coins to carol: %v", err)
|
||||
@ -3410,6 +3399,8 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, charlie)
|
||||
|
||||
err = net.SendCoins(ctxb, btcutil.SatoshiPerBitcoin, charlie)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to send coins to charlie: %v", err)
|
||||
@ -3484,17 +3475,6 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPointAlice, false)
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, carol, chanPointCarol, false)
|
||||
|
||||
// Finally, shutdown the nodes we created to make fake route,
|
||||
// only leaving the two seed nodes (Alice and Bob) within our test
|
||||
// network.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
|
||||
if err := net.ShutdownNode(charlie); err != nil {
|
||||
t.Fatalf("unable to shutdown charlie: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testPrivateChannels tests that a private channel can be used for
|
||||
@ -3542,6 +3522,8 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, dave, net.Alice); err != nil {
|
||||
t.Fatalf("unable to connect dave to alice: %v", err)
|
||||
}
|
||||
@ -3573,6 +3555,8 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, carol, dave); err != nil {
|
||||
t.Fatalf("unable to connect carol to dave: %v", err)
|
||||
}
|
||||
@ -3826,16 +3810,6 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
closeChannelAndAssert(ctxt, t, net, carol, chanPointCarol, false)
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, carol, chanPointPrivate, false)
|
||||
|
||||
// Finally, shutdown the nodes we created for the duration of the tests,
|
||||
// only leaving the two seed nodes (Alice and Bob) within our test
|
||||
// network.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
if err := net.ShutdownNode(dave); err != nil {
|
||||
t.Fatalf("unable to shutdown dave: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testInvoiceRoutingHints tests that the routing hints for an invoice are
|
||||
@ -3865,6 +3839,8 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create carol's node: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, net.Alice, carol); err != nil {
|
||||
t.Fatalf("unable to connect alice to carol: %v", err)
|
||||
}
|
||||
@ -3881,6 +3857,8 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create dave's node: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, net.Alice, dave); err != nil {
|
||||
t.Fatalf("unable to connect alice to dave: %v", err)
|
||||
}
|
||||
@ -3920,9 +3898,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
}
|
||||
|
||||
// Now that the channels are open, we'll take down Eve's node.
|
||||
if err := net.ShutdownNode(eve); err != nil {
|
||||
t.Fatalf("unable to shutdown eve: %v", err)
|
||||
}
|
||||
shutdownAndAssert(net, t, eve)
|
||||
|
||||
// Create an invoice for Alice that will populate the routing hints.
|
||||
invoice := &lnrpc.Invoice{
|
||||
@ -4006,13 +3982,6 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
// is offline.
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPointEve, true)
|
||||
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol's node: %v", err)
|
||||
}
|
||||
if err := net.ShutdownNode(dave); err != nil {
|
||||
t.Fatalf("unable to shutdown dave's node: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testMultiHopOverPrivateChannels tests that private channels can be used as
|
||||
@ -4067,6 +4036,8 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create carol's node: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, net.Bob, carol); err != nil {
|
||||
t.Fatalf("unable to connect bob to carol: %v", err)
|
||||
}
|
||||
@ -4114,6 +4085,8 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create dave's node: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, carol, dave); err != nil {
|
||||
t.Fatalf("unable to connect carol to dave: %v", err)
|
||||
}
|
||||
@ -4223,13 +4196,6 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Bob, chanPointBob, false)
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, carol, chanPointCarol, false)
|
||||
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol's node: %v", err)
|
||||
}
|
||||
if err := net.ShutdownNode(dave); err != nil {
|
||||
t.Fatalf("unable to shutdown dave's node: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func testInvoiceSubscriptions(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
@ -4382,6 +4348,7 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
ctx, _ = context.WithTimeout(context.Background(), timeout)
|
||||
if err := net.ConnectNodes(ctx, net.Alice, carol); err != nil {
|
||||
@ -4474,13 +4441,6 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
ctxt, _ := context.WithTimeout(context.Background(), timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPoint, false)
|
||||
}
|
||||
|
||||
// Finally, shutdown the node we created for the duration of the tests,
|
||||
// only leaving the two seed nodes (Alice and Bob) within our test
|
||||
// network.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func copyFile(dest, src string) error {
|
||||
@ -4567,6 +4527,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
// Let Alice connect and open a channel to Carol,
|
||||
if err := net.ConnectNodes(ctxb, net.Alice, carol); err != nil {
|
||||
@ -4732,13 +4693,6 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("%v", predErr)
|
||||
}
|
||||
|
||||
// Finally, shutdown the node we created for the duration of the tests,
|
||||
// only leaving the two seed nodes (Alice and Bob) within our test
|
||||
// network.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testRevokedCloseRetribution tests that Alice is able carry out
|
||||
@ -5005,6 +4959,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
// We must let Alice have an open channel before she can send a node
|
||||
// announcement, so we open a channel with Carol,
|
||||
@ -5248,6 +5203,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
// We'll also create a new node Dave, who will have a channel with
|
||||
// Carol, and also use similar settings so we can broadcast a commit
|
||||
@ -5256,6 +5212,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new dave node: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
// We must let Dave communicate with Carol before they are able to open
|
||||
// channel, so we connect Dave and Carol,
|
||||
@ -5909,9 +5866,8 @@ out:
|
||||
// We'll attempt to complete the original invoice we created with Carol
|
||||
// above, but before we do so, Carol will go offline, resulting in a
|
||||
// failed payment.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
shutdownAndAssert(net, t, carol)
|
||||
|
||||
// TODO(roasbeef): mission control
|
||||
time.Sleep(time.Second * 5)
|
||||
|
||||
@ -6116,6 +6072,7 @@ func testGraphTopologyNotifications(net *lntest.NetworkHarness, t *harnessTest)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, net.Bob, carol); err != nil {
|
||||
t.Fatalf("unable to connect bob to carol: %v", err)
|
||||
@ -6183,11 +6140,6 @@ func testGraphTopologyNotifications(net *lntest.NetworkHarness, t *harnessTest)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Bob, chanPoint, false)
|
||||
|
||||
close(quit)
|
||||
|
||||
// Finally, shutdown carol as our test has concluded successfully.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testNodeAnnouncement ensures that when a node is started with one or more
|
||||
@ -6212,6 +6164,7 @@ func testNodeAnnouncement(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
// We must let Dave have an open channel before he can send a node
|
||||
// announcement, so we open a channel with Bob,
|
||||
@ -6271,10 +6224,6 @@ func testNodeAnnouncement(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
// Close the channel between Bob and Dave.
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Bob, chanPoint, false)
|
||||
|
||||
if err := net.ShutdownNode(dave); err != nil {
|
||||
t.Fatalf("unable to shutdown dave: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func testNodeSignVerify(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
@ -6319,6 +6268,7 @@ func testNodeSignVerify(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new node: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
carolMsg := []byte("carol msg")
|
||||
|
||||
@ -6343,11 +6293,6 @@ func testNodeSignVerify(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
t.Fatalf("carol's signature doesn't contain her pubkey")
|
||||
}
|
||||
|
||||
// Clean up carol's node.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
|
||||
// Close the channel between alice and bob.
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Alice, aliceBobCh, false)
|
||||
@ -6973,6 +6918,9 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
// self.
|
||||
aliceChanPoint, bobChanPoint, carol := createThreeHopHodlNetwork(t, net)
|
||||
|
||||
// Clean up carol's node when the test finishes.
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
time.Sleep(time.Second * 1)
|
||||
|
||||
// Now that our channels are set up, we'll send two HTLC's from Alice
|
||||
@ -7184,11 +7132,6 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
|
||||
ctxt, _ := context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Alice, aliceChanPoint, false)
|
||||
|
||||
// Clean up carol's node.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testMultiHopReceiverChainClaim tests that in the multi-hop setting, if the
|
||||
@ -7207,6 +7150,9 @@ func testMultiHopReceiverChainClaim(net *lntest.NetworkHarness, t *harnessTest)
|
||||
// self.
|
||||
aliceChanPoint, bobChanPoint, carol := createThreeHopHodlNetwork(t, net)
|
||||
|
||||
// Clean up carol's node when the test finishes.
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
// With the network active, we'll now add a new invoice at Carol's end.
|
||||
invoiceReq := &lnrpc.Invoice{
|
||||
Value: 100000,
|
||||
@ -7409,11 +7355,6 @@ func testMultiHopReceiverChainClaim(net *lntest.NetworkHarness, t *harnessTest)
|
||||
// carol to conclude the test.
|
||||
ctxt, _ := context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Alice, aliceChanPoint, false)
|
||||
|
||||
// Clean up carol's node.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testMultiHopLocalForceCloseOnChainHtlcTimeout tests that in a multi-hop HTLC
|
||||
@ -7432,6 +7373,9 @@ func testMultiHopLocalForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
|
||||
// self.
|
||||
aliceChanPoint, bobChanPoint, carol := createThreeHopHodlNetwork(t, net)
|
||||
|
||||
// Clean up carol's node when the test finishes.
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
// With our channels set up, we'll then send a single HTLC from Alice
|
||||
// to Carol. As Carol is in hodl mode, she won't settle this HTLC which
|
||||
// opens up the base for out tests.
|
||||
@ -7664,11 +7608,6 @@ func testMultiHopLocalForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
|
||||
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Alice, aliceChanPoint, false)
|
||||
|
||||
// Clean up carol's node.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testMultiHopRemoteForceCloseOnChainHtlcTimeout tests that if we extend a
|
||||
@ -7687,6 +7626,9 @@ func testMultiHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
|
||||
// self.
|
||||
aliceChanPoint, bobChanPoint, carol := createThreeHopHodlNetwork(t, net)
|
||||
|
||||
// Clean up carol's node when the test finishes.
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
// With our channels set up, we'll then send a single HTLC from Alice
|
||||
// to Carol. As Carol is in hodl mode, she won't settle this HTLC which
|
||||
// opens up the base for out tests.
|
||||
@ -7879,9 +7821,6 @@ func testMultiHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
|
||||
// needed.
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, net.Alice, aliceChanPoint, false)
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testMultiHopHtlcLocalChainClaim tests that in a multi-hop HTLC scenario, if
|
||||
@ -7899,6 +7838,9 @@ func testMultiHopHtlcLocalChainClaim(net *lntest.NetworkHarness, t *harnessTest)
|
||||
// self.
|
||||
aliceChanPoint, bobChanPoint, carol := createThreeHopHodlNetwork(t, net)
|
||||
|
||||
// Clean up carol's node when the test finishes.
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
// With the network active, we'll now add a new invoice at Carol's end.
|
||||
invoiceReq := &lnrpc.Invoice{
|
||||
Value: 100000,
|
||||
@ -8108,11 +8050,6 @@ func testMultiHopHtlcLocalChainClaim(net *lntest.NetworkHarness, t *harnessTest)
|
||||
if err != nil {
|
||||
t.Fatalf(predErr.Error())
|
||||
}
|
||||
|
||||
// Clean up carol's node.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testMultiHopHtlcRemoteChainClaim tests that in the multi-hop HTLC scenario,
|
||||
@ -8130,6 +8067,9 @@ func testMultiHopHtlcRemoteChainClaim(net *lntest.NetworkHarness, t *harnessTest
|
||||
// self.
|
||||
aliceChanPoint, bobChanPoint, carol := createThreeHopHodlNetwork(t, net)
|
||||
|
||||
// Clean up carol's node when the test finishes.
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
// With the network active, we'll now add a new invoice at Carol's end.
|
||||
invoiceReq := &lnrpc.Invoice{
|
||||
Value: 100000,
|
||||
@ -8299,10 +8239,6 @@ func testMultiHopHtlcRemoteChainClaim(net *lntest.NetworkHarness, t *harnessTest
|
||||
if err != nil {
|
||||
t.Fatalf(predErr.Error())
|
||||
}
|
||||
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testSwitchCircuitPersistence creates a multihop network to ensure the sender
|
||||
@ -8354,6 +8290,8 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, dave, net.Alice); err != nil {
|
||||
t.Fatalf("unable to connect dave to alice: %v", err)
|
||||
}
|
||||
@ -8386,6 +8324,8 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, carol, dave); err != nil {
|
||||
t.Fatalf("unable to connect carol to dave: %v", err)
|
||||
}
|
||||
@ -8612,16 +8552,6 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
closeChannelAndAssert(ctxt, t, net, dave, chanPointDave, false)
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, carol, chanPointCarol, false)
|
||||
|
||||
// Finally, shutdown the nodes we created for the duration of the tests,
|
||||
// only leaving the two seed nodes (Alice and Bob) within our test
|
||||
// network.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
if err := net.ShutdownNode(dave); err != nil {
|
||||
t.Fatalf("unable to shutdown dave: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testSwitchOfflineDelivery constructs a set of multihop payments, and tests
|
||||
@ -8675,6 +8605,8 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, dave, net.Alice); err != nil {
|
||||
t.Fatalf("unable to connect dave to alice: %v", err)
|
||||
}
|
||||
@ -8707,6 +8639,8 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, carol, dave); err != nil {
|
||||
t.Fatalf("unable to connect carol to dave: %v", err)
|
||||
}
|
||||
@ -8937,16 +8871,6 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
closeChannelAndAssert(ctxt, t, net, dave, chanPointDave, false)
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, carol, chanPointCarol, false)
|
||||
|
||||
// Finally, shutdown the nodes we created for the duration of the tests,
|
||||
// only leaving the two seed nodes (Alice and Bob) within our test
|
||||
// network.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
if err := net.ShutdownNode(dave); err != nil {
|
||||
t.Fatalf("unable to shutdown dave: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testSwitchOfflineDeliveryPersistence constructs a set of multihop payments,
|
||||
@ -9001,6 +8925,8 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, dave, net.Alice); err != nil {
|
||||
t.Fatalf("unable to connect dave to alice: %v", err)
|
||||
}
|
||||
@ -9033,6 +8959,8 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, carol, dave); err != nil {
|
||||
t.Fatalf("unable to connect carol to dave: %v", err)
|
||||
}
|
||||
@ -9267,16 +9195,6 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
|
||||
closeChannelAndAssert(ctxt, t, net, dave, chanPointDave, false)
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, carol, chanPointCarol, false)
|
||||
|
||||
// Finally, shutdown the nodes we created for the duration of the tests,
|
||||
// only leaving the two seed nodes (Alice and Bob) within our test
|
||||
// network.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
if err := net.ShutdownNode(dave); err != nil {
|
||||
t.Fatalf("unable to shutdown dave: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testSwitchOfflineDeliveryOutgoingOffline constructs a set of multihop payments,
|
||||
@ -9333,6 +9251,8 @@ func testSwitchOfflineDeliveryOutgoingOffline(
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, dave, net.Alice); err != nil {
|
||||
t.Fatalf("unable to connect dave to alice: %v", err)
|
||||
}
|
||||
@ -9503,9 +9423,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(
|
||||
// Shutdown carol and leave her offline for the rest of the test. This
|
||||
// is critical, as we wish to see if Dave can propragate settles even if
|
||||
// the outgoing link is never revived.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
shutdownAndAssert(net, t, carol)
|
||||
|
||||
// Now restart Dave, ensuring he is both persisting the settles, and is
|
||||
// able to reforward them to Alice after recovering from a restart.
|
||||
@ -9557,13 +9475,6 @@ func testSwitchOfflineDeliveryOutgoingOffline(
|
||||
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPointAlice, false)
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, dave, chanPointDave, false)
|
||||
|
||||
// Finally, shutdown Dave, the remaining node we created for the
|
||||
// duration of the tests, only leaving the two seed nodes (Alice and
|
||||
// Bob) within our test network.
|
||||
if err := net.ShutdownNode(dave); err != nil {
|
||||
t.Fatalf("unable to shutdown dave: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// computeFee calculates the payment fee as specified in BOLT07
|
||||
@ -9593,6 +9504,8 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, carol)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, carol, net.Bob); err != nil {
|
||||
t.Fatalf("unable to connect carol to bob: %v", err)
|
||||
}
|
||||
@ -9611,6 +9524,8 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new nodes: %v", err)
|
||||
}
|
||||
defer shutdownAndAssert(net, t, dave)
|
||||
|
||||
if err := net.ConnectNodes(ctxb, dave, carol); err != nil {
|
||||
t.Fatalf("unable to connect dave to carol: %v", err)
|
||||
}
|
||||
@ -9749,16 +9664,6 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
closeChannelAndAssert(ctxt, t, net, net.Bob, chanPointBob, false)
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
closeChannelAndAssert(ctxt, t, net, carol, chanPointCarol, false)
|
||||
|
||||
// Finally, shutdown Carol and Dave, the remaining node we created for the
|
||||
// duration of the tests, only leaving the two seed nodes (Alice and
|
||||
// Bob) within our test network.
|
||||
if err := net.ShutdownNode(carol); err != nil {
|
||||
t.Fatalf("unable to shutdown carol: %v", err)
|
||||
}
|
||||
if err := net.ShutdownNode(dave); err != nil {
|
||||
t.Fatalf("unable to shutdown dave: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// testRouteFeeCutoff tests that we are able to prevent querying routes and
|
||||
|
@ -249,6 +249,11 @@ func (hn *HarnessNode) DBPath() string {
|
||||
return hn.cfg.DBPath()
|
||||
}
|
||||
|
||||
// Name returns the name of this node set during initialization.
|
||||
func (hn *HarnessNode) Name() string {
|
||||
return hn.cfg.Name
|
||||
}
|
||||
|
||||
// Start launches a new process running lnd. Additionally, the PID of the
|
||||
// launched process is saved in order to possibly kill the process forcibly
|
||||
// later.
|
||||
|
Loading…
Reference in New Issue
Block a user