Skip to content

Commit b3acb5d

Browse files
committed
itest: fix misuse of MineBlocks and replace it with
`MineBlocksAndAssertNumTxes`
1 parent 7b03909 commit b3acb5d

8 files changed

+28
-10
lines changed

itest/lnd_channel_backup_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func newChanRestoreScenario(ht *lntest.HarnessTest, ct lnrpc.CommitmentType,
9494
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, dave)
9595

9696
// Mine a block to confirm the funds.
97-
ht.MineBlocks(1)
97+
ht.MineBlocksAndAssertNumTxes(1, 2)
9898

9999
// For the anchor output case we need two UTXOs for Carol so she can
100100
// sweep both the local and remote anchor.

itest/lnd_estimate_route_fee_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ func testEstimateRouteFee(ht *lntest.HarnessTest) {
359359

360360
mts.ht.CloseChannelAssertPending(mts.bob, channelPointBobPaula, false)
361361
mts.ht.CloseChannelAssertPending(mts.eve, channelPointEvePaula, false)
362+
ht.MineBlocksAndAssertNumTxes(1, 2)
363+
362364
mts.closeChannels()
363365
}
364366

itest/lnd_mpp_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,13 @@ func newMppTestScenario(ht *lntest.HarnessTest) *mppTestScenario {
208208
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, carol)
209209
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, dave)
210210
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, eve)
211-
ht.MineBlocks(1)
211+
212+
// Mine 1 block to get the above coins confirmed.
213+
if ht.IsNeutrinoBackend() {
214+
ht.MineBlocks(1)
215+
} else {
216+
ht.MineBlocksAndAssertNumTxes(1, 3)
217+
}
212218
}
213219

214220
mts := &mppTestScenario{
@@ -318,7 +324,7 @@ func (m *mppTestScenario) closeChannels() {
318324
m.ht.CloseChannelAssertPending(m.eve, m.channelPoints[5], false)
319325

320326
// Now mine a block to include all the closing transactions.
321-
m.ht.MineBlocks(1)
327+
m.ht.MineBlocksAndAssertNumTxes(1, 6)
322328

323329
// Assert that the channels are closed.
324330
for _, hn := range m.nodes {

itest/lnd_multi-hop_test.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,11 @@ func createThreeHopNetwork(ht *lntest.HarnessTest,
22232223
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, carol)
22242224

22252225
// Mine 1 block to get the above coins confirmed.
2226-
ht.MineBlocks(1)
2226+
if ht.IsNeutrinoBackend() {
2227+
ht.MineBlocks(1)
2228+
} else {
2229+
ht.MineBlocksAndAssertNumTxes(1, 3)
2230+
}
22272231
}
22282232

22292233
// We'll start the test by creating a channel between Alice and Bob,
@@ -2704,7 +2708,7 @@ func runExtraPreimageFromLocalCommit(ht *lntest.HarnessTest,
27042708
ht.AssertOutpointInMempool(htlcOutpoint)
27052709

27062710
// Mine a block to confirm Carol's direct spend tx.
2707-
ht.MineBlocks(1)
2711+
ht.MineBlocksAndAssertNumTxes(1, 1)
27082712
}
27092713

27102714
// Finally, check that the Alice's payment is marked as succeeded as

itest/lnd_onchain_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) {
601601
Index: 1,
602602
}
603603
ht.AssertOutpointInMempool(commitSweepOp)
604-
ht.MineBlocks(1)
604+
ht.MineBlocksAndAssertNumTxes(1, 1)
605605

606606
ht.AssertNumWaitingClose(alice, 0)
607607
}

itest/lnd_recovery_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,7 @@ func testRescanAddressDetection(ht *lntest.HarnessTest) {
428428
})
429429

430430
// Wait until the spending tx is found and mine a block to confirm it.
431-
ht.AssertNumTxsInMempool(1)
432-
ht.MineBlocks(1)
431+
ht.MineBlocksAndAssertNumTxes(1, 1)
433432

434433
// The wallet should still just see a single UTXO of the change output
435434
// created earlier.

itest/lnd_res_handoff_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func testResHandoff(ht *lntest.HarnessTest) {
6666
ht.AssertNumWaitingClose(bob, 1)
6767

6868
// Mine a block to confirm the closing tx.
69-
ht.MineBlocks(1)
69+
ht.MineBlocksAndAssertNumTxes(1, 1)
7070

7171
// We sleep here so we can be sure that the hand-off has occurred from
7272
// Bob's contractcourt to Bob's htlcswitch. This sleep could be removed

lntest/harness_miner.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,19 @@ func (h *HarnessTest) MineBlocksAndAssertNumTxes(num uint32,
9999
// Update the harness's current height.
100100
defer h.updateCurrentHeight()
101101

102+
// Neutrino nodes have trouble accessing the mempool so we skip it.
103+
//
104+
// TODO(yy): figure out the details.
105+
if h.IsNeutrinoBackend() {
106+
return h.miner.MineBlocks(num)
107+
}
108+
102109
// If we expect transactions to be included in the blocks we'll mine,
103110
// we wait here until they are seen in the miner's mempool.
104111
txids := h.AssertNumTxsInMempool(numTxs)
105112

106113
// Mine blocks.
107-
blocks := h.miner.MineBlocksSlow(num)
114+
blocks := h.miner.MineBlocks(num)
108115

109116
// Assert that all the transactions were included in the first block.
110117
for _, txid := range txids {

0 commit comments

Comments
 (0)