mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 14:22:37 +01:00
miner: bugfix
return the transaction when found in the mempool.
This commit is contained in:
parent
75f6622ccf
commit
ae28f75557
1 changed files with 11 additions and 10 deletions
|
@ -17,6 +17,7 @@ import (
|
||||||
"github.com/btcsuite/btcd/integration/rpctest"
|
"github.com/btcsuite/btcd/integration/rpctest"
|
||||||
"github.com/btcsuite/btcd/rpcclient"
|
"github.com/btcsuite/btcd/rpcclient"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
|
"github.com/lightningnetwork/lnd/fn"
|
||||||
"github.com/lightningnetwork/lnd/lntest/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -281,8 +282,6 @@ func (h *HarnessMiner) GetRawTransactionVerbose(
|
||||||
|
|
||||||
// AssertTxInMempool asserts a given transaction can be found in the mempool.
|
// 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 {
|
||||||
var msgTx *wire.MsgTx
|
|
||||||
|
|
||||||
err := wait.NoError(func() error {
|
err := wait.NoError(func() error {
|
||||||
// We require the RPC call to be succeeded and won't wait for
|
// We require the RPC call to be succeeded and won't wait for
|
||||||
// it as it's an unexpected behavior.
|
// it as it's an unexpected behavior.
|
||||||
|
@ -292,20 +291,22 @@ func (h *HarnessMiner) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx {
|
||||||
return fmt.Errorf("empty mempool")
|
return fmt.Errorf("empty mempool")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, memTx := range mempool {
|
isEqual := func(memTx *chainhash.Hash) bool {
|
||||||
// Check the values are equal.
|
return *memTx == *txid
|
||||||
if *memTx == *txid {
|
}
|
||||||
return nil
|
result := fn.Find(isEqual, mempool)
|
||||||
}
|
|
||||||
|
if result.IsNone() {
|
||||||
|
return fmt.Errorf("txid %v not found in "+
|
||||||
|
"mempool: %v", txid, mempool)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("txid %v not found in mempool: %v", txid,
|
return nil
|
||||||
mempool)
|
|
||||||
}, wait.MinerMempoolTimeout)
|
}, wait.MinerMempoolTimeout)
|
||||||
|
|
||||||
require.NoError(h, err, "timeout checking mempool")
|
require.NoError(h, err, "timeout checking mempool")
|
||||||
|
|
||||||
return msgTx
|
return h.GetRawTransaction(txid).MsgTx()
|
||||||
}
|
}
|
||||||
|
|
||||||
// AssertTxNotInMempool asserts a given transaction cannot be found in the
|
// AssertTxNotInMempool asserts a given transaction cannot be found in the
|
||||||
|
|
Loading…
Add table
Reference in a new issue