From c89637a4e27fda54abf2ed158859a20cb7dd5daa Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 1 Oct 2021 10:25:53 +0200 Subject: [PATCH] itest: fix close of closed channel panic --- lntest/node.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lntest/node.go b/lntest/node.go index 0431f3be..2957e2c6 100644 --- a/lntest/node.go +++ b/lntest/node.go @@ -1599,6 +1599,15 @@ func (hn *HarnessNode) WaitForChannelPolicyUpdate(ctx context.Context, select { // Send a watch request every second. case <-ticker.C: + // Did the event can close in the meantime? We want to + // avoid a "close of closed channel" panic since we're + // re-using the same event chan for multiple requests. + select { + case <-eventChan: + return nil + default: + } + hn.chanWatchRequests <- &chanWatchRequest{ chanPoint: op, eventChan: eventChan,