lntest+itest: add method AssertNumTxsInMempool and AssertTxInBlock

in harness

Prepare to make `HarnessTest.Miner` a private instance to sync height.
This commit is contained in:
yyforyongyu 2024-05-01 19:21:00 +08:00 committed by yyforyongyu
parent e553895ddd
commit 976bb37972
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868
20 changed files with 108 additions and 93 deletions

View File

@ -783,7 +783,7 @@ func runChanRestoreScenarioForceClose(ht *lntest.HarnessTest, zeroConf bool) {
) )
// We now wait until both Dave's closing tx. // We now wait until both Dave's closing tx.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// Now that we're able to make our restored now, we'll shutdown the old // Now that we're able to make our restored now, we'll shutdown the old
// Dave node as we'll be storing it shortly below. // Dave node as we'll be storing it shortly below.
@ -1272,7 +1272,7 @@ func testDataLossProtection(ht *lntest.HarnessTest) {
ht.MineBlocks(1) ht.MineBlocks(1)
// Dave should sweep his funds. // Dave should sweep his funds.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// Mine a block to confirm the sweep, and make sure Dave got his // Mine a block to confirm the sweep, and make sure Dave got his
// balance back. // balance back.
@ -1428,7 +1428,7 @@ func assertTimeLockSwept(ht *lntest.HarnessTest, carol, dave *node.HarnessNode,
// Mine a block to trigger the sweeps. // Mine a block to trigger the sweeps.
ht.MineBlocks(1) ht.MineBlocks(1)
ht.Miner.AssertNumTxsInMempool(expectedTxes) ht.AssertNumTxsInMempool(expectedTxes)
// Carol should consider the channel pending force close (since she is // Carol should consider the channel pending force close (since she is
// waiting for her sweep to confirm). // waiting for her sweep to confirm).
@ -1462,9 +1462,9 @@ func assertTimeLockSwept(ht *lntest.HarnessTest, carol, dave *node.HarnessNode,
// Mine a block to trigger the sweeps. // Mine a block to trigger the sweeps.
ht.MineEmptyBlocks(1) ht.MineEmptyBlocks(1)
daveSweep := ht.Miner.AssertNumTxsInMempool(1)[0] daveSweep := ht.AssertNumTxsInMempool(1)[0]
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, daveSweep) ht.AssertTxInBlock(block, daveSweep)
// Now the channel should be fully closed also from Dave's POV. // Now the channel should be fully closed also from Dave's POV.
ht.AssertNumPendingForceClose(dave, 0) ht.AssertNumPendingForceClose(dave, 0)
@ -1510,7 +1510,7 @@ func assertDLPExecuted(ht *lntest.HarnessTest,
// Upon reconnection, the nodes should detect that Dave is out of sync. // Upon reconnection, the nodes should detect that Dave is out of sync.
// Carol should force close the channel using her latest commitment. // Carol should force close the channel using her latest commitment.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// Channel should be in the state "waiting close" for Carol since she // Channel should be in the state "waiting close" for Carol since she
// broadcasted the force close tx. // broadcasted the force close tx.

View File

@ -389,7 +389,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
// So we fetch the node's mempool to ensure it has been properly // So we fetch the node's mempool to ensure it has been properly
// broadcast. // broadcast.
ht.MineEmptyBlocks(1) ht.MineEmptyBlocks(1)
sweepingTXID := ht.Miner.AssertNumTxsInMempool(1)[0] sweepingTXID := ht.AssertNumTxsInMempool(1)[0]
// Fetch the sweep transaction, all input it's spending should be from // Fetch the sweep transaction, all input it's spending should be from
// the commitment transaction which was broadcast on-chain. // the commitment transaction which was broadcast on-chain.
@ -547,7 +547,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
// NOTE: after restart, all the htlc timeout txns will be offered to // NOTE: after restart, all the htlc timeout txns will be offered to
// the sweeper with `Immediate` set to true, so they won't be // the sweeper with `Immediate` set to true, so they won't be
// aggregated. // aggregated.
htlcTxIDs := ht.Miner.AssertNumTxsInMempool(numInvoices) htlcTxIDs := ht.AssertNumTxsInMempool(numInvoices)
// Retrieve each htlc timeout txn from the mempool, and ensure it is // Retrieve each htlc timeout txn from the mempool, and ensure it is
// well-formed. This entails verifying that each only spends from // well-formed. This entails verifying that each only spends from
@ -733,7 +733,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
} }
// Wait for the single sweep txn to appear in the mempool. // Wait for the single sweep txn to appear in the mempool.
htlcSweepTxID := ht.Miner.AssertNumTxsInMempool(1)[0] htlcSweepTxID := ht.AssertNumTxsInMempool(1)[0]
// Fetch the htlc sweep transaction from the mempool. // Fetch the htlc sweep transaction from the mempool.
htlcSweepTx := ht.Miner.GetRawTransaction(htlcSweepTxID) htlcSweepTx := ht.Miner.GetRawTransaction(htlcSweepTxID)
@ -818,7 +818,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
// Generate the final block that sweeps all htlc funds into the user's // Generate the final block that sweeps all htlc funds into the user's
// wallet, and make sure the sweep is in this block. // wallet, and make sure the sweep is in this block.
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, htlcSweepTxID) ht.AssertTxInBlock(block, htlcSweepTxID)
// Now that the channel has been fully swept, it should no longer show // Now that the channel has been fully swept, it should no longer show
// up within the pending channels RPC. // up within the pending channels RPC.
@ -935,7 +935,7 @@ func testFailingChannel(ht *lntest.HarnessTest) {
ht.MineEmptyBlocks(1) ht.MineEmptyBlocks(1)
// Carol should have broadcast her sweeping tx. // Carol should have broadcast her sweeping tx.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// Mine two blocks to confirm Carol's sweeping tx, which will by now // Mine two blocks to confirm Carol's sweeping tx, which will by now
// Alice's commit output should be offered to her sweeper. // Alice's commit output should be offered to her sweeper.

View File

@ -859,7 +859,7 @@ func testChannelFundingPersistence(ht *lntest.HarnessTest) {
// channel has been opened. The funding transaction should be found // channel has been opened. The funding transaction should be found
// within the newly mined block. // within the newly mined block.
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, fundingTxID) ht.AssertTxInBlock(block, fundingTxID)
// Get the height that our transaction confirmed at. // Get the height that our transaction confirmed at.
_, height := ht.Miner.GetBestBlock() _, height := ht.Miner.GetBestBlock()
@ -1047,7 +1047,7 @@ func testBatchChanFunding(ht *lntest.HarnessTest) {
// Mine the batch transaction and check the network topology. // Mine the batch transaction and check the network topology.
block := ht.MineBlocksAndAssertNumTxes(6, 1)[0] block := ht.MineBlocksAndAssertNumTxes(6, 1)[0]
ht.Miner.AssertTxInBlock(block, txHash) ht.AssertTxInBlock(block, txHash)
ht.AssertTopologyChannelOpen(alice, chanPoint1) ht.AssertTopologyChannelOpen(alice, chanPoint1)
ht.AssertTopologyChannelOpen(alice, chanPoint2) ht.AssertTopologyChannelOpen(alice, chanPoint2)
ht.AssertTopologyChannelOpen(alice, chanPoint3) ht.AssertTopologyChannelOpen(alice, chanPoint3)

View File

@ -416,7 +416,7 @@ func testMaxPendingChannels(ht *lntest.HarnessTest) {
// Ensure that the funding transaction enters a block, and is // Ensure that the funding transaction enters a block, and is
// properly advertised by Alice. // properly advertised by Alice.
ht.Miner.AssertTxInBlock(block, fundingTxID) ht.AssertTxInBlock(block, fundingTxID)
ht.AssertTopologyChannelOpen(alice, fundingChanPoint) ht.AssertTopologyChannelOpen(alice, fundingChanPoint)
// The channel should be listed in the peer information // The channel should be listed in the peer information

View File

@ -246,7 +246,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest,
ht.MineBlocks(int(numBlocks)) ht.MineBlocks(int(numBlocks))
// Bob's force close transaction should now be found in the mempool. // Bob's force close transaction should now be found in the mempool.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
op := ht.OutPointFromChannelPoint(bobChanPoint) op := ht.OutPointFromChannelPoint(bobChanPoint)
closeTx := ht.Miner.AssertOutpointInMempool(op) closeTx := ht.Miner.AssertOutpointInMempool(op)
@ -276,7 +276,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest,
// 1. Bob's sweeping tx anchor sweep should now be found in the mempool. // 1. Bob's sweeping tx anchor sweep should now be found in the mempool.
// 2. Bob's HTLC timeout tx sweep should now be found in the mempool. // 2. Bob's HTLC timeout tx sweep should now be found in the mempool.
// Carol's anchor sweep should be failed due to output being dust. // Carol's anchor sweep should be failed due to output being dust.
ht.Miner.AssertNumTxsInMempool(2) ht.AssertNumTxsInMempool(2)
htlcOutpoint := wire.OutPoint{Hash: closeTx.TxHash(), Index: 2} htlcOutpoint := wire.OutPoint{Hash: closeTx.TxHash(), Index: 2}
commitOutpoint := wire.OutPoint{Hash: closeTx.TxHash(), Index: 3} commitOutpoint := wire.OutPoint{Hash: closeTx.TxHash(), Index: 3}
@ -501,7 +501,7 @@ func runMultiHopReceiverChainClaim(ht *lntest.HarnessTest,
// At this point, Carol should broadcast her active commitment // At this point, Carol should broadcast her active commitment
// transaction in order to go to the chain and sweep her HTLC. // transaction in order to go to the chain and sweep her HTLC.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
closingTx := ht.Miner.AssertOutpointInMempool( closingTx := ht.Miner.AssertOutpointInMempool(
ht.OutPointFromChannelPoint(bobChanPoint), ht.OutPointFromChannelPoint(bobChanPoint),
@ -526,7 +526,7 @@ func runMultiHopReceiverChainClaim(ht *lntest.HarnessTest,
// scenarios, as we are using a wallet utxo, which means any txns using // scenarios, as we are using a wallet utxo, which means any txns using
// that wallet utxo must pay more fees. On the other hand, there's no // that wallet utxo must pay more fees. On the other hand, there's no
// way to remove that anchor-CPFP tx from the mempool. // way to remove that anchor-CPFP tx from the mempool.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// After the force close transaction is mined, Carol should offer her // After the force close transaction is mined, Carol should offer her
// second level HTLC tx to the sweeper, which means we should see two // second level HTLC tx to the sweeper, which means we should see two
@ -600,7 +600,7 @@ func runMultiHopReceiverChainClaim(ht *lntest.HarnessTest,
ht.MineEmptyBlocks(1) ht.MineEmptyBlocks(1)
// We should have a new transaction in the mempool. // We should have a new transaction in the mempool.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// Finally, if we mine an additional block to confirm Carol's second // Finally, if we mine an additional block to confirm Carol's second
// level success transaction. Carol should not show a pending channel // level success transaction. Carol should not show a pending channel
@ -761,7 +761,7 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
) )
txid := commitSweepTx.TxHash() txid := commitSweepTx.TxHash()
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, &txid) ht.AssertTxInBlock(block, &txid)
blocksMined++ blocksMined++
} }
@ -789,7 +789,7 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
// Next, we'll mine an additional block. This should serve to confirm // Next, we'll mine an additional block. This should serve to confirm
// the second layer timeout transaction. // the second layer timeout transaction.
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, &timeoutTx) ht.AssertTxInBlock(block, &timeoutTx)
// With the second layer timeout transaction confirmed, Bob should have // With the second layer timeout transaction confirmed, Bob should have
// canceled backwards the HTLC that carol sent. // canceled backwards the HTLC that carol sent.
@ -1007,12 +1007,12 @@ func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
// Bob's sweeping transaction should now be found in the mempool at // Bob's sweeping transaction should now be found in the mempool at
// this point. // this point.
sweepTx := ht.Miner.AssertNumTxsInMempool(1)[0] sweepTx := ht.AssertNumTxsInMempool(1)[0]
// If we mine an additional block, then this should confirm Bob's // If we mine an additional block, then this should confirm Bob's
// transaction which sweeps the direct HTLC output. // transaction which sweeps the direct HTLC output.
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, sweepTx) ht.AssertTxInBlock(block, sweepTx)
// Now that the sweeping transaction has been confirmed, Bob should // Now that the sweeping transaction has been confirmed, Bob should
// cancel back that HTLC. As a result, Alice should not know of any // cancel back that HTLC. As a result, Alice should not know of any
@ -1047,7 +1047,7 @@ func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
) )
bobCommitSweepTxid := bobCommitSweep.TxHash() bobCommitSweepTxid := bobCommitSweep.TxHash()
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, &bobCommitSweepTxid) ht.AssertTxInBlock(block, &bobCommitSweepTxid)
} }
ht.AssertNumPendingForceClose(bob, 0) ht.AssertNumPendingForceClose(bob, 0)
@ -1191,7 +1191,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
blocksMined++ blocksMined++
// Assert the expected num of txns are found in the mempool. // Assert the expected num of txns are found in the mempool.
ht.Miner.AssertNumTxsInMempool(expectedTxes) ht.AssertNumTxsInMempool(expectedTxes)
// Mine a block to clean up the mempool for the rest of the test. // Mine a block to clean up the mempool for the rest of the test.
ht.MineBlocksAndAssertNumTxes(1, expectedTxes) ht.MineBlocksAndAssertNumTxes(1, expectedTxes)
@ -1215,7 +1215,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
ht.MineEmptyBlocks(int(numBlocks - blocksMined)) ht.MineEmptyBlocks(int(numBlocks - blocksMined))
// Carol's commitment transaction should now be in the mempool. // Carol's commitment transaction should now be in the mempool.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// Look up the closing transaction. It should be spending from the // Look up the closing transaction. It should be spending from the
// funding transaction, // funding transaction,
@ -1226,7 +1226,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
// Mine a block that should confirm the commit tx. // Mine a block that should confirm the commit tx.
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, &closingTxid) ht.AssertTxInBlock(block, &closingTxid)
// After the force close transaction is mined, Carol should offer her // After the force close transaction is mined, Carol should offer her
// second-level success HTLC tx and anchor to the sweeper. // second-level success HTLC tx and anchor to the sweeper.
@ -1273,7 +1273,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
ht.MineEmptyBlocks(1) ht.MineEmptyBlocks(1)
// Assert transactions can be found in the mempool. // Assert transactions can be found in the mempool.
ht.Miner.AssertNumTxsInMempool(expectedTxes) ht.AssertNumTxsInMempool(expectedTxes)
// At this point we suspend Alice to make sure she'll handle the // At this point we suspend Alice to make sure she'll handle the
// on-chain settle after a restart. // on-chain settle after a restart.
@ -1345,7 +1345,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
bobSecondLevelCSV-- bobSecondLevelCSV--
// Carol's sweep tx should be broadcast. // Carol's sweep tx should be broadcast.
carolSweep := ht.Miner.AssertNumTxsInMempool(1)[0] carolSweep := ht.AssertNumTxsInMempool(1)[0]
// Bob should offer his second level tx to his sweeper. // Bob should offer his second level tx to his sweeper.
ht.AssertNumPendingSweeps(bob, 1) ht.AssertNumPendingSweeps(bob, 1)
@ -1353,7 +1353,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
// Mining one additional block, Bob's second level tx is mature, and he // Mining one additional block, Bob's second level tx is mature, and he
// can sweep the output. // can sweep the output.
block = ht.MineBlocksAndAssertNumTxes(bobSecondLevelCSV, 1)[0] block = ht.MineBlocksAndAssertNumTxes(bobSecondLevelCSV, 1)[0]
ht.Miner.AssertTxInBlock(block, carolSweep) ht.AssertTxInBlock(block, carolSweep)
bobSweep := ht.Miner.GetNumTxsFromMempool(1)[0] bobSweep := ht.Miner.GetNumTxsFromMempool(1)[0]
bobSweepTxid := bobSweep.TxHash() bobSweepTxid := bobSweep.TxHash()
@ -1362,7 +1362,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
// Now Bob should have no pending channels anymore, as this just // Now Bob should have no pending channels anymore, as this just
// resolved it by the confirmation of the sweep transaction. // resolved it by the confirmation of the sweep transaction.
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0] block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, &bobSweepTxid) ht.AssertTxInBlock(block, &bobSweepTxid)
// With the script-enforced lease commitment type, Alice and Bob still // With the script-enforced lease commitment type, Alice and Bob still
// haven't been able to sweep their respective commit outputs due to the // haven't been able to sweep their respective commit outputs due to the
@ -1558,7 +1558,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
ht.MineEmptyBlocks(int(numBlocks) - blocksMined) ht.MineEmptyBlocks(int(numBlocks) - blocksMined)
// Carol's commitment transaction should now be in the mempool. // Carol's commitment transaction should now be in the mempool.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// The closing transaction should be spending from the funding // The closing transaction should be spending from the funding
// transaction. // transaction.
@ -1574,7 +1574,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
// Mine a block, which should contain: the commitment. // Mine a block, which should contain: the commitment.
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, &closingTxid) ht.AssertTxInBlock(block, &closingTxid)
// After the force close transaction is mined, Carol should offer her // After the force close transaction is mined, Carol should offer her
// second level HTLC tx to the sweeper, along with her anchor output. // second level HTLC tx to the sweeper, along with her anchor output.
@ -1612,7 +1612,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
// anchor sweeping. // anchor sweeping.
ht.MineBlocksAndAssertNumTxes(1, 1) ht.MineBlocksAndAssertNumTxes(1, 1)
carolSecondLevelCSV-- carolSecondLevelCSV--
ht.Miner.AssertNumTxsInMempool(2) ht.AssertNumTxsInMempool(2)
// Mine a block to confirm the expected transactions. // Mine a block to confirm the expected transactions.
ht.MineBlocksAndAssertNumTxes(1, 2) ht.MineBlocksAndAssertNumTxes(1, 2)
@ -1633,7 +1633,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
// We'll now mine a block which should confirm Bob's HTLC sweep // We'll now mine a block which should confirm Bob's HTLC sweep
// transaction. // transaction.
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0] block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, &bobHtlcSweepTxid) ht.AssertTxInBlock(block, &bobHtlcSweepTxid)
carolSecondLevelCSV-- carolSecondLevelCSV--
// Now that the sweeping transaction has been confirmed, Bob should now // Now that the sweeping transaction has been confirmed, Bob should now
@ -1656,12 +1656,12 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
// Mine a block to trigger the sweep of the second level tx. // Mine a block to trigger the sweep of the second level tx.
ht.MineEmptyBlocks(1) ht.MineEmptyBlocks(1)
carolSweep := ht.Miner.AssertNumTxsInMempool(1)[0] carolSweep := ht.AssertNumTxsInMempool(1)[0]
// When Carol's sweep gets confirmed, she should have no more pending // When Carol's sweep gets confirmed, she should have no more pending
// channels. // channels.
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0] block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, carolSweep) ht.AssertTxInBlock(block, carolSweep)
ht.AssertNumPendingForceClose(carol, 0) ht.AssertNumPendingForceClose(carol, 0)
// With the script-enforced lease commitment type, Alice and Bob still // With the script-enforced lease commitment type, Alice and Bob still
@ -1881,7 +1881,7 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
// Bob's force close transaction should now be found in the mempool. If // Bob's force close transaction should now be found in the mempool. If
// there are anchors, we expect it to be offered to Bob's sweeper. // there are anchors, we expect it to be offered to Bob's sweeper.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// Bob has two anchor sweep requests, one for remote (invalid) and the // Bob has two anchor sweep requests, one for remote (invalid) and the
// other for local. // other for local.
@ -1925,7 +1925,7 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
ht.MineBlocksAndAssertNumTxes(1, 1) ht.MineBlocksAndAssertNumTxes(1, 1)
// The above mined block will trigger Bob to sweep his anchor output. // The above mined block will trigger Bob to sweep his anchor output.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// Let Alice settle her invoices. When Bob now gets the preimages, he // Let Alice settle her invoices. When Bob now gets the preimages, he
// has no other option than to broadcast his second-level transactions // has no other option than to broadcast his second-level transactions
@ -2162,7 +2162,7 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
// level sweep. Now Bob should have no pending channels anymore, as // level sweep. Now Bob should have no pending channels anymore, as
// this just resolved it by the confirmation of the sweep transaction. // this just resolved it by the confirmation of the sweep transaction.
block := ht.MineBlocksAndAssertNumTxes(1, numExpected)[0] block := ht.MineBlocksAndAssertNumTxes(1, numExpected)[0]
ht.Miner.AssertTxInBlock(block, &bobSweep) ht.AssertTxInBlock(block, &bobSweep)
// For leased channels, we need to mine one more block to confirm Bob's // For leased channels, we need to mine one more block to confirm Bob's
// commit output sweep. // commit output sweep.
@ -2441,7 +2441,7 @@ func runExtraPreimageFromRemoteCommit(ht *lntest.HarnessTest,
// Mine a block to trigger the sweep, and clean up the anchor sweeping // Mine a block to trigger the sweep, and clean up the anchor sweeping
// tx. // tx.
ht.MineBlocksAndAssertNumTxes(1, 1) ht.MineBlocksAndAssertNumTxes(1, 1)
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// Restart Bob. Once he finishes syncing the channel state, he should // Restart Bob. Once he finishes syncing the channel state, he should
// notice the force close from Carol. // notice the force close from Carol.
@ -2457,7 +2457,7 @@ func runExtraPreimageFromRemoteCommit(ht *lntest.HarnessTest,
// We should now have Carol's htlc success tx in the mempool. // We should now have Carol's htlc success tx in the mempool.
numTxesMempool := 1 numTxesMempool := 1
ht.Miner.AssertNumTxsInMempool(numTxesMempool) ht.AssertNumTxsInMempool(numTxesMempool)
// For neutrino backend, the timeout resolver needs to extract the // For neutrino backend, the timeout resolver needs to extract the
// preimage from the blocks. // preimage from the blocks.
@ -2667,15 +2667,15 @@ func runExtraPreimageFromLocalCommit(ht *lntest.HarnessTest,
switch c { switch c {
case lnrpc.CommitmentType_LEGACY: case lnrpc.CommitmentType_LEGACY:
htlcOutpoint.Index = 0 htlcOutpoint.Index = 0
ht.Miner.AssertNumTxsInMempool(2) ht.AssertNumTxsInMempool(2)
case lnrpc.CommitmentType_ANCHORS, lnrpc.CommitmentType_SIMPLE_TAPROOT: case lnrpc.CommitmentType_ANCHORS, lnrpc.CommitmentType_SIMPLE_TAPROOT:
htlcOutpoint.Index = 2 htlcOutpoint.Index = 2
ht.Miner.AssertNumTxsInMempool(2) ht.AssertNumTxsInMempool(2)
case lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE: case lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE:
htlcOutpoint.Index = 2 htlcOutpoint.Index = 2
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
} }
// Get the current height to compute number of blocks to mine to // Get the current height to compute number of blocks to mine to

View File

@ -96,7 +96,7 @@ func testNonStdSweepInner(ht *lntest.HarnessTest, address string) {
carol.RPC.SendCoins(sendReq) carol.RPC.SendCoins(sendReq)
// Fetch the txid so we can grab the raw transaction. // Fetch the txid so we can grab the raw transaction.
txid := ht.Miner.AssertNumTxsInMempool(1)[0] txid := ht.AssertNumTxsInMempool(1)[0]
tx := ht.Miner.GetRawTransaction(txid) tx := ht.Miner.GetRawTransaction(txid)
msgTx := tx.MsgTx() msgTx := tx.MsgTx()

View File

@ -717,7 +717,7 @@ func testRemoveTx(ht *lntest.HarnessTest) {
TargetConf: 6, TargetConf: 6,
} }
alice.RPC.SendCoins(sendReq) alice.RPC.SendCoins(sendReq)
txID := ht.Miner.AssertNumTxsInMempool(1)[0] txID := ht.AssertNumTxsInMempool(1)[0]
// Make sure the unspent number of utxos is 2 and the unconfirmed // Make sure the unspent number of utxos is 2 and the unconfirmed
// balances add up. // balances add up.
@ -767,7 +767,7 @@ func testRemoveTx(ht *lntest.HarnessTest) {
// shows up in alice's wallet although we removed the transaction from // shows up in alice's wallet although we removed the transaction from
// the wallet when it was unconfirmed. // the wallet when it was unconfirmed.
block := ht.Miner.MineBlocks(1)[0] block := ht.Miner.MineBlocks(1)[0]
ht.Miner.AssertTxInBlock(block, txID) ht.AssertTxInBlock(block, txID)
// Verify that alice has 2 confirmed unspent utxos in her default // Verify that alice has 2 confirmed unspent utxos in her default
// wallet. // wallet.
@ -861,7 +861,7 @@ func testListSweeps(ht *lntest.HarnessTest) {
ht.MineEmptyBlocks(1) ht.MineEmptyBlocks(1)
// Now we can expect that the sweep has been broadcast. // Now we can expect that the sweep has been broadcast.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// List all unconfirmed sweeps that alice's node had broadcast. // List all unconfirmed sweeps that alice's node had broadcast.
sweepResp := alice.RPC.ListSweeps(false, -1) sweepResp := alice.RPC.ListSweeps(false, -1)

View File

@ -45,7 +45,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
// Wait for miner to have seen the funding tx. The temporary miner is // Wait for miner to have seen the funding tx. The temporary miner is
// disconnected, and won't see the transaction. // disconnected, and won't see the transaction.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// At this point, the channel's funding transaction will have been // At this point, the channel's funding transaction will have been
// broadcast, but not confirmed, and the channel should be pending. // broadcast, but not confirmed, and the channel should be pending.
@ -59,7 +59,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
// channel on the original miner's chain, which should be considered // channel on the original miner's chain, which should be considered
// open. // open.
block := ht.MineBlocksAndAssertNumTxes(10, 1)[0] block := ht.MineBlocksAndAssertNumTxes(10, 1)[0]
ht.Miner.AssertTxInBlock(block, fundingTxID) ht.AssertTxInBlock(block, fundingTxID)
_, err = tempMiner.Client.Generate(15) _, err = tempMiner.Client.Generate(15)
require.NoError(ht, err, "unable to generate blocks") require.NoError(ht, err, "unable to generate blocks")
@ -115,7 +115,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
// Cleanup by mining the funding tx again, then closing the channel. // Cleanup by mining the funding tx again, then closing the channel.
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0] block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, fundingTxID) ht.AssertTxInBlock(block, fundingTxID)
ht.CloseChannel(alice, chanPoint) ht.CloseChannel(alice, chanPoint)
} }

View File

@ -261,7 +261,7 @@ func runPsbtChanFunding(ht *lntest.HarnessTest, carol, dave *node.HarnessNode,
} }
// No transaction should have been published yet. // No transaction should have been published yet.
ht.Miner.AssertNumTxsInMempool(0) ht.AssertNumTxsInMempool(0)
// Let's progress the second channel now. This time we'll use the raw // Let's progress the second channel now. This time we'll use the raw
// wire format transaction directly. // wire format transaction directly.
@ -295,7 +295,7 @@ func runPsbtChanFunding(ht *lntest.HarnessTest, carol, dave *node.HarnessNode,
txHash := finalTx.TxHash() txHash := finalTx.TxHash()
block := ht.MineBlocksAndAssertNumTxes(6, 1)[0] block := ht.MineBlocksAndAssertNumTxes(6, 1)[0]
ht.Miner.AssertTxInBlock(block, &txHash) ht.AssertTxInBlock(block, &txHash)
ht.AssertTopologyChannelOpen(carol, chanPoint) ht.AssertTopologyChannelOpen(carol, chanPoint)
ht.AssertTopologyChannelOpen(carol, chanPoint2) ht.AssertTopologyChannelOpen(carol, chanPoint2)
@ -456,7 +456,7 @@ func runPsbtChanFundingExternal(ht *lntest.HarnessTest, carol,
finalizeRes := alice.RPC.FinalizePsbt(finalizeReq) finalizeRes := alice.RPC.FinalizePsbt(finalizeReq)
// No transaction should have been published yet. // No transaction should have been published yet.
ht.Miner.AssertNumTxsInMempool(0) ht.AssertNumTxsInMempool(0)
// Great, now let's publish the final raw transaction. // Great, now let's publish the final raw transaction.
var finalTx wire.MsgTx var finalTx wire.MsgTx
@ -470,7 +470,7 @@ func runPsbtChanFundingExternal(ht *lntest.HarnessTest, carol,
// Now we can mine a block to get the transaction confirmed, then wait // Now we can mine a block to get the transaction confirmed, then wait
// for the new channel to be propagated through the network. // for the new channel to be propagated through the network.
block := ht.MineBlocksAndAssertNumTxes(6, 1)[0] block := ht.MineBlocksAndAssertNumTxes(6, 1)[0]
ht.Miner.AssertTxInBlock(block, &txHash) ht.AssertTxInBlock(block, &txHash)
ht.AssertTopologyChannelOpen(carol, chanPoint) ht.AssertTopologyChannelOpen(carol, chanPoint)
ht.AssertTopologyChannelOpen(carol, chanPoint2) ht.AssertTopologyChannelOpen(carol, chanPoint2)
@ -627,7 +627,7 @@ func runPsbtChanFundingSingleStep(ht *lntest.HarnessTest, carol,
txHash := finalTx.TxHash() txHash := finalTx.TxHash()
block := ht.MineBlocksAndAssertNumTxes(6, 1)[0] block := ht.MineBlocksAndAssertNumTxes(6, 1)[0]
ht.Miner.AssertTxInBlock(block, &txHash) ht.AssertTxInBlock(block, &txHash)
ht.AssertTopologyChannelOpen(carol, chanPoint) ht.AssertTopologyChannelOpen(carol, chanPoint)
// Next, to make sure the channel functions as normal, we'll make some // Next, to make sure the channel functions as normal, we'll make some
@ -1326,7 +1326,7 @@ func extractPublishAndMine(ht *lntest.HarnessTest, node *node.HarnessNode,
// Mine one block which should contain two transactions. // Mine one block which should contain two transactions.
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
txHash := finalTx.TxHash() txHash := finalTx.TxHash()
ht.Miner.AssertTxInBlock(block, &txHash) ht.AssertTxInBlock(block, &txHash)
return finalTx return finalTx
} }
@ -1432,8 +1432,8 @@ func assertPsbtSpend(ht *lntest.HarnessTest, alice *node.HarnessNode,
block := ht.MineBlocksAndAssertNumTxes(1, 2)[0] block := ht.MineBlocksAndAssertNumTxes(1, 2)[0]
firstTxHash := prevTx.TxHash() firstTxHash := prevTx.TxHash()
secondTxHash := finalTx.TxHash() secondTxHash := finalTx.TxHash()
ht.Miner.AssertTxInBlock(block, &firstTxHash) ht.AssertTxInBlock(block, &firstTxHash)
ht.Miner.AssertTxInBlock(block, &secondTxHash) ht.AssertTxInBlock(block, &secondTxHash)
} }
// assertPsbtFundSignSpend funds a PSBT from the internal wallet and then // assertPsbtFundSignSpend funds a PSBT from the internal wallet and then
@ -1794,7 +1794,7 @@ func testPsbtChanFundingWithUnstableUtxos(ht *lntest.HarnessTest) {
txHash := finalTx.TxHash() txHash := finalTx.TxHash()
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, &txHash) ht.AssertTxInBlock(block, &txHash)
// Now we do the same but instead use preselected utxos to verify that // Now we do the same but instead use preselected utxos to verify that
// these utxos respects the utxo restrictions on sweeper unconfirmed // these utxos respects the utxo restrictions on sweeper unconfirmed
@ -1941,7 +1941,7 @@ func testPsbtChanFundingWithUnstableUtxos(ht *lntest.HarnessTest) {
txHash = finalTx.TxHash() txHash = finalTx.TxHash()
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0] block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, &txHash) ht.AssertTxInBlock(block, &txHash)
ht.CloseChannel(carol, channelPoint3) ht.CloseChannel(carol, channelPoint3)
} }

