From 23f2d9340292fb3301991905c61c826a7b21a62d Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 26 Jun 2018 18:03:56 -0700 Subject: [PATCH 1/2] htlcswitch/link_test: wait for link shutdown after removal --- htlcswitch/link_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index c6b2819ff..8c56b1e4e 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -3710,6 +3710,7 @@ func (h *persistentLinkHarness) restart(restartSwitch bool, // First, remove the link from the switch. h.coreLink.cfg.Switch.RemoveLink(h.link.ChanID()) + h.coreLink.WaitForShutdown() var htlcSwitch *Switch if restartSwitch { From 66c4240234e741edd12232de68f06f34e6acbc14 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 26 Jun 2018 18:05:39 -0700 Subject: [PATCH 2/2] htlcswitch/link: add WaitForShutdown method for testing --- htlcswitch/link.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 9a933f046..2aeb9707e 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -465,6 +465,12 @@ func (l *channelLink) Stop() { l.wg.Wait() } +// WaitForShutdown blocks until the link finishes shutting down, which includes +// termination of all dependent goroutines. +func (l *channelLink) WaitForShutdown() { + l.wg.Wait() +} + // EligibleToForward returns a bool indicating if the channel is able to // actively accept requests to forward HTLC's. We're able to forward HTLC's if // we know the remote party's next revocation point. Otherwise, we can't