From da30ca0efadd3861016f6435636d9b399da65162 Mon Sep 17 00:00:00 2001 From: glozow Date: Wed, 30 Jul 2025 15:48:34 -0400 Subject: [PATCH] [prep/util] help MockMempoolMinFee handle more precise feerates Use a virtual size of 1000 to keep precision when using a feerate (which is rounded to the nearest satoshi per kvb) that isn't just an integer. Github-Pull: #33106 Rebased-From: 457cfb61b5323a13218b3cfb5a6a6d8b3a7c5f7f --- src/test/util/setup_common.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index bf26997c076..29327d461ba 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -571,6 +572,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.