lntest: retry mempool snapshots during RBF churn
What changed, and why it matters
This change only affects internal test code. It makes a test helper retry when the Bitcoin mempool changes while it is being read, which can happen during Replace-By-Fee (RBF) transactions in tests. There is no change to production LND node code, no user-facing behavior change, and no security fix.
No security action needed. Treat as normal test infrastructure improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies lntest/miner/miner.go’s GetNumTxsFromMempool helper. Previously it took a single mempool snapshot via AssertNumTxsInMempool, then fetched each raw transaction; if an RBF replacement removed a txid between listing and fetching, the call could fail. The patch wraps the list-and-fetch loop in wait.NoError with MinerMempoolTimeout so a fresh snapshot is retried on GetRawTransaction errors. This is a test-only robustness improvement.
Changed components
lntest/miner/miner.go test helper onlyInspect captured patch +22 / −6
diff --git a/lntest/miner/miner.go b/lntest/miner/miner.go
index 92a9000..f6f7594 100644
--- a/lntest/miner/miner.go
+++ b/lntest/miner/miner.go
@@ -589,13 +589,29 @@ func (h *HarnessMiner) AssertOutpointInMempool(op wire.OutPoint) *wire.MsgTx {
// GetNumTxsFromMempool polls until finding the desired number of transactions
// in the miner's mempool and returns the full transactions to the caller.
func (h *HarnessMiner) GetNumTxsFromMempool(n int) []*wire.MsgTx {
- txids := h.AssertNumTxsInMempool(n)
-
var txes []*wire.MsgTx
- for _, txid := range txids {
- tx := h.GetRawTransaction(txid)
- txes = append(txes, tx.MsgTx())
- }
+
+ err := wait.NoError(func() error {
+ txids := h.AssertNumTxsInMempool(n)
+
+ txes = nil
+ for _, txid := range txids {
+ // The mempool can change between listing its txids
+ // and fetching a transaction. For example, sweep
+ // tests may RBF-replace a tx while we iterate over
+ // the snapshot. Retry with a fresh snapshot when
+ // that happens.
+ tx, err := h.backend.GetRawTransaction(&txid)
+ if err != nil {
+ return err
+ }
+
+ txes = append(txes, tx.MsgTx())
+ }
+
+ return nil
+ }, wait.MinerMempoolTimeout)
+ require.NoError(h, err, "get txs from mempool")
return txes
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.