mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-21 22:11:41 +01:00
Merge pull request #9195 from yyforyongyu/optimize-itest-setup
itest+lntest: speed up test setup
This commit is contained in:
commit
f46ae2f893
17 changed files with 134 additions and 102 deletions
|
@ -76,6 +76,10 @@
|
|||
|
||||
* Log rotation can now use ZSTD
|
||||
|
||||
* [A new method](https://github.com/lightningnetwork/lnd/pull/9195)
|
||||
`AssertTxnsNotInMempool` has been added to `lntest` package to allow batch
|
||||
exclusion check in itest.
|
||||
|
||||
# Technical and Architectural Updates
|
||||
## BOLT Spec Updates
|
||||
|
||||
|
|
|
@ -634,7 +634,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
|
|||
// Recorf the HTLC outpoint, such that we can later
|
||||
// check whether it gets swept
|
||||
op := wire.OutPoint{
|
||||
Hash: *htlcTxID,
|
||||
Hash: htlcTxID,
|
||||
Index: uint32(i),
|
||||
}
|
||||
htlcTxOutpointSet[op] = 0
|
||||
|
|
|
@ -117,7 +117,7 @@ func coopCloseWithHTLCs(ht *lntest.HarnessTest) {
|
|||
)
|
||||
|
||||
// Wait for the close tx to be in the Mempool.
|
||||
ht.AssertTxInMempool(&closeTxid)
|
||||
ht.AssertTxInMempool(closeTxid)
|
||||
|
||||
// Wait for it to get mined and finish tearing down.
|
||||
ht.AssertStreamChannelCoopClosed(alice, chanPoint, false, closeClient)
|
||||
|
|
|
@ -874,7 +874,7 @@ func testChannelFundingPersistence(ht *lntest.HarnessTest) {
|
|||
// channel has been opened. The funding transaction should be found
|
||||
// within the newly mined block.
|
||||
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
ht.AssertTxInBlock(block, fundingTxID)
|
||||
ht.AssertTxInBlock(block, *fundingTxID)
|
||||
|
||||
// Get the height that our transaction confirmed at.
|
||||
height := int32(ht.CurrentHeight())
|
||||
|
@ -1067,13 +1067,13 @@ func testBatchChanFunding(ht *lntest.HarnessTest) {
|
|||
|
||||
// Mine the batch transaction and check the network topology.
|
||||
block := ht.MineBlocksAndAssertNumTxes(6, 1)[0]
|
||||
ht.AssertTxInBlock(block, txHash)
|
||||
ht.AssertTxInBlock(block, *txHash)
|
||||
ht.AssertTopologyChannelOpen(alice, chanPoint1)
|
||||
ht.AssertTopologyChannelOpen(alice, chanPoint2)
|
||||
ht.AssertTopologyChannelOpen(alice, chanPoint3)
|
||||
|
||||
// Check if the change type from the batch_open_channel funding is P2TR.
|
||||
rawTx := ht.GetRawTransaction(txHash)
|
||||
rawTx := ht.GetRawTransaction(*txHash)
|
||||
require.Len(ht, rawTx.MsgTx().TxOut, 5)
|
||||
|
||||
// Check the fee rate of the batch-opening transaction. We expect slight
|
||||
|
|
|
@ -736,8 +736,8 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
|
|||
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||
blocksMined++
|
||||
|
||||
htlcOutpoint := wire.OutPoint{Hash: *closeTx, Index: 2}
|
||||
bobCommitOutpoint := wire.OutPoint{Hash: *closeTx, Index: 3}
|
||||
htlcOutpoint := wire.OutPoint{Hash: closeTx, Index: 2}
|
||||
bobCommitOutpoint := wire.OutPoint{Hash: closeTx, Index: 3}
|
||||
|
||||
// Before the HTLC times out, we'll need to assert that Bob broadcasts
|
||||
// a sweep transaction for his commit output. Note that if the channel
|
||||
|
@ -761,7 +761,7 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
|
|||
)
|
||||
txid := commitSweepTx.TxHash()
|
||||
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
ht.AssertTxInBlock(block, &txid)
|
||||
ht.AssertTxInBlock(block, txid)
|
||||
|
||||
blocksMined++
|
||||
}
|
||||
|
@ -789,7 +789,7 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
|
|||
// Next, we'll mine an additional block. This should serve to confirm
|
||||
// the second layer timeout transaction.
|
||||
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
ht.AssertTxInBlock(block, &timeoutTx)
|
||||
ht.AssertTxInBlock(block, timeoutTx)
|
||||
|
||||
// With the second layer timeout transaction confirmed, Bob should have
|
||||
// canceled backwards the HTLC that carol sent.
|
||||
|
@ -1041,13 +1041,13 @@ func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
|
|||
// Mine a block to trigger the sweep.
|
||||
ht.MineEmptyBlocks(1)
|
||||
|
||||
bobCommitOutpoint := wire.OutPoint{Hash: *closeTx, Index: 3}
|
||||
bobCommitOutpoint := wire.OutPoint{Hash: closeTx, Index: 3}
|
||||
bobCommitSweep := ht.AssertOutpointInMempool(
|
||||
bobCommitOutpoint,
|
||||
)
|
||||
bobCommitSweepTxid := bobCommitSweep.TxHash()
|
||||
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
ht.AssertTxInBlock(block, &bobCommitSweepTxid)
|
||||
ht.AssertTxInBlock(block, bobCommitSweepTxid)
|
||||
}
|
||||
ht.AssertNumPendingForceClose(bob, 0)
|
||||
|
||||
|
@ -1226,7 +1226,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
|
|||
|
||||
// Mine a block that should confirm the commit tx.
|
||||
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
ht.AssertTxInBlock(block, &closingTxid)
|
||||
ht.AssertTxInBlock(block, closingTxid)
|
||||
|
||||
// After the force close transaction is mined, Carol should offer her
|
||||
// second-level success HTLC tx and anchor to the sweeper.
|
||||
|
@ -1303,7 +1303,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
|
|||
bobSecondLvlTx := ht.GetNumTxsFromMempool(1)[0]
|
||||
|
||||
// It should spend from the commitment in the channel with Alice.
|
||||
ht.AssertTxSpendFrom(bobSecondLvlTx, *bobForceClose)
|
||||
ht.AssertTxSpendFrom(bobSecondLvlTx, bobForceClose)
|
||||
|
||||
// At this point, Bob should have broadcast his second layer success
|
||||
// transaction, and should have sent it to the nursery for incubation.
|
||||
|
@ -1362,7 +1362,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
|
|||
// Now Bob should have no pending channels anymore, as this just
|
||||
// resolved it by the confirmation of the sweep transaction.
|
||||
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
ht.AssertTxInBlock(block, &bobSweepTxid)
|
||||
ht.AssertTxInBlock(block, bobSweepTxid)
|
||||
|
||||
// With the script-enforced lease commitment type, Alice and Bob still
|
||||
// haven't been able to sweep their respective commit outputs due to the
|
||||
|
@ -1397,7 +1397,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
|
|||
|
||||
// Both Alice and Bob show broadcast their commit sweeps.
|
||||
aliceCommitOutpoint := wire.OutPoint{
|
||||
Hash: *bobForceClose, Index: 3,
|
||||
Hash: bobForceClose, Index: 3,
|
||||
}
|
||||
ht.AssertOutpointInMempool(
|
||||
aliceCommitOutpoint,
|
||||
|
@ -1574,7 +1574,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
|
|||
|
||||
// Mine a block, which should contain: the commitment.
|
||||
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
ht.AssertTxInBlock(block, &closingTxid)
|
||||
ht.AssertTxInBlock(block, closingTxid)
|
||||
|
||||
// After the force close transaction is mined, Carol should offer her
|
||||
// second level HTLC tx to the sweeper, along with her anchor output.
|
||||
|
@ -1628,12 +1628,12 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
|
|||
bobHtlcSweepTxid := bobHtlcSweep.TxHash()
|
||||
|
||||
// It should spend from the commitment in the channel with Alice.
|
||||
ht.AssertTxSpendFrom(bobHtlcSweep, *aliceForceClose)
|
||||
ht.AssertTxSpendFrom(bobHtlcSweep, aliceForceClose)
|
||||
|
||||
// We'll now mine a block which should confirm Bob's HTLC sweep
|
||||
// transaction.
|
||||
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
ht.AssertTxInBlock(block, &bobHtlcSweepTxid)
|
||||
ht.AssertTxInBlock(block, bobHtlcSweepTxid)
|
||||
carolSecondLevelCSV--
|
||||
|
||||
// Now that the sweeping transaction has been confirmed, Bob should now
|
||||
|
@ -1690,7 +1690,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
|
|||
|
||||
// Both Alice and Bob should broadcast their commit sweeps.
|
||||
aliceCommitOutpoint := wire.OutPoint{
|
||||
Hash: *aliceForceClose, Index: 3,
|
||||
Hash: aliceForceClose, Index: 3,
|
||||
}
|
||||
ht.AssertOutpointInMempool(aliceCommitOutpoint)
|
||||
bobCommitOutpoint := wire.OutPoint{Hash: closingTxid, Index: 3}
|
||||
|
@ -2145,7 +2145,7 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
|
|||
// level sweep. Now Bob should have no pending channels anymore, as
|
||||
// this just resolved it by the confirmation of the sweep transaction.
|
||||
block := ht.MineBlocksAndAssertNumTxes(1, numExpected)[0]
|
||||
ht.AssertTxInBlock(block, &bobSweep)
|
||||
ht.AssertTxInBlock(block, bobSweep)
|
||||
|
||||
// For leased channels, we need to mine one more block to confirm Bob's
|
||||
// commit output sweep.
|
||||
|
|
|
@ -111,7 +111,7 @@ func testNonStdSweepInner(ht *lntest.HarnessTest, address string) {
|
|||
for _, inp := range msgTx.TxIn {
|
||||
// Fetch the previous outpoint's value.
|
||||
prevOut := inp.PreviousOutPoint
|
||||
ptx := ht.GetRawTransaction(&prevOut.Hash)
|
||||
ptx := ht.GetRawTransaction(prevOut.Hash)
|
||||
|
||||
pout := ptx.MsgTx().TxOut[prevOut.Index]
|
||||
inputVal += int(pout.Value)
|
||||
|
|
|
@ -60,7 +60,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
|
|||
// channel on the original miner's chain, which should be considered
|
||||
// open.
|
||||
block := ht.MineBlocksAndAssertNumTxes(10, 1)[0]
|
||||
ht.AssertTxInBlock(block, fundingTxID)
|
||||
ht.AssertTxInBlock(block, *fundingTxID)
|
||||
_, err = tempMiner.Client.Generate(15)
|
||||
require.NoError(ht, err, "unable to generate blocks")
|
||||
|
||||
|
@ -116,7 +116,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
|
|||
|
||||
// Cleanup by mining the funding tx again, then closing the channel.
|
||||
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
ht.AssertTxInBlock(block, fundingTxID)
|
||||
ht.AssertTxInBlock(block, *fundingTxID)
|
||||
|
||||
ht.CloseChannel(alice, chanPoint)
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ func runPsbtChanFunding(ht *lntest.HarnessTest, carol, dave *node.HarnessNode,
|
|||
|
||||
txHash := finalTx.TxHash()
|
||||
block := ht.MineBlocksAndAssertNumTxes(6, 1)[0]
|
||||
ht.AssertTxInBlock(block, &txHash)
|
||||
ht.AssertTxInBlock(block, txHash)
|
||||
ht.AssertTopologyChannelOpen(carol, chanPoint)
|
||||
ht.AssertTopologyChannelOpen(carol, chanPoint2)
|
||||
|
||||
|
@ -481,7 +481,7 @@ func runPsbtChanFundingExternal(ht *lntest.HarnessTest, carol,
|
|||
// Now we can mine a block to get the transaction confirmed, then wait
|
||||
// for the new channel to be propagated through the network.
|
||||
block := ht.MineBlocksAndAssertNumTxes(6, 1)[0]
|
||||
ht.AssertTxInBlock(block, &txHash)
|
||||
ht.AssertTxInBlock(block, txHash)
|
||||
ht.AssertTopologyChannelOpen(carol, chanPoint)
|
||||
ht.AssertTopologyChannelOpen(carol, chanPoint2)
|
||||
|
||||
|
@ -638,7 +638,7 @@ func runPsbtChanFundingSingleStep(ht *lntest.HarnessTest, carol,
|
|||
|
||||
txHash := finalTx.TxHash()
|
||||
block := ht.MineBlocksAndAssertNumTxes(6, 1)[0]
|
||||
ht.AssertTxInBlock(block, &txHash)
|
||||
ht.AssertTxInBlock(block, txHash)
|
||||
ht.AssertTopologyChannelOpen(carol, chanPoint)
|
||||
|
||||
// Next, to make sure the channel functions as normal, we'll make some
|
||||
|
@ -1337,7 +1337,7 @@ func extractPublishAndMine(ht *lntest.HarnessTest, node *node.HarnessNode,
|
|||
// Mine one block which should contain two transactions.
|
||||
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
txHash := finalTx.TxHash()
|
||||
ht.AssertTxInBlock(block, &txHash)
|
||||
ht.AssertTxInBlock(block, txHash)
|
||||
|
||||
return finalTx
|
||||
}
|
||||
|
@ -1443,8 +1443,8 @@ func assertPsbtSpend(ht *lntest.HarnessTest, alice *node.HarnessNode,
|
|||
block := ht.MineBlocksAndAssertNumTxes(1, 2)[0]
|
||||
firstTxHash := prevTx.TxHash()
|
||||
secondTxHash := finalTx.TxHash()
|
||||
ht.AssertTxInBlock(block, &firstTxHash)
|
||||
ht.AssertTxInBlock(block, &secondTxHash)
|
||||
ht.AssertTxInBlock(block, firstTxHash)
|
||||
ht.AssertTxInBlock(block, secondTxHash)
|
||||
}
|
||||
|
||||
// assertPsbtFundSignSpend funds a PSBT from the internal wallet and then
|
||||
|
@ -1807,7 +1807,7 @@ func testPsbtChanFundingWithUnstableUtxos(ht *lntest.HarnessTest) {
|
|||
|
||||
txHash := finalTx.TxHash()
|
||||
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
ht.AssertTxInBlock(block, &txHash)
|
||||
ht.AssertTxInBlock(block, txHash)
|
||||
|
||||
// Now we do the same but instead use preselected utxos to verify that
|
||||
// these utxos respects the utxo restrictions on sweeper unconfirmed
|
||||
|
@ -1951,5 +1951,5 @@ func testPsbtChanFundingWithUnstableUtxos(ht *lntest.HarnessTest) {
|
|||
|
||||
txHash = finalTx.TxHash()
|
||||
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
ht.AssertTxInBlock(block, &txHash)
|
||||
ht.AssertTxInBlock(block, txHash)
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ func breachRetributionTestCase(ht *lntest.HarnessTest,
|
|||
// ordering, the first output in this breach tx is the to_remote
|
||||
// output.
|
||||
toRemoteOp := wire.OutPoint{
|
||||
Hash: *breachTXID,
|
||||
Hash: breachTXID,
|
||||
Index: 0,
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ func breachRetributionTestCase(ht *lntest.HarnessTest,
|
|||
// Assert that all the inputs of this transaction are spending outputs
|
||||
// generated by Bob's breach transaction above.
|
||||
for _, txIn := range justiceTx.TxIn {
|
||||
require.Equal(ht, *breachTXID, txIn.PreviousOutPoint.Hash,
|
||||
require.Equal(ht, breachTXID, txIn.PreviousOutPoint.Hash,
|
||||
"justice tx not spending commitment utxo")
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ func breachRetributionTestCase(ht *lntest.HarnessTest,
|
|||
// transaction which was just accepted into the mempool.
|
||||
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
justiceTxid := justiceTx.TxHash()
|
||||
ht.AssertTxInBlock(block, &justiceTxid)
|
||||
ht.AssertTxInBlock(block, justiceTxid)
|
||||
|
||||
ht.AssertNodeNumChannels(carol, 0)
|
||||
|
||||
|
@ -318,7 +318,7 @@ func revokedCloseRetributionZeroValueRemoteOutputCase(ht *lntest.HarnessTest,
|
|||
// ordering, the first output in this breach tx is the to_local
|
||||
// output.
|
||||
toLocalOp := wire.OutPoint{
|
||||
Hash: *breachTXID,
|
||||
Hash: breachTXID,
|
||||
Index: 0,
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ func revokedCloseRetributionZeroValueRemoteOutputCase(ht *lntest.HarnessTest,
|
|||
// transaction which was just accepted into the mempool.
|
||||
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
justiceTxid := justiceTx.TxHash()
|
||||
ht.AssertTxInBlock(block, &justiceTxid)
|
||||
ht.AssertTxInBlock(block, justiceTxid)
|
||||
|
||||
// At this point, Dave should have no pending channels.
|
||||
ht.AssertNodeNumChannels(dave, 0)
|
||||
|
@ -567,7 +567,7 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
|
|||
// outputs to the second level before Dave broadcasts his justice tx,
|
||||
// we'll search through the mempool for a tx that matches the number of
|
||||
// expected inputs in the justice tx.
|
||||
var justiceTxid *chainhash.Hash
|
||||
var justiceTxid chainhash.Hash
|
||||
errNotFound := errors.New("justice tx not found")
|
||||
findJusticeTx := func() (*chainhash.Hash, error) {
|
||||
mempool := ht.GetRawMempool()
|
||||
|
@ -579,14 +579,14 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
|
|||
// NOTE: We don't use `ht.GetRawTransaction`
|
||||
// which asserts a txid must be found as the HTLC
|
||||
// spending txes might be aggregated.
|
||||
tx, err := ht.Miner().Client.GetRawTransaction(txid)
|
||||
tx, err := ht.Miner().Client.GetRawTransaction(&txid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
exNumInputs := 2 + numInvoices
|
||||
if len(tx.MsgTx().TxIn) == exNumInputs {
|
||||
return txid, nil
|
||||
return &txid, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -598,7 +598,7 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
justiceTxid = txid
|
||||
justiceTxid = *txid
|
||||
|
||||
return nil
|
||||
}, defaultTimeout)
|
||||
|
@ -619,7 +619,7 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
|
|||
return err
|
||||
}
|
||||
|
||||
justiceTxid = txid
|
||||
justiceTxid = *txid
|
||||
|
||||
return nil
|
||||
}, defaultTimeout)
|
||||
|
@ -631,7 +631,7 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
|
|||
// isSecondLevelSpend checks that the passed secondLevelTxid is a
|
||||
// potentitial second level spend spending from the commit tx.
|
||||
isSecondLevelSpend := func(commitTxid,
|
||||
secondLevelTxid *chainhash.Hash) bool {
|
||||
secondLevelTxid chainhash.Hash) bool {
|
||||
|
||||
secondLevel := ht.GetRawTransaction(secondLevelTxid)
|
||||
|
||||
|
@ -661,7 +661,7 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
|
|||
// the breach tx, Carol might have had the time to take an
|
||||
// output to the second level. In that case, check that the
|
||||
// justice tx is spending this second level output.
|
||||
if isSecondLevelSpend(breachTXID, &txIn.PreviousOutPoint.Hash) {
|
||||
if isSecondLevelSpend(breachTXID, txIn.PreviousOutPoint.Hash) {
|
||||
continue
|
||||
}
|
||||
require.Fail(ht, "justice tx not spending commitment utxo "+
|
||||
|
|
|
@ -318,7 +318,7 @@ func assertSignOutputRaw(ht *lntest.HarnessTest,
|
|||
tx := wire.NewMsgTx(2)
|
||||
tx.TxIn = []*wire.TxIn{{
|
||||
PreviousOutPoint: wire.OutPoint{
|
||||
Hash: *txid,
|
||||
Hash: txid,
|
||||
Index: uint32(targetOutputIndex),
|
||||
},
|
||||
}}
|
||||
|
|
|
@ -214,7 +214,7 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) {
|
|||
txns := ht.GetNumTxsFromMempool(2)
|
||||
|
||||
// Find the sweeping tx.
|
||||
sweepTx := ht.FindSweepingTxns(txns, 1, *closeTxid)[0]
|
||||
sweepTx := ht.FindSweepingTxns(txns, 1, closeTxid)[0]
|
||||
|
||||
// Get the weight for Bob's anchor sweeping tx.
|
||||
txWeight := ht.CalculateTxWeight(sweepTx)
|
||||
|
@ -281,7 +281,7 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) {
|
|||
txns = ht.GetNumTxsFromMempool(2)
|
||||
|
||||
// Find the sweeping tx.
|
||||
sweepTx = ht.FindSweepingTxns(txns, 1, *closeTxid)[0]
|
||||
sweepTx = ht.FindSweepingTxns(txns, 1, closeTxid)[0]
|
||||
|
||||
// Calculate the fee rate of Bob's new sweeping tx.
|
||||
feeRate = uint64(ht.CalculateTxFeeRate(sweepTx))
|
||||
|
@ -320,7 +320,7 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) {
|
|||
txns = ht.GetNumTxsFromMempool(2)
|
||||
|
||||
// Find the sweeping tx.
|
||||
sweepTx = ht.FindSweepingTxns(txns, 1, *closeTxid)[0]
|
||||
sweepTx = ht.FindSweepingTxns(txns, 1, closeTxid)[0]
|
||||
|
||||
// Calculate the fee of Bob's new sweeping tx.
|
||||
fee = uint64(ht.CalculateTxFee(sweepTx))
|
||||
|
@ -341,7 +341,7 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) {
|
|||
txns = ht.GetNumTxsFromMempool(2)
|
||||
|
||||
// Find the sweeping tx.
|
||||
currentSweepTx := ht.FindSweepingTxns(txns, 1, *closeTxid)[0]
|
||||
currentSweepTx := ht.FindSweepingTxns(txns, 1, closeTxid)[0]
|
||||
|
||||
// Assert the anchor sweep tx stays unchanged.
|
||||
require.Equal(ht, sweepTx.TxHash(), currentSweepTx.TxHash())
|
||||
|
@ -553,7 +553,7 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) {
|
|||
txns := ht.GetNumTxsFromMempool(2)
|
||||
|
||||
// Find the sweeping tx.
|
||||
sweepTx := ht.FindSweepingTxns(txns, 1, *closeTxid)[0]
|
||||
sweepTx := ht.FindSweepingTxns(txns, 1, closeTxid)[0]
|
||||
|
||||
// Get the weight for Bob's anchor sweeping tx.
|
||||
txWeight := ht.CalculateTxWeight(sweepTx)
|
||||
|
@ -620,7 +620,7 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) {
|
|||
txns = ht.GetNumTxsFromMempool(2)
|
||||
|
||||
// Find the sweeping tx.
|
||||
sweepTx = ht.FindSweepingTxns(txns, 1, *closeTxid)[0]
|
||||
sweepTx = ht.FindSweepingTxns(txns, 1, closeTxid)[0]
|
||||
|
||||
// Calculate the fee rate of Bob's new sweeping tx.
|
||||
feeRate = uint64(ht.CalculateTxFeeRate(sweepTx))
|
||||
|
@ -659,7 +659,7 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) {
|
|||
txns = ht.GetNumTxsFromMempool(2)
|
||||
|
||||
// Find the sweeping tx.
|
||||
sweepTx = ht.FindSweepingTxns(txns, 1, *closeTxid)[0]
|
||||
sweepTx = ht.FindSweepingTxns(txns, 1, closeTxid)[0]
|
||||
|
||||
// Calculate the fee of Bob's new sweeping tx.
|
||||
fee = uint64(ht.CalculateTxFee(sweepTx))
|
||||
|
@ -680,7 +680,7 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) {
|
|||
txns = ht.GetNumTxsFromMempool(2)
|
||||
|
||||
// Find the sweeping tx.
|
||||
currentSweepTx := ht.FindSweepingTxns(txns, 1, *closeTxid)[0]
|
||||
currentSweepTx := ht.FindSweepingTxns(txns, 1, closeTxid)[0]
|
||||
|
||||
// Assert the anchor sweep tx stays unchanged.
|
||||
require.Equal(ht, sweepTx.TxHash(), currentSweepTx.TxHash())
|
||||
|
@ -2274,7 +2274,7 @@ func testBumpForceCloseFee(ht *lntest.HarnessTest) {
|
|||
// this anchor sweep transaction (because of the small fee delta).
|
||||
ht.MineEmptyBlocks(1)
|
||||
cpfpHash1 := cpfpSweep1.TxHash()
|
||||
ht.AssertTxInMempool(&cpfpHash1)
|
||||
ht.AssertTxInMempool(cpfpHash1)
|
||||
|
||||
// Now Bump the fee rate again with a bigger starting fee rate of the
|
||||
// fee function.
|
||||
|
|
|
@ -171,7 +171,7 @@ func testTaprootComputeInputScriptKeySpendBip86(ht *lntest.HarnessTest,
|
|||
ht.AssertUTXOInWallet(alice, op, "")
|
||||
|
||||
p2trOutpoint := wire.OutPoint{
|
||||
Hash: *txid,
|
||||
Hash: txid,
|
||||
Index: uint32(p2trOutputIndex),
|
||||
}
|
||||
|
||||
|
@ -1413,7 +1413,7 @@ func clearWalletImportedTapscriptBalance(ht *lntest.HarnessTest,
|
|||
// Mine one block which should contain the sweep transaction.
|
||||
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
sweepTxHash := sweepTx.TxHash()
|
||||
ht.AssertTxInBlock(block, &sweepTxHash)
|
||||
ht.AssertTxInBlock(block, sweepTxHash)
|
||||
}
|
||||
|
||||
// testScriptHashLock returns a simple bitcoin script that locks the funds to
|
||||
|
@ -1484,7 +1484,7 @@ func sendToTaprootOutput(ht *lntest.HarnessTest, hn *node.HarnessNode,
|
|||
txid := ht.AssertNumTxsInMempool(1)[0]
|
||||
p2trOutputIndex := ht.GetOutputIndex(txid, tapScriptAddr.String())
|
||||
p2trOutpoint := wire.OutPoint{
|
||||
Hash: *txid,
|
||||
Hash: txid,
|
||||
Index: uint32(p2trOutputIndex),
|
||||
}
|
||||
|
||||
|
@ -1849,7 +1849,7 @@ func testTaprootCoopClose(ht *lntest.HarnessTest) {
|
|||
|
||||
// assertTaprootDeliveryUsed returns true if a Taproot addr was used in
|
||||
// the co-op close transaction.
|
||||
assertTaprootDeliveryUsed := func(closingTxid *chainhash.Hash) bool {
|
||||
assertTaprootDeliveryUsed := func(closingTxid chainhash.Hash) bool {
|
||||
tx := ht.GetRawTransaction(closingTxid)
|
||||
for _, txOut := range tx.MsgTx().TxOut {
|
||||
if !txscript.IsPayToTaproot(txOut.PkScript) {
|
||||
|
|
|
@ -372,7 +372,7 @@ func fundChanAndCloseFromImportedAccount(ht *lntest.HarnessTest, srcNode,
|
|||
)
|
||||
|
||||
block := ht.MineBlocksAndAssertNumTxes(6, 1)[0]
|
||||
ht.AssertTxInBlock(block, txHash)
|
||||
ht.AssertTxInBlock(block, *txHash)
|
||||
|
||||
confBalanceAfterChan += chanChangeUtxoAmt
|
||||
ht.AssertWalletAccountBalance(srcNode, account, 0, 0)
|
||||
|
@ -389,7 +389,7 @@ func fundChanAndCloseFromImportedAccount(ht *lntest.HarnessTest, srcNode,
|
|||
)
|
||||
|
||||
block := ht.MineBlocksAndAssertNumTxes(6, 1)[0]
|
||||
ht.AssertTxInBlock(block, txHash)
|
||||
ht.AssertTxInBlock(block, *txHash)
|
||||
|
||||
confBalanceAfterChan += chanChangeUtxoAmt
|
||||
ht.AssertWalletAccountBalance(
|
||||
|
|
|
@ -342,6 +342,7 @@ func (h *HarnessTest) SetupStandbyNodes() {
|
|||
// above a good number of confirmations.
|
||||
const totalTxes = 200
|
||||
h.MineBlocksAndAssertNumTxes(numBlocksSendOutput, totalTxes)
|
||||
h.MineBlocks(numBlocksSendOutput)
|
||||
|
||||
// Now we want to wait for the nodes to catch up.
|
||||
h.WaitForBlockchainSync(h.Alice)
|
||||
|
@ -913,12 +914,12 @@ func (h *HarnessTest) validateNodeState(hn *node.HarnessNode) error {
|
|||
// GetChanPointFundingTxid takes a channel point and converts it into a chain
|
||||
// hash.
|
||||
func (h *HarnessTest) GetChanPointFundingTxid(
|
||||
cp *lnrpc.ChannelPoint) *chainhash.Hash {
|
||||
cp *lnrpc.ChannelPoint) chainhash.Hash {
|
||||
|
||||
txid, err := lnrpc.GetChanPointFundingTxid(cp)
|
||||
require.NoError(h, err, "unable to get txid")
|
||||
|
||||
return txid
|
||||
return *txid
|
||||
}
|
||||
|
||||
// OutPointFromChannelPoint creates an outpoint from a given channel point.
|
||||
|
@ -927,7 +928,7 @@ func (h *HarnessTest) OutPointFromChannelPoint(
|
|||
|
||||
txid := h.GetChanPointFundingTxid(cp)
|
||||
return wire.OutPoint{
|
||||
Hash: *txid,
|
||||
Hash: txid,
|
||||
Index: cp.OutputIndex,
|
||||
}
|
||||
}
|
||||
|
@ -1263,7 +1264,7 @@ func (h *HarnessTest) OpenChannelAssertErr(srcNode, destNode *node.HarnessNode,
|
|||
// mempool.
|
||||
func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
|
||||
cp *lnrpc.ChannelPoint,
|
||||
force bool) (rpc.CloseChanClient, *chainhash.Hash) {
|
||||
force bool) (rpc.CloseChanClient, chainhash.Hash) {
|
||||
|
||||
// Calls the rpc to close the channel.
|
||||
closeReq := &lnrpc.CloseChannelRequest{
|
||||
|
@ -1306,9 +1307,9 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
|
|||
pendingClose.ClosePending.Txid)
|
||||
|
||||
// Assert the closing tx is in the mempool.
|
||||
h.miner.AssertTxInMempool(closeTxid)
|
||||
h.miner.AssertTxInMempool(*closeTxid)
|
||||
|
||||
return stream, closeTxid
|
||||
return stream, *closeTxid
|
||||
}
|
||||
|
||||
// CloseChannel attempts to coop close a non-anchored channel identified by the
|
||||
|
@ -1321,7 +1322,7 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
|
|||
// 5. the node reports zero waiting close channels.
|
||||
// 6. the node receives a topology update regarding the channel close.
|
||||
func (h *HarnessTest) CloseChannel(hn *node.HarnessNode,
|
||||
cp *lnrpc.ChannelPoint) *chainhash.Hash {
|
||||
cp *lnrpc.ChannelPoint) chainhash.Hash {
|
||||
|
||||
stream, _ := h.CloseChannelAssertPending(hn, cp, false)
|
||||
|
||||
|
@ -1340,7 +1341,7 @@ func (h *HarnessTest) CloseChannel(hn *node.HarnessNode,
|
|||
// 7. mine DefaultCSV-1 blocks.
|
||||
// 8. the node reports zero pending force close channels.
|
||||
func (h *HarnessTest) ForceCloseChannel(hn *node.HarnessNode,
|
||||
cp *lnrpc.ChannelPoint) *chainhash.Hash {
|
||||
cp *lnrpc.ChannelPoint) chainhash.Hash {
|
||||
|
||||
stream, _ := h.CloseChannelAssertPending(hn, cp, true)
|
||||
|
||||
|
@ -1902,7 +1903,7 @@ func (h *HarnessTest) CalculateTxFee(tx *wire.MsgTx) btcutil.Amount {
|
|||
var balance btcutil.Amount
|
||||
for _, in := range tx.TxIn {
|
||||
parentHash := in.PreviousOutPoint.Hash
|
||||
rawTx := h.miner.GetRawTransaction(&parentHash)
|
||||
rawTx := h.miner.GetRawTransaction(parentHash)
|
||||
parent := rawTx.MsgTx()
|
||||
value := parent.TxOut[in.PreviousOutPoint.Index].Value
|
||||
|
||||
|
@ -2151,7 +2152,7 @@ func (h *HarnessTest) ReceiveChannelEvent(
|
|||
|
||||
// GetOutputIndex returns the output index of the given address in the given
|
||||
// transaction.
|
||||
func (h *HarnessTest) GetOutputIndex(txid *chainhash.Hash, addr string) int {
|
||||
func (h *HarnessTest) GetOutputIndex(txid chainhash.Hash, addr string) int {
|
||||
// We'll then extract the raw transaction from the mempool in order to
|
||||
// determine the index of the p2tr output.
|
||||
tx := h.miner.GetRawTransaction(txid)
|
||||
|
|
|
@ -534,7 +534,7 @@ func (h *HarnessTest) AssertTopologyChannelClosed(hn *node.HarnessNode,
|
|||
// by consuming a message from the passed close channel stream. Returns the
|
||||
// closing txid if found.
|
||||
func (h HarnessTest) WaitForChannelCloseEvent(
|
||||
stream rpc.CloseChanClient) *chainhash.Hash {
|
||||
stream rpc.CloseChanClient) chainhash.Hash {
|
||||
|
||||
// Consume one event.
|
||||
event, err := h.ReceiveCloseChannelUpdate(stream)
|
||||
|
@ -548,7 +548,7 @@ func (h HarnessTest) WaitForChannelCloseEvent(
|
|||
require.NoErrorf(h, err, "wrong format found in closing txid: %v",
|
||||
resp.ChanClose.ClosingTxid)
|
||||
|
||||
return txid
|
||||
return *txid
|
||||
}
|
||||
|
||||
// AssertNumWaitingClose checks that a PendingChannels response from the node
|
||||
|
@ -634,7 +634,7 @@ func (h *HarnessTest) AssertNumPendingForceClose(hn *node.HarnessNode,
|
|||
// - assert the node has seen the channel close update.
|
||||
func (h *HarnessTest) AssertStreamChannelCoopClosed(hn *node.HarnessNode,
|
||||
cp *lnrpc.ChannelPoint, anchors bool,
|
||||
stream rpc.CloseChanClient) *chainhash.Hash {
|
||||
stream rpc.CloseChanClient) chainhash.Hash {
|
||||
|
||||
// Assert the channel is waiting close.
|
||||
resp := h.AssertChannelWaitingClose(hn, cp)
|
||||
|
@ -682,7 +682,7 @@ func (h *HarnessTest) AssertStreamChannelCoopClosed(hn *node.HarnessNode,
|
|||
// confirmed.
|
||||
func (h *HarnessTest) AssertStreamChannelForceClosed(hn *node.HarnessNode,
|
||||
cp *lnrpc.ChannelPoint, anchorSweep bool,
|
||||
stream rpc.CloseChanClient) *chainhash.Hash {
|
||||
stream rpc.CloseChanClient) chainhash.Hash {
|
||||
|
||||
// Assert the channel is waiting close.
|
||||
resp := h.AssertChannelWaitingClose(hn, cp)
|
||||
|
|
|
@ -112,9 +112,7 @@ func (h *HarnessTest) MineBlocksAndAssertNumTxes(num uint32,
|
|||
}
|
||||
|
||||
// Make sure the mempool has been updated.
|
||||
for _, txid := range txids {
|
||||
h.miner.AssertTxNotInMempool(*txid)
|
||||
}
|
||||
h.miner.AssertTxnsNotInMempool(txids)
|
||||
|
||||
// Finally, make sure all the active nodes are synced.
|
||||
bestBlock := blocks[len(blocks)-1]
|
||||
|
@ -202,7 +200,7 @@ func (h *HarnessTest) mineTillForceCloseResolved(hn *node.HarnessNode) {
|
|||
}
|
||||
|
||||
// AssertTxInMempool asserts a given transaction can be found in the mempool.
|
||||
func (h *HarnessTest) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx {
|
||||
func (h *HarnessTest) AssertTxInMempool(txid chainhash.Hash) *wire.MsgTx {
|
||||
return h.miner.AssertTxInMempool(txid)
|
||||
}
|
||||
|
||||
|
@ -212,14 +210,14 @@ func (h *HarnessTest) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx {
|
|||
// NOTE: this should be used after `AssertTxInMempool` to ensure the tx has
|
||||
// entered the mempool before. Otherwise it might give false positive and the
|
||||
// tx may enter the mempool after the check.
|
||||
func (h *HarnessTest) AssertTxNotInMempool(txid chainhash.Hash) *wire.MsgTx {
|
||||
return h.miner.AssertTxNotInMempool(txid)
|
||||
func (h *HarnessTest) AssertTxNotInMempool(txid chainhash.Hash) {
|
||||
h.miner.AssertTxNotInMempool(txid)
|
||||
}
|
||||
|
||||
// AssertNumTxsInMempool polls until finding the desired number of transactions
|
||||
// in the provided miner's mempool. It will assert if this number is not met
|
||||
// after the given timeout.
|
||||
func (h *HarnessTest) AssertNumTxsInMempool(n int) []*chainhash.Hash {
|
||||
func (h *HarnessTest) AssertNumTxsInMempool(n int) []chainhash.Hash {
|
||||
return h.miner.AssertNumTxsInMempool(n)
|
||||
}
|
||||
|
||||
|
@ -230,7 +228,7 @@ func (h *HarnessTest) AssertOutpointInMempool(op wire.OutPoint) *wire.MsgTx {
|
|||
|
||||
// AssertTxInBlock asserts that a given txid can be found in the passed block.
|
||||
func (h *HarnessTest) AssertTxInBlock(block *wire.MsgBlock,
|
||||
txid *chainhash.Hash) {
|
||||
txid chainhash.Hash) {
|
||||
|
||||
h.miner.AssertTxInBlock(block, txid)
|
||||
}
|
||||
|
@ -263,13 +261,13 @@ func (h *HarnessTest) DisconnectFromMiner(tempMiner *miner.HarnessMiner) {
|
|||
|
||||
// GetRawMempool makes a RPC call to the miner's GetRawMempool and
|
||||
// asserts.
|
||||
func (h *HarnessTest) GetRawMempool() []*chainhash.Hash {
|
||||
func (h *HarnessTest) GetRawMempool() []chainhash.Hash {
|
||||
return h.miner.GetRawMempool()
|
||||
}
|
||||
|
||||
// GetRawTransaction makes a RPC call to the miner's GetRawTransaction and
|
||||
// asserts.
|
||||
func (h *HarnessTest) GetRawTransaction(txid *chainhash.Hash) *btcutil.Tx {
|
||||
func (h *HarnessTest) GetRawTransaction(txid chainhash.Hash) *btcutil.Tx {
|
||||
return h.miner.GetRawTransaction(txid)
|
||||
}
|
||||
|
||||
|
|
|
@ -156,11 +156,16 @@ func (h *HarnessMiner) GetBestBlock() (*chainhash.Hash, int32) {
|
|||
|
||||
// GetRawMempool makes a RPC call to the miner's GetRawMempool and
|
||||
// asserts.
|
||||
func (h *HarnessMiner) GetRawMempool() []*chainhash.Hash {
|
||||
func (h *HarnessMiner) GetRawMempool() []chainhash.Hash {
|
||||
mempool, err := h.Client.GetRawMempool()
|
||||
require.NoError(h, err, "unable to get mempool")
|
||||
|
||||
return mempool
|
||||
txns := make([]chainhash.Hash, 0, len(mempool))
|
||||
for _, txid := range mempool {
|
||||
txns = append(txns, *txid)
|
||||
}
|
||||
|
||||
return txns
|
||||
}
|
||||
|
||||
// GenerateBlocks mine 'num' of blocks and returns them.
|
||||
|
@ -198,9 +203,9 @@ func (h *HarnessMiner) MineBlocks(num uint32) []*wire.MsgBlock {
|
|||
// AssertNumTxsInMempool polls until finding the desired number of transactions
|
||||
// in the provided miner's mempool. It will assert if this number is not met
|
||||
// after the given timeout.
|
||||
func (h *HarnessMiner) AssertNumTxsInMempool(n int) []*chainhash.Hash {
|
||||
func (h *HarnessMiner) AssertNumTxsInMempool(n int) []chainhash.Hash {
|
||||
var (
|
||||
mem []*chainhash.Hash
|
||||
mem []chainhash.Hash
|
||||
err error
|
||||
)
|
||||
|
||||
|
@ -222,7 +227,7 @@ func (h *HarnessMiner) AssertNumTxsInMempool(n int) []*chainhash.Hash {
|
|||
|
||||
// AssertTxInBlock asserts that a given txid can be found in the passed block.
|
||||
func (h *HarnessMiner) AssertTxInBlock(block *wire.MsgBlock,
|
||||
txid *chainhash.Hash) {
|
||||
txid chainhash.Hash) {
|
||||
|
||||
blockTxes := make([]chainhash.Hash, 0)
|
||||
|
||||
|
@ -264,8 +269,8 @@ func (h *HarnessMiner) MineBlocksAndAssertNumTxes(num uint32,
|
|||
|
||||
// GetRawTransaction makes a RPC call to the miner's GetRawTransaction and
|
||||
// asserts.
|
||||
func (h *HarnessMiner) GetRawTransaction(txid *chainhash.Hash) *btcutil.Tx {
|
||||
tx, err := h.Client.GetRawTransaction(txid)
|
||||
func (h *HarnessMiner) GetRawTransaction(txid chainhash.Hash) *btcutil.Tx {
|
||||
tx, err := h.Client.GetRawTransaction(&txid)
|
||||
require.NoErrorf(h, err, "failed to get raw tx: %v", txid)
|
||||
return tx
|
||||
}
|
||||
|
@ -273,15 +278,15 @@ func (h *HarnessMiner) GetRawTransaction(txid *chainhash.Hash) *btcutil.Tx {
|
|||
// GetRawTransactionVerbose makes a RPC call to the miner's
|
||||
// GetRawTransactionVerbose and asserts.
|
||||
func (h *HarnessMiner) GetRawTransactionVerbose(
|
||||
txid *chainhash.Hash) *btcjson.TxRawResult {
|
||||
txid chainhash.Hash) *btcjson.TxRawResult {
|
||||
|
||||
tx, err := h.Client.GetRawTransactionVerbose(txid)
|
||||
tx, err := h.Client.GetRawTransactionVerbose(&txid)
|
||||
require.NoErrorf(h, err, "failed to get raw tx verbose: %v", txid)
|
||||
return tx
|
||||
}
|
||||
|
||||
// AssertTxInMempool asserts a given transaction can be found in the mempool.
|
||||
func (h *HarnessMiner) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx {
|
||||
func (h *HarnessMiner) AssertTxInMempool(txid chainhash.Hash) *wire.MsgTx {
|
||||
err := wait.NoError(func() error {
|
||||
// We require the RPC call to be succeeded and won't wait for
|
||||
// it as it's an unexpected behavior.
|
||||
|
@ -291,8 +296,8 @@ func (h *HarnessMiner) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx {
|
|||
return fmt.Errorf("empty mempool")
|
||||
}
|
||||
|
||||
isEqual := func(memTx *chainhash.Hash) bool {
|
||||
return *memTx == *txid
|
||||
isEqual := func(memTx chainhash.Hash) bool {
|
||||
return memTx == txid
|
||||
}
|
||||
result := fn.Find(isEqual, mempool)
|
||||
|
||||
|
@ -309,15 +314,41 @@ func (h *HarnessMiner) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx {
|
|||
return h.GetRawTransaction(txid).MsgTx()
|
||||
}
|
||||
|
||||
// AssertTxnsNotInMempool asserts the given txns are not found in the mempool.
|
||||
// It assumes the mempool is not empty.
|
||||
func (h *HarnessMiner) AssertTxnsNotInMempool(txids []chainhash.Hash) {
|
||||
err := wait.NoError(func() error {
|
||||
// We require the RPC call to be succeeded and won't wait for
|
||||
// it as it's an unexpected behavior.
|
||||
mempool := h.GetRawMempool()
|
||||
|
||||
// Turn the mempool into a txn set for faster lookups.
|
||||
mempoolTxns := fn.NewSet(mempool...)
|
||||
|
||||
// Check if any of the txids are in the mempool.
|
||||
for _, txid := range txids {
|
||||
// Skip if the tx is not in the mempool.
|
||||
if !mempoolTxns.Contains(txid) {
|
||||
continue
|
||||
}
|
||||
|
||||
return fmt.Errorf("expect txid %v to be NOT found in "+
|
||||
"mempool", txid)
|
||||
}
|
||||
|
||||
return nil
|
||||
}, wait.MinerMempoolTimeout)
|
||||
|
||||
require.NoError(h, err, "timeout checking txns not in mempool")
|
||||
}
|
||||
|
||||
// AssertTxNotInMempool asserts a given transaction cannot be found in the
|
||||
// mempool. It assumes the mempool is not empty.
|
||||
//
|
||||
// NOTE: this should be used after `AssertTxInMempool` to ensure the tx has
|
||||
// entered the mempool before. Otherwise it might give false positive and the
|
||||
// tx may enter the mempool after the check.
|
||||
func (h *HarnessMiner) AssertTxNotInMempool(txid chainhash.Hash) *wire.MsgTx {
|
||||
var msgTx *wire.MsgTx
|
||||
|
||||
func (h *HarnessMiner) AssertTxNotInMempool(txid chainhash.Hash) {
|
||||
err := wait.NoError(func() error {
|
||||
// We require the RPC call to be succeeded and won't wait for
|
||||
// it as it's an unexpected behavior.
|
||||
|
@ -325,7 +356,7 @@ func (h *HarnessMiner) AssertTxNotInMempool(txid chainhash.Hash) *wire.MsgTx {
|
|||
|
||||
for _, memTx := range mempool {
|
||||
// Check the values are equal.
|
||||
if txid.IsEqual(memTx) {
|
||||
if txid == memTx {
|
||||
return fmt.Errorf("expect txid %v to be NOT "+
|
||||
"found in mempool", txid)
|
||||
}
|
||||
|
@ -335,8 +366,6 @@ func (h *HarnessMiner) AssertTxNotInMempool(txid chainhash.Hash) *wire.MsgTx {
|
|||
}, wait.MinerMempoolTimeout)
|
||||
|
||||
require.NoError(h, err, "timeout checking tx not in mempool")
|
||||
|
||||
return msgTx
|
||||
}
|
||||
|
||||
// SendOutputsWithoutChange uses the miner to send the given outputs using the
|
||||
|
@ -418,7 +447,7 @@ func (h *HarnessMiner) AssertOutpointInMempool(op wire.OutPoint) *wire.MsgTx {
|
|||
// found. For instance, the aggregation logic used in
|
||||
// sweeping HTLC outputs will update the mempool by
|
||||
// replacing the HTLC spending txes with a single one.
|
||||
tx, err := h.Client.GetRawTransaction(txid)
|
||||
tx, err := h.Client.GetRawTransaction(&txid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue