From 555b7db60267474c0b084228fc619ec0a2f985ca Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 6 Sep 2018 16:57:28 -0700 Subject: [PATCH] test: fix flake in link node garbage collection test In this commit, we fix a flake in the link node garbage collection test by ensuring the channels have been fully closed on both sides before we attempt to restart and ensure that they don't actually establish connections. Without this check, it's possible that either side hasn't yet processed all the blocks, so they'll still reconnect to each other on start up. --- lnd_test.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lnd_test.go b/lnd_test.go index ad2c93ec..24079bf3 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -5715,6 +5715,47 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) { t.Fatalf("unable to generate blocks: %v", err) } + // Before we test reconnection, we'll ensure that the channel has been + // fully cleaned up for both Carol and Alice. + var predErr error + pendingChansRequest := &lnrpc.PendingChannelsRequest{} + err = lntest.WaitPredicate(func() bool { + ctxt, _ = context.WithTimeout(ctxb, timeout) + pendingChanResp, err := net.Alice.PendingChannels( + ctxt, pendingChansRequest, + ) + if err != nil { + predErr = fmt.Errorf("unable to query for pending "+ + "channels: %v", err) + return false + } + + predErr = checkNumForceClosedChannels(pendingChanResp, 0) + if predErr != nil { + return false + } + + ctxt, _ = context.WithTimeout(ctxb, timeout) + pendingChanResp, err = carol.PendingChannels( + ctxt, pendingChansRequest, + ) + if err != nil { + predErr = fmt.Errorf("unable to query for pending "+ + "channels: %v", err) + return false + } + + predErr = checkNumForceClosedChannels(pendingChanResp, 0) + if predErr != nil { + return false + } + + return true + }, time.Second*15) + if err != nil { + t.Fatalf("channels not marked as fully resolved: %v", predErr) + } + testReconnection(carol) // Finally, we'll ensure that Bob and Carol no longer show in Alice's