itest: Shutdown final Dave node in testChanRestore

This changes the defer function in the test for channel backups to
correctly close over the 'dave' variable.

Without this closure, the shutdownAndAssert call would attempt to
shutdown the original (non-restored) dave instead of the most recently
created (restored) dave, causing a leak of a node during tests.
This commit is contained in:
Matheus Degiovani 2019-09-10 09:21:00 -03:00
parent 281c535b49
commit d6286e9463
No known key found for this signature in database
GPG Key ID: 60AC5E69F376D6E6

@ -13405,7 +13405,11 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, dave)
// Defer to a closure instead of to shutdownAndAssert due to the value
// of 'dave' changing throughout the test.
defer func() {
shutdownAndAssert(net, t, dave)
}()
carol, err := net.NewNode("carol", nil)
if err != nil {
t.Fatalf("unable to make new node: %v", err)