lntest+itest: strictly define the behavior of MineBlocks

This commit adds more assertion to `MineBlocks` so the caller won't
misuse it.
This commit is contained in:
yyforyongyu authored and yyforyongyu committed 2024-07-23 21:30:07 +08:00
1 parent 91b20e661b
commit e553895ddd
8 files changed
+52 -31

No files matched your search

+2 -2
View File
@@ -93,7 +93,7 @@ func testHoldInvoiceForceClose(ht *lntest.HarnessTest) {
// TODO(yy): fix block height asymmetry among all the subsystems.
//
// We first mine enough blocks to trigger an invoice cancelation.
ht.MineBlocks(blocksTillCancel)
ht.MineBlocks(int(blocksTillCancel))
// Wait for the nodes to be synced.
ht.WaitForBlockchainSync(alice)
@@ -133,7 +133,7 @@ func testHoldInvoiceForceClose(ht *lntest.HarnessTest) {
// happen in bitcoind backend, as Alice's CNCT was syncing way faster
// than Bob's INVC, causing the channel being force closed before the
// invoice cancelation message was received by Alice.
ht.MineBlocks(blocksTillForce - blocksTillCancel)
ht.MineBlocks(int(blocksTillForce - blocksTillCancel))
// Wait for the nodes to be synced.
ht.WaitForBlockchainSync(alice)
+1 -1
View File
@@ -243,7 +243,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest,
numBlocks := padCLTV(
uint32(finalCltvDelta - lncfg.DefaultOutgoingBroadcastDelta),
)
ht.MineBlocks(numBlocks)
ht.MineBlocks(int(numBlocks))
// Bob's force close transaction should now be found in the mempool.
ht.Miner.AssertNumTxsInMempool(1)
+1 -1
View File
@@ -58,7 +58,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
// and our new miner mine 15. This will also confirm our pending
// channel on the original miner's chain, which should be considered
// open.
block := ht.MineBlocks(10)[0]
block := ht.MineBlocksAndAssertNumTxes(10, 1)[0]
ht.Miner.AssertTxInBlock(block, fundingTxID)
_, err = tempMiner.Client.Generate(15)
require.NoError(ht, err, "unable to generate blocks")
+1 -1
View File
@@ -263,7 +263,7 @@ func testOnchainFundRecovery(ht *lntest.HarnessTest) {
txid := ht.Miner.AssertNumTxsInMempool(1)[0]
require.Equal(ht, txid.String(), resp.Txid)
block := ht.MineBlocks(1)[0]
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, txid)
}
restoreCheckBalance(finalBalance, 9, 20, promptChangeAddr)
+1 -1
View File
@@ -1021,7 +1021,7 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
// value.
info := ht.Bob.RPC.GetInfo()
target := carolHTLC.IncomingExpiry - info.BlockHeight
ht.MineBlocks(target)
ht.MineBlocks(int(target))
// Wait for Bob's timeout transaction in the mempool, since we've
// suspended Carol we don't need to account for her commitment output
+2 -2
View File
@@ -872,7 +872,7 @@ func testSweepHTLCs(ht *lntest.HarnessTest) {
numBlocks := padCLTV(uint32(
invoiceReqHold.CltvExpiry - lncfg.DefaultOutgoingBroadcastDelta,
))
ht.MineBlocks(numBlocks)
ht.MineBlocks(int(numBlocks))
// Before we mine empty blocks to check the RBF behavior, we need to be
// aware that Bob's incoming HTLC will expire before his outgoing HTLC
@@ -1804,7 +1804,7 @@ func createSimpleNetwork(ht *lntest.HarnessTest, nodeCfg []string,
}
// Mine 1 block to get the above coins confirmed.
ht.MineBlocks(1)
ht.MineBlocksAndAssertNumTxes(1, numNodes-1)
// Open channels in batch to save blocks mined.
reqs := make([]*lntest.OpenChannelRequest, 0, len(nodes)-1)