itest: fix misuse of MineBlocks and replace it with

`MineBlocksAndAssertNumTxes`
This commit is contained in:
yyforyongyu
2024-05-20 23:06:20 +08:00
committed by yyforyongyu
parent f1f341095e
commit 8240a87c2b
8 changed files with 19 additions and 11 deletions

View File

@@ -94,7 +94,7 @@ func newChanRestoreScenario(ht *lntest.HarnessTest, ct lnrpc.CommitmentType,
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, dave) ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, dave)
// Mine a block to confirm the funds. // 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 // For the anchor output case we need two UTXOs for Carol so she can
// sweep both the local and remote anchor. // sweep both the local and remote anchor.

View File

@@ -359,6 +359,8 @@ func testEstimateRouteFee(ht *lntest.HarnessTest) {
mts.ht.CloseChannelAssertPending(mts.bob, channelPointBobPaula, false) mts.ht.CloseChannelAssertPending(mts.bob, channelPointBobPaula, false)
mts.ht.CloseChannelAssertPending(mts.eve, channelPointEvePaula, false) mts.ht.CloseChannelAssertPending(mts.eve, channelPointEvePaula, false)
ht.MineBlocksAndAssertNumTxes(1, 2)
mts.closeChannels() mts.closeChannels()
} }

View File

@@ -208,7 +208,8 @@ func newMppTestScenario(ht *lntest.HarnessTest) *mppTestScenario {
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, carol) ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, carol)
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, dave) ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, dave)
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, eve) ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, eve)
ht.MineBlocks(1)
ht.MineBlocksAndAssertNumTxes(1, 3)
} }
mts := &mppTestScenario{ mts := &mppTestScenario{
@@ -318,7 +319,7 @@ func (m *mppTestScenario) closeChannels() {
m.ht.CloseChannelAssertPending(m.eve, m.channelPoints[5], false) m.ht.CloseChannelAssertPending(m.eve, m.channelPoints[5], false)
// Now mine a block to include all the closing transactions. // 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. // Assert that the channels are closed.
for _, hn := range m.nodes { for _, hn := range m.nodes {

View File

@@ -2223,7 +2223,7 @@ func createThreeHopNetwork(ht *lntest.HarnessTest,
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, carol) ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, carol)
// Mine 1 block to get the above coins confirmed. // Mine 1 block to get the above coins confirmed.
ht.MineBlocks(1) ht.MineBlocksAndAssertNumTxes(1, 3)
} }
// We'll start the test by creating a channel between Alice and Bob, // We'll start the test by creating a channel between Alice and Bob,
@@ -2703,8 +2703,14 @@ func runExtraPreimageFromLocalCommit(ht *lntest.HarnessTest,
// Make sure the direct spend tx is still in the mempool. // Make sure the direct spend tx is still in the mempool.
ht.AssertOutpointInMempool(htlcOutpoint) ht.AssertOutpointInMempool(htlcOutpoint)
// Mine a block to confirm Carol's direct spend tx. // Mine a block to confirm two txns,
ht.MineBlocks(1) // - Carol's direct spend tx.
// - Bob's to_local output sweep tx.
if c != lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE {
ht.MineBlocksAndAssertNumTxes(1, 2)
} else {
ht.MineBlocksAndAssertNumTxes(1, 1)
}
} }
// Finally, check that the Alice's payment is marked as succeeded as // Finally, check that the Alice's payment is marked as succeeded as

View File

@@ -601,7 +601,7 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) {
Index: 1, Index: 1,
} }
ht.AssertOutpointInMempool(commitSweepOp) ht.AssertOutpointInMempool(commitSweepOp)
ht.MineBlocks(1) ht.MineBlocksAndAssertNumTxes(1, 1)
ht.AssertNumWaitingClose(alice, 0) ht.AssertNumWaitingClose(alice, 0)
} }

View File

@@ -428,8 +428,7 @@ func testRescanAddressDetection(ht *lntest.HarnessTest) {
}) })
// Wait until the spending tx is found and mine a block to confirm it. // Wait until the spending tx is found and mine a block to confirm it.
ht.AssertNumTxsInMempool(1) ht.MineBlocksAndAssertNumTxes(1, 1)
ht.MineBlocks(1)
// The wallet should still just see a single UTXO of the change output // The wallet should still just see a single UTXO of the change output
// created earlier. // created earlier.

View File

@@ -66,7 +66,7 @@ func testResHandoff(ht *lntest.HarnessTest) {
ht.AssertNumWaitingClose(bob, 1) ht.AssertNumWaitingClose(bob, 1)
// Mine a block to confirm the closing tx. // 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 // 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 // Bob's contractcourt to Bob's htlcswitch. This sleep could be removed

View File

@@ -104,7 +104,7 @@ func (h *HarnessTest) MineBlocksAndAssertNumTxes(num uint32,
txids := h.AssertNumTxsInMempool(numTxs) txids := h.AssertNumTxsInMempool(numTxs)
// Mine blocks. // Mine blocks.
blocks := h.miner.MineBlocksSlow(num) blocks := h.miner.MineBlocks(num)
// Assert that all the transactions were included in the first block. // Assert that all the transactions were included in the first block.
for _, txid := range txids { for _, txid := range txids {