From 2be0eb15c3eb1e9e577441f00935ed8d01497e69 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Mon, 20 May 2024 23:06:20 +0800 Subject: [PATCH] itest: fix misuse of `MineBlocks` and replace it with `MineBlocksAndAssertNumTxes` --- itest/lnd_channel_backup_test.go | 2 +- itest/lnd_estimate_route_fee_test.go | 2 ++ itest/lnd_mpp_test.go | 10 ++++++++-- itest/lnd_multi-hop_test.go | 8 ++++++-- itest/lnd_onchain_test.go | 2 +- itest/lnd_recovery_test.go | 3 +-- itest/lnd_res_handoff_test.go | 2 +- 7 files changed, 20 insertions(+), 9 deletions(-) diff --git a/itest/lnd_channel_backup_test.go b/itest/lnd_channel_backup_test.go index 8da67a71a0..36b38f8b5c 100644 --- a/itest/lnd_channel_backup_test.go +++ b/itest/lnd_channel_backup_test.go @@ -94,7 +94,7 @@ func newChanRestoreScenario(ht *lntest.HarnessTest, ct lnrpc.CommitmentType, ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, dave) // Mine a block to confirm the funds. - ht.MineBlocks(1) + ht.MineBlocksAndAssertNumTxes(1, 2) // For the anchor output case we need two UTXOs for Carol so she can // sweep both the local and remote anchor. diff --git a/itest/lnd_estimate_route_fee_test.go b/itest/lnd_estimate_route_fee_test.go index 352dfe5ce2..8ed0be2725 100644 --- a/itest/lnd_estimate_route_fee_test.go +++ b/itest/lnd_estimate_route_fee_test.go @@ -359,6 +359,8 @@ func testEstimateRouteFee(ht *lntest.HarnessTest) { mts.ht.CloseChannelAssertPending(mts.bob, channelPointBobPaula, false) mts.ht.CloseChannelAssertPending(mts.eve, channelPointEvePaula, false) + ht.MineBlocksAndAssertNumTxes(1, 2) + mts.closeChannels() } diff --git a/itest/lnd_mpp_test.go b/itest/lnd_mpp_test.go index bf26798465..e5a1a8a4f3 100644 --- a/itest/lnd_mpp_test.go +++ b/itest/lnd_mpp_test.go @@ -208,7 +208,13 @@ func newMppTestScenario(ht *lntest.HarnessTest) *mppTestScenario { ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, carol) ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, dave) ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, eve) - ht.MineBlocks(1) + + // Mine 1 block to get the above coins confirmed. + if ht.IsNeutrinoBackend() { + ht.MineBlocks(1) + } else { + ht.MineBlocksAndAssertNumTxes(1, 3) + } } mts := &mppTestScenario{ @@ -318,7 +324,7 @@ func (m *mppTestScenario) closeChannels() { m.ht.CloseChannelAssertPending(m.eve, m.channelPoints[5], false) // Now mine a block to include all the closing transactions. - m.ht.MineBlocks(1) + m.ht.MineBlocksAndAssertNumTxes(1, 6) // Assert that the channels are closed. for _, hn := range m.nodes { diff --git a/itest/lnd_multi-hop_test.go b/itest/lnd_multi-hop_test.go index 47df4c38fd..160acb65a5 100644 --- a/itest/lnd_multi-hop_test.go +++ b/itest/lnd_multi-hop_test.go @@ -2223,7 +2223,11 @@ func createThreeHopNetwork(ht *lntest.HarnessTest, ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, carol) // Mine 1 block to get the above coins confirmed. - ht.MineBlocks(1) + if ht.IsNeutrinoBackend() { + ht.MineBlocks(1) + } else { + ht.MineBlocksAndAssertNumTxes(1, 3) + } } // We'll start the test by creating a channel between Alice and Bob, @@ -2704,7 +2708,7 @@ func runExtraPreimageFromLocalCommit(ht *lntest.HarnessTest, ht.AssertOutpointInMempool(htlcOutpoint) // Mine a block to confirm Carol's direct spend tx. - ht.MineBlocks(1) + ht.MineBlocksAndAssertNumTxes(1, 1) } // Finally, check that the Alice's payment is marked as succeeded as diff --git a/itest/lnd_onchain_test.go b/itest/lnd_onchain_test.go index 9ddf194b31..a34b9a2e47 100644 --- a/itest/lnd_onchain_test.go +++ b/itest/lnd_onchain_test.go @@ -601,7 +601,7 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) { Index: 1, } ht.AssertOutpointInMempool(commitSweepOp) - ht.MineBlocks(1) + ht.MineBlocksAndAssertNumTxes(1, 1) ht.AssertNumWaitingClose(alice, 0) } diff --git a/itest/lnd_recovery_test.go b/itest/lnd_recovery_test.go index ccc5f90afb..ea93f373eb 100644 --- a/itest/lnd_recovery_test.go +++ b/itest/lnd_recovery_test.go @@ -428,8 +428,7 @@ func testRescanAddressDetection(ht *lntest.HarnessTest) { }) // Wait until the spending tx is found and mine a block to confirm it. - ht.AssertNumTxsInMempool(1) - ht.MineBlocks(1) + ht.MineBlocksAndAssertNumTxes(1, 1) // The wallet should still just see a single UTXO of the change output // created earlier. diff --git a/itest/lnd_res_handoff_test.go b/itest/lnd_res_handoff_test.go index 8fc2f10434..941cc52837 100644 --- a/itest/lnd_res_handoff_test.go +++ b/itest/lnd_res_handoff_test.go @@ -66,7 +66,7 @@ func testResHandoff(ht *lntest.HarnessTest) { ht.AssertNumWaitingClose(bob, 1) // Mine a block to confirm the closing tx. - ht.MineBlocks(1) + ht.MineBlocksAndAssertNumTxes(1, 1) // We sleep here so we can be sure that the hand-off has occurred from // Bob's contractcourt to Bob's htlcswitch. This sleep could be removed