@@ -17,6 +17,7 @@ import (
1717 "github.com/btcsuite/btcd/integration/rpctest"
1818 "github.com/btcsuite/btcd/rpcclient"
1919 "github.com/btcsuite/btcd/wire"
20+ "github.com/lightningnetwork/lnd/fn"
2021 "github.com/lightningnetwork/lnd/lntest/node"
2122 "github.com/lightningnetwork/lnd/lntest/wait"
2223 "github.com/stretchr/testify/require"
@@ -281,8 +282,6 @@ func (h *HarnessMiner) GetRawTransactionVerbose(
281282
282283// AssertTxInMempool asserts a given transaction can be found in the mempool.
283284func (h * HarnessMiner ) AssertTxInMempool (txid * chainhash.Hash ) * wire.MsgTx {
284- var msgTx * wire.MsgTx
285-
286285 err := wait .NoError (func () error {
287286 // We require the RPC call to be succeeded and won't wait for
288287 // it as it's an unexpected behavior.
@@ -292,20 +291,22 @@ func (h *HarnessMiner) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx {
292291 return fmt .Errorf ("empty mempool" )
293292 }
294293
295- for _ , memTx := range mempool {
296- // Check the values are equal.
297- if * memTx == * txid {
298- return nil
299- }
294+ isEqual := func (memTx * chainhash.Hash ) bool {
295+ return * memTx == * txid
300296 }
297+ result := fn .Find (isEqual , mempool )
301298
302- return fmt .Errorf ("txid %v not found in mempool: %v" , txid ,
303- mempool )
299+ if result .IsNone () {
300+ return fmt .Errorf ("txid %v not found in " +
301+ "mempool: %v" , txid , mempool )
302+ }
303+
304+ return nil
304305 }, wait .MinerMempoolTimeout )
305306
306307 require .NoError (h , err , "timeout checking mempool" )
307308
308- return msgTx
309+ return h . GetRawTransaction ( txid ). MsgTx ()
309310}
310311
311312// AssertTxNotInMempool asserts a given transaction cannot be found in the
0 commit comments