miner: bugfix

return the transaction when found in the mempool.
This commit is contained in:
ziggie 2024-07-29 15:57:21 +02:00
parent 75f6622ccf
commit ae28f75557
No known key found for this signature in database
GPG key ID: 1AFF9C4DCED6D666

View file

@ -17,6 +17,7 @@ import (
"github.com/btcsuite/btcd/integration/rpctest"
"github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/lntest/node"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/stretchr/testify/require"
@ -281,8 +282,6 @@ func (h *HarnessMiner) GetRawTransactionVerbose(
// AssertTxInMempool asserts a given transaction can be found in the mempool.
func (h *HarnessMiner) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx {
var msgTx *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.
@ -292,20 +291,22 @@ func (h *HarnessMiner) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx {
return fmt.Errorf("empty mempool")
}
for _, memTx := range mempool {
// Check the values are equal.
if *memTx == *txid {
return nil
}
isEqual := func(memTx *chainhash.Hash) bool {
return *memTx == *txid
}
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,
mempool)
return nil
}, wait.MinerMempoolTimeout)
require.NoError(h, err, "timeout checking mempool")
return msgTx
return h.GetRawTransaction(txid).MsgTx()
}
// AssertTxNotInMempool asserts a given transaction cannot be found in the