Skip to content

Commit 457cfb6

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.
1 parent 3eab8b7 commit 457cfb6

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
@@ -40,6 +40,7 @@
4040
#include <test/util/coverage.h>
4141
#include <test/util/net.h>
4242
#include <test/util/random.h>
43+
#include <test/util/transaction_utils.h>
4344
#include <test/util/txmempool.h>
4445
#include <txdb.h>
4546
#include <txmempool.h>
@@ -586,6 +587,9 @@ void TestChain100Setup::MockMempoolMinFee(const CFeeRate& target_feerate)
586587
CMutableTransaction mtx = CMutableTransaction();
587588
mtx.vin.emplace_back(COutPoint{Txid::FromUint256(m_rng.rand256()), 0});
588589
mtx.vout.emplace_back(1 * COIN, GetScriptForDestination(WitnessV0ScriptHash(CScript() << OP_TRUE)));
590+
// Set a large size so that the fee evaluated at target_feerate (which is usually in sats/kvB) is an integer.
591+
// Otherwise, GetMinFee() may end up slightly different from target_feerate.
592+
BulkTransaction(mtx, 4000);
589593
const auto tx{MakeTransactionRef(mtx)};
590594
LockPoints lp;
591595
// The new mempool min feerate is equal to the removed package's feerate + incremental feerate.

0 commit comments

Comments
 (0)