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
20 changed files with 108 additions and 93 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/lntest/node"
"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")
}
// 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)
}