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:
1 parent
e553895ddd
commit
976bb37972
20 files changed
+108
-93
No files matched your search
+1
-1
@@ -1193,7 +1193,7 @@ func (h *HarnessTest) openChannel(alice, bob *node.HarnessNode,
|
||||
|
||||
// Check that the funding tx is found in the first block.
|
||||
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
|
||||
// network topology.
|
||||
|
||||
@@ -656,7 +656,7 @@ func (h *HarnessTest) AssertStreamChannelCoopClosed(hn *node.HarnessNode,
|
||||
// Consume one close event and assert the closing txid can be found in
|
||||
// the block.
|
||||
closingTxid := h.WaitForChannelCloseEvent(stream)
|
||||
h.Miner.AssertTxInBlock(block, closingTxid)
|
||||
h.AssertTxInBlock(block, closingTxid)
|
||||
|
||||
// We should see zero waiting close channels now.
|
||||
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
|
||||
// the block.
|
||||
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
|
||||
// channels now.
|
||||
@@ -2564,7 +2564,7 @@ func (h *HarnessTest) AssertClosingTxInMempool(cp *lnrpc.ChannelPoint,
|
||||
}
|
||||
|
||||
// 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.
|
||||
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.
|
||||
func (h *HarnessTest) MineClosingTx(cp *lnrpc.ChannelPoint) *wire.MsgTx {
|
||||
// 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.
|
||||
op := h.OutPointFromChannelPoint(cp)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
Reference in new issue
Block a user