From d6286e94638ce2f0bcace01d6b8e9bbef5e0ca71 Mon Sep 17 00:00:00 2001 From: Matheus Degiovani Date: Tue, 10 Sep 2019 09:21:00 -0300 Subject: [PATCH] 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. --- lntest/itest/lnd_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index 0081d0cc..f36e8130 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -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)