[prep/util] help MockMempoolMinFee handle more precise feerates
What changed, and why it matters
This is a small test-only change in Bitcoin Core. It adjusts a mock mempool helper used in automated tests so that fee calculations line up more precisely when non-integer fee rates are used. The change only affects test code and does not alter how the live Bitcoin network or wallet behaves.
No security action required. Treat as a normal test-maintenance commit. Reviewers may verify that MockMempoolMinFee callers still pass with the enlarged dummy transaction size.
Security signals we found
No security signal: change is confined to test utilities
No consensus, networking, wallet, or mempool policy code modified
Change addresses unit-test precision/rounding, not a vulnerability
Evidence from the diff
The commit modifies MockMempoolMinFee in src/test/util/setup_common.cpp, a test utility that simulates a mempool minimum fee rate. It includes test/util/transaction_utils.h and calls BulkTransaction(mtx, 4000) to inflate the dummy transaction’s virtual size to 1000 vbytes (the helper adds 4000 bytes to reach a round multiple). Because CFeeRate is expressed in satoshis per kvB, a 1000-vbyte transaction makes the fee an integer for common feerates, avoiding rounding drift between target_feerate and the value later returned by GetMinFee(). This is a precision fix in test infrastructure, not a consensus, mempool policy, or production code change.
Changed components
src/test/util/setup_common.cppMockMempoolMinFee test helperInspect captured patch +4 / −0
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index 76a42d19..9c9bdc70 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -40,6 +40,7 @@
#include <test/util/coverage.h>
#include <test/util/net.h>
#include <test/util/random.h>
+#include <test/util/transaction_utils.h>
#include <test/util/txmempool.h>
#include <txdb.h>
#include <txmempool.h>
@@ -586,6 +587,9 @@ void TestChain100Setup::MockMempoolMinFee(const CFeeRate& target_feerate)
CMutableTransaction mtx = CMutableTransaction();
mtx.vin.emplace_back(COutPoint{Txid::FromUint256(m_rng.rand256()), 0});
mtx.vout.emplace_back(1 * COIN, GetScriptForDestination(WitnessV0ScriptHash(CScript() << OP_TRUE)));
+ // Set a large size so that the fee evaluated at target_feerate (which is usually in sats/kvB) is an integer.
+ // Otherwise, GetMinFee() may end up slightly different from target_feerate.
+ BulkTransaction(mtx, 4000);
const auto tx{MakeTransactionRef(mtx)};
LockPoints lp;
// The new mempool min feerate is equal to the removed package's feerate + incremental feerate.
Why this scored 16/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.