From e947162d97a9ab9d93e11c35bc6f849892157204 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 17 Apr 2017 16:09:47 -0700 Subject: [PATCH] test: signal the process for exit before shutting down local goroutines This commit is tied to the prior commit and it patches up a lingering race condition and deadlock that can arise due to now properly waiting for all goroutine to exit before concluding the shutdown process. --- lnd_test.go | 1 + networktest.go | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lnd_test.go b/lnd_test.go index 13a6120fa..658fe4f10 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -1509,6 +1509,7 @@ func testRevokedCloseRetribution(net *networkHarness, t *harnessTest) { // Next query for Bob's channel state, as we sent 3 payments of 10k // satoshis each, Bob should now see his balance as being 30k satoshis. + time.Sleep(time.Millisecond * 200) bobChan, err := getBobChanInfo() if err != nil { t.Fatalf("unable to get bob's channel info: %v", err) diff --git a/networktest.go b/networktest.go index d074ce4f9..b161ce03f 100644 --- a/networktest.go +++ b/networktest.go @@ -279,12 +279,17 @@ func (l *lightningNode) Stop() error { default: } + if runtime.GOOS == "windows" { + if err := l.cmd.Process.Signal(os.Kill); err != nil { + return err + } + } else if err := l.cmd.Process.Signal(os.Interrupt); err != nil { + return err + } + close(l.quit) l.wg.Wait() - if runtime.GOOS == "windows" { - return l.cmd.Process.Signal(os.Kill) - } - return l.cmd.Process.Signal(os.Interrupt) + return nil } // Restart attempts to restart a lightning node by shutting it down cleanly,