From 64f7a7f3d039d2dd0bac596db203b6af00ed1ab1 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Wed, 19 Mar 2025 17:24:20 +0800 Subject: [PATCH] lntest+itest: update block height in `MineBlockWithTx` Make sure we update the harness's current height and assert nodes have been synced. Also fixes some typo found. --- itest/lnd_multi-hop_force_close_test.go | 2 +- itest/lnd_sweep_test.go | 4 ++-- lntest/harness_miner.go | 10 +++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/itest/lnd_multi-hop_force_close_test.go b/itest/lnd_multi-hop_force_close_test.go index 84f8c8d44..c542c81ac 100644 --- a/itest/lnd_multi-hop_force_close_test.go +++ b/itest/lnd_multi-hop_force_close_test.go @@ -2570,7 +2570,7 @@ func runLocalPreimageClaimLeased(ht *lntest.HarnessTest, // We'll now mine enough blocks so Carol decides that she needs to go // on-chain to claim the HTLC as Bob has been inactive. numBlocks := padCLTV( - invoiceExpiry - ht.CurrentHeight() - incomingBroadcastDelta - 1, + invoiceExpiry - ht.CurrentHeight() - incomingBroadcastDelta, ) ht.MineBlocks(int(numBlocks)) diff --git a/itest/lnd_sweep_test.go b/itest/lnd_sweep_test.go index 8533b74d0..d6e5fcff5 100644 --- a/itest/lnd_sweep_test.go +++ b/itest/lnd_sweep_test.go @@ -1957,7 +1957,7 @@ func runBumpFee(ht *lntest.HarnessTest, alice *node.HarnessNode) { // initial broadcast always succeeds. assertFeeRateGreater(testFeeRate) - // Clean up the mempol. + // Clean up the mempool. ht.MineBlocksAndAssertNumTxes(1, 2) } @@ -2373,6 +2373,6 @@ func testFeeReplacement(ht *lntest.HarnessTest) { uint64(feeRate), 0.02, "want %d, got %d in tx=%v", currentFeeRate, feeRate, outgoingSweep2.TxHash()) - // Finally, clean the mempol. + // Finally, clean the mempool. ht.MineBlocksAndAssertNumTxes(1, 1) } diff --git a/lntest/harness_miner.go b/lntest/harness_miner.go index cde9663c4..010c3f8ca 100644 --- a/lntest/harness_miner.go +++ b/lntest/harness_miner.go @@ -247,7 +247,15 @@ func (h *HarnessTest) GetBestBlock() (*chainhash.Hash, int32) { // MineBlockWithTx mines a single block to include the specifies tx only. func (h *HarnessTest) MineBlockWithTx(tx *wire.MsgTx) *wire.MsgBlock { - return h.miner.MineBlockWithTx(tx) + // Update the harness's current height. + defer h.updateCurrentHeight() + + block := h.miner.MineBlockWithTx(tx) + + // Finally, make sure all the active nodes are synced. + h.AssertActiveNodesSyncedTo(block.BlockHash()) + + return block } // ConnectToMiner connects the miner to a temp miner.