From cc6b20bf2f8dcd2a9c5d9c0964412e8ff85a4e73 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Tue, 31 Oct 2023 16:51:24 +0800 Subject: [PATCH] lntest: mine empty blocks when cleaning up force close Fix this test flake, ``` harness_miner.go:218: Error Trace: /home/runner/work/lnd/lnd/lntest/harness_miner.go:218 /home/runner/work/lnd/lnd/lntest/harness.go:1641 /home/runner/work/lnd/lnd/lntest/harness.go:1515 /home/runner/work/lnd/lnd/itest/lnd_wipe_fwdpkgs_test.go:121 /home/runner/work/lnd/lnd/lntest/harness.go:286 /home/runner/work/lnd/lnd/itest/lnd_test.go:136 Error: Received unexpected error: want 1, got 0 in mempool: [] Test: TestLightningNetworkDaemon/tranche02/91-of-135/neutrino/wipe_forwarding_packages Messages: assert tx in mempool timeout harness.go:339: finished test: wipe_forwarding_packages, start height=1636, end height=1653, mined blocks=17 harness.go:345: test failed, skipped cleanup ``` --- lntest/harness.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lntest/harness.go b/lntest/harness.go index 5915abed7..ccb5be930 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -1504,11 +1504,13 @@ func (h *HarnessTest) CleanupForceClose(hn *node.HarnessNode) { h.AssertNumPendingForceClose(hn, 1) // Mine enough blocks for the node to sweep its funds from the force - // closed channel. + // closed channel. The commit sweep resolver is able to broadcast the + // sweep tx up to one block before the CSV elapses, so wait until + // defaulCSV-1. // - // The commit sweep resolver is able to broadcast the sweep tx up to - // one block before the CSV elapses, so wait until defaulCSV-1. - h.MineBlocks(node.DefaultCSV - 1) + // NOTE: we might empty blocks here as we don't know the exact number + // of blocks to mine. This may end up mining more blocks than needed. + h.MineEmptyBlocks(node.DefaultCSV - 1) // The node should now sweep the funds, clean up by mining the sweeping // tx.