Skip to content

Commit 732ad8e

Browse files
committed
[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: bitcoin#33106 Rebased-From: 457cfb6
1 parent fbee36f commit 732ad8e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/test/util/setup_common.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <streams.h>
4242
#include <test/util/net.h>
4343
#include <test/util/random.h>
44+
#include <test/util/transaction_utils.h>
4445
#include <test/util/txmempool.h>
4546
#include <txdb.h>
4647
#include <txmempool.h>
@@ -582,6 +583,9 @@ void TestChain100Setup::MockMempoolMinFee(const CFeeRate& target_feerate)
582583
CMutableTransaction mtx = CMutableTransaction();
583584
mtx.vin.emplace_back(COutPoint{Txid::FromUint256(g_insecure_rand_ctx.rand256()), 0});
584585
mtx.vout.emplace_back(1 * COIN, GetScriptForDestination(WitnessV0ScriptHash(CScript() << OP_TRUE)));
586+
// Set a large size so that the fee evaluated at target_feerate (which is usually in sats/kvB) is an integer.
587+
// Otherwise, GetMinFee() may end up slightly different from target_feerate.
588+
BulkTransaction(mtx, 4000);
585589
const auto tx{MakeTransactionRef(mtx)};
586590
LockPoints lp;
587591
// The new mempool min feerate is equal to the removed package's feerate + incremental feerate.

0 commit comments

Comments
 (0)