Skip to content

Commit

Permalink
itest: fix misuse of MineBlocks and replace it with
Browse files Browse the repository at this point in the history
`MineBlocksAndAssertNumTxes`
  • Loading branch information
yyforyongyu committed Jun 5, 2024
1 parent a3b85e9 commit 2be0eb1
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion itest/lnd_channel_backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions itest/lnd_estimate_route_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
10 changes: 8 additions & 2 deletions itest/lnd_mpp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions itest/lnd_multi-hop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion itest/lnd_onchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions itest/lnd_recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion itest/lnd_res_handoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2be0eb1

Please sign in to comment.