View File

@ -260,11 +260,11 @@ func testOnchainFundRecovery(ht *lntest.HarnessTest) {
} }
resp := node.RPC.SendCoins(req) resp := node.RPC.SendCoins(req)
txid := ht.Miner.AssertNumTxsInMempool(1)[0] txid := ht.AssertNumTxsInMempool(1)[0]
require.Equal(ht, txid.String(), resp.Txid) require.Equal(ht, txid.String(), resp.Txid)
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, txid) ht.AssertTxInBlock(block, txid)
} }
restoreCheckBalance(finalBalance, 9, 20, promptChangeAddr) restoreCheckBalance(finalBalance, 9, 20, promptChangeAddr)
@ -428,7 +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.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
ht.MineBlocks(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

View File

@ -122,7 +122,7 @@ func breachRetributionTestCase(ht *lntest.HarnessTest,
// update, then ensure that the closing transaction was included in the // update, then ensure that the closing transaction was included in the
// block. // block.
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.Miner.AssertTxInBlock(block, breachTXID) ht.AssertTxInBlock(block, breachTXID)
// Construct to_remote output which pays to Bob. Based on the output // Construct to_remote output which pays to Bob. Based on the output
// ordering, the first output in this breach tx is the to_remote // ordering, the first output in this breach tx is the to_remote
@ -174,7 +174,7 @@ func breachRetributionTestCase(ht *lntest.HarnessTest,
// transaction which was just accepted into the mempool. // transaction which was just accepted into the mempool.
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0] block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
justiceTxid := justiceTx.TxHash() justiceTxid := justiceTx.TxHash()
ht.Miner.AssertTxInBlock(block, &justiceTxid) ht.AssertTxInBlock(block, &justiceTxid)
ht.AssertNodeNumChannels(carol, 0) ht.AssertNodeNumChannels(carol, 0)
@ -363,7 +363,7 @@ func revokedCloseRetributionZeroValueRemoteOutputCase(ht *lntest.HarnessTest,
// transaction which was just accepted into the mempool. // transaction which was just accepted into the mempool.
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
justiceTxid := justiceTx.TxHash() justiceTxid := justiceTx.TxHash()
ht.Miner.AssertTxInBlock(block, &justiceTxid) ht.AssertTxInBlock(block, &justiceTxid)
// At this point, Dave should have no pending channels. // At this point, Dave should have no pending channels.
ht.AssertNodeNumChannels(dave, 0) ht.AssertNodeNumChannels(dave, 0)
@ -559,7 +559,7 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
breachTXID := ht.WaitForChannelCloseEvent(closeUpdates) breachTXID := ht.WaitForChannelCloseEvent(closeUpdates)
require.Equal(ht, closeTxID[:], breachTXID[:], require.Equal(ht, closeTxID[:], breachTXID[:],
"expected breach ID to be equal to close ID") "expected breach ID to be equal to close ID")
ht.Miner.AssertTxInBlock(block, breachTXID) ht.AssertTxInBlock(block, breachTXID)
// Query the mempool for Dave's justice transaction, this should be // Query the mempool for Dave's justice transaction, this should be
// broadcast as Carol's contract breaching transaction gets confirmed // broadcast as Carol's contract breaching transaction gets confirmed

View File

@ -296,7 +296,7 @@ func assertSignOutputRaw(ht *lntest.HarnessTest,
alice.RPC.SendCoins(req) alice.RPC.SendCoins(req)
// Wait until the TX is found in the mempool. // Wait until the TX is found in the mempool.
txid := ht.Miner.AssertNumTxsInMempool(1)[0] txid := ht.AssertNumTxsInMempool(1)[0]
targetOutputIndex := ht.GetOutputIndex(txid, targetAddr.String()) targetOutputIndex := ht.GetOutputIndex(txid, targetAddr.String())
@ -359,7 +359,7 @@ func assertSignOutputRaw(ht *lntest.HarnessTest,
}) })
// Wait until the spending tx is found. // Wait until the spending tx is found.
txid = ht.Miner.AssertNumTxsInMempool(1)[0] txid = ht.AssertNumTxsInMempool(1)[0]
p2wkhOutputIndex := ht.GetOutputIndex(txid, p2wkhAdrr.String()) p2wkhOutputIndex := ht.GetOutputIndex(txid, p2wkhAdrr.String())
op := &lnrpc.OutPoint{ op := &lnrpc.OutPoint{

View File

@ -266,7 +266,7 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) {
// We expect to see two txns in the mempool, // We expect to see two txns in the mempool,
// - Bob's force close tx. // - Bob's force close tx.
// - Bob's anchor sweep tx. // - Bob's anchor sweep tx.
ht.Miner.AssertNumTxsInMempool(2) ht.AssertNumTxsInMempool(2)
// We expect the fees to increase by i*delta. // We expect the fees to increase by i*delta.
expectedFee := startFeeAnchor + feeDelta.MulF64(float64(i)) expectedFee := startFeeAnchor + feeDelta.MulF64(float64(i))
@ -887,7 +887,7 @@ func testSweepHTLCs(ht *lntest.HarnessTest) {
ht.AssertNumPendingSweeps(bob, 2) ht.AssertNumPendingSweeps(bob, 2)
// Assert Bob's force closing tx has been broadcast. // Assert Bob's force closing tx has been broadcast.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// Mine the force close tx, which triggers Bob's contractcourt to offer // Mine the force close tx, which triggers Bob's contractcourt to offer
// his outgoing HTLC to his sweeper. // his outgoing HTLC to his sweeper.
@ -982,7 +982,7 @@ func testSweepHTLCs(ht *lntest.HarnessTest) {
outgoingFuncPosition++ outgoingFuncPosition++
// We should see Bob's sweeping tx in the mempool. // We should see Bob's sweeping tx in the mempool.
ht.Miner.AssertNumTxsInMempool(1) ht.AssertNumTxsInMempool(1)
// Make sure Bob's old sweeping tx has been removed from the // Make sure Bob's old sweeping tx has been removed from the
// mempool. // mempool.
@ -1156,7 +1156,7 @@ func testSweepHTLCs(ht *lntest.HarnessTest) {
// We should see two txns in the mempool, // We should see two txns in the mempool,
// - the incoming HTLC sweeping tx. // - the incoming HTLC sweeping tx.
// - the outgoing HTLC sweeping tx. // - the outgoing HTLC sweeping tx.
ht.Miner.AssertNumTxsInMempool(2) ht.AssertNumTxsInMempool(2)
// Make sure Bob's old sweeping txns have been removed from the // Make sure Bob's old sweeping txns have been removed from the
// mempool. // mempool.
@ -1600,7 +1600,7 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
// We expect to see both Alice's and Bob's sweeping txns in the // We expect to see both Alice's and Bob's sweeping txns in the
// mempool. // mempool.
ht.Miner.AssertNumTxsInMempool(2) ht.AssertNumTxsInMempool(2)
// Make sure Alice's old sweeping tx has been removed from the // Make sure Alice's old sweeping tx has been removed from the
// mempool. // mempool.
@ -1687,7 +1687,7 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
// We expect to see both Alice's and Bob's sweeping txns in the // We expect to see both Alice's and Bob's sweeping txns in the
// mempool. // mempool.
ht.Miner.AssertNumTxsInMempool(2) ht.AssertNumTxsInMempool(2)
// Make sure Alice's old sweeping tx has been removed from the // Make sure Alice's old sweeping tx has been removed from the
// mempool. // mempool.

View File

@ -107,7 +107,7 @@ func testTaprootSendCoinsKeySpendBip86(ht *lntest.HarnessTest,
TargetConf: 6, TargetConf: 6,
}) })
txid := ht.Miner.AssertNumTxsInMempool(1)[0] txid := ht.AssertNumTxsInMempool(1)[0]
// Wait until bob has seen the tx and considers it as owned. // Wait until bob has seen the tx and considers it as owned.
p2trOutputIndex := ht.GetOutputIndex(txid, p2trResp.Address) p2trOutputIndex := ht.GetOutputIndex(txid, p2trResp.Address)
@ -162,7 +162,7 @@ func testTaprootComputeInputScriptKeySpendBip86(ht *lntest.HarnessTest,
alice.RPC.SendCoins(req) alice.RPC.SendCoins(req)
// Wait until bob has seen the tx and considers it as owned. // Wait until bob has seen the tx and considers it as owned.
txid := ht.Miner.AssertNumTxsInMempool(1)[0] txid := ht.AssertNumTxsInMempool(1)[0]
p2trOutputIndex := ht.GetOutputIndex(txid, p2trAddr.String()) p2trOutputIndex := ht.GetOutputIndex(txid, p2trAddr.String())
op := &lnrpc.OutPoint{ op := &lnrpc.OutPoint{
TxidBytes: txid[:], TxidBytes: txid[:],
@ -1413,7 +1413,7 @@ func clearWalletImportedTapscriptBalance(ht *lntest.HarnessTest,
// Mine one block which should contain the sweep transaction. // Mine one block which should contain the sweep transaction.
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
sweepTxHash := sweepTx.TxHash() sweepTxHash := sweepTx.TxHash()
ht.Miner.AssertTxInBlock(block, &sweepTxHash) ht.AssertTxInBlock(block, &sweepTxHash)
} }
// testScriptHashLock returns a simple bitcoin script that locks the funds to // testScriptHashLock returns a simple bitcoin script that locks the funds to
@ -1481,7 +1481,7 @@ func sendToTaprootOutput(ht *lntest.HarnessTest, hn *node.HarnessNode,
hn.RPC.SendCoins(req) hn.RPC.SendCoins(req)
// Wait until the TX is found in the mempool. // Wait until the TX is found in the mempool.
txid := ht.Miner.AssertNumTxsInMempool(1)[0] txid := ht.AssertNumTxsInMempool(1)[0]
p2trOutputIndex := ht.GetOutputIndex(txid, tapScriptAddr.String()) p2trOutputIndex := ht.GetOutputIndex(txid, tapScriptAddr.String())
p2trOutpoint := wire.OutPoint{ p2trOutpoint := wire.OutPoint{
Hash: *txid, Hash: *txid,
@ -1592,7 +1592,7 @@ func confirmAddress(ht *lntest.HarnessTest, hn *node.HarnessNode,
addrString string) { addrString string) {
// Wait until the tx that sends to the address is found. // Wait until the tx that sends to the address is found.
txid := ht.Miner.AssertNumTxsInMempool(1)[0] txid := ht.AssertNumTxsInMempool(1)[0]
// Wait until bob has seen the tx and considers it as owned. // Wait until bob has seen the tx and considers it as owned.
addrOutputIndex := ht.GetOutputIndex(txid, addrString) addrOutputIndex := ht.GetOutputIndex(txid, addrString)

View File

@ -372,7 +372,7 @@ func fundChanAndCloseFromImportedAccount(ht *lntest.HarnessTest, srcNode,
) )
block := ht.MineBlocksAndAssertNumTxes(6, 1)[0] block := ht.MineBlocksAndAssertNumTxes(6, 1)[0]
ht.Miner.AssertTxInBlock(block, txHash) ht.AssertTxInBlock(block, txHash)
confBalanceAfterChan += chanChangeUtxoAmt confBalanceAfterChan += chanChangeUtxoAmt
ht.AssertWalletAccountBalance(srcNode, account, 0, 0) ht.AssertWalletAccountBalance(srcNode, account, 0, 0)
@ -389,7 +389,7 @@ func fundChanAndCloseFromImportedAccount(ht *lntest.HarnessTest, srcNode,
) )
block := ht.MineBlocksAndAssertNumTxes(6, 1)[0] block := ht.MineBlocksAndAssertNumTxes(6, 1)[0]
ht.Miner.AssertTxInBlock(block, txHash) ht.AssertTxInBlock(block, txHash)
confBalanceAfterChan += chanChangeUtxoAmt confBalanceAfterChan += chanChangeUtxoAmt
ht.AssertWalletAccountBalance( ht.AssertWalletAccountBalance(

View File

@ -502,7 +502,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
breachTXID := ht.WaitForChannelCloseEvent(closeUpdates) breachTXID := ht.WaitForChannelCloseEvent(closeUpdates)
ht.Miner.AssertTxInBlock(block, breachTXID) ht.AssertTxInBlock(block, breachTXID)
// The breachTXID should match the above closeTxID. // The breachTXID should match the above closeTxID.
require.EqualValues(ht, breachTXID, closeTxID) require.EqualValues(ht, breachTXID, closeTxID)
@ -510,7 +510,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
// Query the mempool for Dave's justice transaction, this should be // Query the mempool for Dave's justice transaction, this should be
// broadcast as Carol's contract breaching transaction gets confirmed // broadcast as Carol's contract breaching transaction gets confirmed
// above. // above.
justiceTXID := ht.Miner.AssertNumTxsInMempool(1)[0] justiceTXID := ht.AssertNumTxsInMempool(1)[0]
// Query for the mempool transaction found above. Then assert that all // Query for the mempool transaction found above. Then assert that all
// the inputs of this transaction are spending outputs generated by // the inputs of this transaction are spending outputs generated by

View File

@ -110,7 +110,7 @@ func testZeroConfChannelOpen(ht *lntest.HarnessTest) {
fundingTxID := ht.GetChanPointFundingTxid(fundingPoint2) fundingTxID := ht.GetChanPointFundingTxid(fundingPoint2)
ht.Miner.AssertTxInBlock(block, fundingTxID) ht.AssertTxInBlock(block, fundingTxID)
daveInvoiceResp3 := dave.RPC.AddInvoice(daveInvoiceParams) daveInvoiceResp3 := dave.RPC.AddInvoice(daveInvoiceParams)
ht.CompletePaymentRequests( ht.CompletePaymentRequests(
@ -159,7 +159,7 @@ func testZeroConfChannelOpen(ht *lntest.HarnessTest) {
block = ht.MineBlocksAndAssertNumTxes(6, 1)[0] block = ht.MineBlocksAndAssertNumTxes(6, 1)[0]
fundingTxID = ht.GetChanPointFundingTxid(fundingPoint3) fundingTxID = ht.GetChanPointFundingTxid(fundingPoint3)
ht.Miner.AssertTxInBlock(block, fundingTxID) ht.AssertTxInBlock(block, fundingTxID)
// Wait until Eve's ZeroConf channel is replaced by the confirmed SCID // Wait until Eve's ZeroConf channel is replaced by the confirmed SCID
// in her graph. // in her graph.

View File

@ -1193,7 +1193,7 @@ func (h *HarnessTest) openChannel(alice, bob *node.HarnessNode,
// Check that the funding tx is found in the first block. // Check that the funding tx is found in the first block.
fundingTxID := h.GetChanPointFundingTxid(fundingChanPoint) fundingTxID := h.GetChanPointFundingTxid(fundingChanPoint)
h.Miner.AssertTxInBlock(block, fundingTxID) h.AssertTxInBlock(block, fundingTxID)
// Check that both alice and bob have seen the channel from their // Check that both alice and bob have seen the channel from their
// network topology. // network topology.

View File

@ -656,7 +656,7 @@ func (h *HarnessTest) AssertStreamChannelCoopClosed(hn *node.HarnessNode,
// Consume one close event and assert the closing txid can be found in // Consume one close event and assert the closing txid can be found in
// the block. // the block.
closingTxid := h.WaitForChannelCloseEvent(stream) closingTxid := h.WaitForChannelCloseEvent(stream)
h.Miner.AssertTxInBlock(block, closingTxid) h.AssertTxInBlock(block, closingTxid)
// We should see zero waiting close channels now. // We should see zero waiting close channels now.
h.AssertNumWaitingClose(hn, 0) h.AssertNumWaitingClose(hn, 0)
@ -700,7 +700,7 @@ func (h *HarnessTest) AssertStreamChannelForceClosed(hn *node.HarnessNode,
// Consume one close event and assert the closing txid can be found in // Consume one close event and assert the closing txid can be found in
// the block. // the block.
closingTxid := h.WaitForChannelCloseEvent(stream) closingTxid := h.WaitForChannelCloseEvent(stream)
h.Miner.AssertTxInBlock(block, closingTxid) h.AssertTxInBlock(block, closingTxid)
// We should see zero waiting close channels and 1 pending force close // We should see zero waiting close channels and 1 pending force close
// channels now. // channels now.
@ -2564,7 +2564,7 @@ func (h *HarnessTest) AssertClosingTxInMempool(cp *lnrpc.ChannelPoint,
} }
// Wait for the expected txes to be found in the mempool. // Wait for the expected txes to be found in the mempool.
h.Miner.AssertNumTxsInMempool(expectedTxes) h.AssertNumTxsInMempool(expectedTxes)
// Get the closing tx from the mempool. // Get the closing tx from the mempool.
op := h.OutPointFromChannelPoint(cp) op := h.OutPointFromChannelPoint(cp)
@ -2578,7 +2578,7 @@ func (h *HarnessTest) AssertClosingTxInMempool(cp *lnrpc.ChannelPoint,
// will assert the anchor sweep tx is also in the mempool. // will assert the anchor sweep tx is also in the mempool.
func (h *HarnessTest) MineClosingTx(cp *lnrpc.ChannelPoint) *wire.MsgTx { func (h *HarnessTest) MineClosingTx(cp *lnrpc.ChannelPoint) *wire.MsgTx {
// Wait for the expected txes to be found in the mempool. // Wait for the expected txes to be found in the mempool.
h.Miner.AssertNumTxsInMempool(1) h.AssertNumTxsInMempool(1)
// Get the closing tx from the mempool. // Get the closing tx from the mempool.
op := h.OutPointFromChannelPoint(cp) op := h.OutPointFromChannelPoint(cp)

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/lntest/node" "github.com/lightningnetwork/lnd/lntest/node"
"github.com/lightningnetwork/lnd/lntest/wait" "github.com/lightningnetwork/lnd/lntest/wait"
@ -177,3 +178,17 @@ func (h *HarnessTest) mineTillForceCloseResolved(hn *node.HarnessNode) {
require.NoErrorf(h, err, "assert force close resolved timeout") require.NoErrorf(h, err, "assert force close resolved timeout")
} }
// AssertNumTxsInMempool polls until finding the desired number of transactions
// in the provided miner's mempool. It will asserrt if this number is not met
// after the given timeout.
func (h *HarnessTest) AssertNumTxsInMempool(n int) []*chainhash.Hash {
return h.Miner.AssertNumTxsInMempool(n)
}
// AssertTxInBlock asserts that a given txid can be found in the passed block.
func (h *HarnessTest) AssertTxInBlock(block *wire.MsgBlock,
txid *chainhash.Hash) {
h.Miner.AssertTxInBlock(block, txid)
}