From 2a6f128a43fa67eb3ffdf6ea965f34fd9f0106df Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 29 Oct 2021 11:18:37 +0200 Subject: [PATCH] itest: wait for channel to be properly closed It looks like in some cases a channel is still being closed while we already try to create a sweep output. In that case the pending closed channel is still counted as anchor channel and a reserve output is created. To make sure that doesn't happen, we make sure there are no pending or open channels of any kind around before we create the sweep transaction. --- lntest/itest/lnd_onchain_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lntest/itest/lnd_onchain_test.go b/lntest/itest/lnd_onchain_test.go index da4af2fa0..cfae6921d 100644 --- a/lntest/itest/lnd_onchain_test.go +++ b/lntest/itest/lnd_onchain_test.go @@ -209,8 +209,7 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) { // Alice opens a smaller channel. This works since it will have a // change output. aliceChanPoint1 := openChannelAndAssert( - t, net, alice, bob, - lntest.OpenChannelParams{ + t, net, alice, bob, lntest.OpenChannelParams{ Amt: chanAmt / 4, }, ) @@ -326,7 +325,7 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) { block = mineBlocks(t, net, 1, 1)[0] // The sweep transaction should have exactly one inputs as we only had - // the the single output from above in the wallet. + // the single output from above in the wallet. sweepTx = block.Transactions[1] if len(sweepTx.TxIn) != 1 { t.Fatalf("expected 1 inputs instead have %v", len(sweepTx.TxIn)) @@ -352,9 +351,12 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) { t.Fatalf("Alice's balance did not increase after channel close") } + // Assert there are no open or pending channels anymore. + assertNumPendingChannels(t, alice, 0, 0) + assertNodeNumChannels(t, alice, 0) + // We'll wait for the balance to reflect that the channel has been // closed and the funds are in the wallet. - sweepReq = &lnrpc.SendCoinsRequest{ Addr: minerAddr.String(), SendAll: true,