v29.4-roots.3 · Commit 3: [PATCH 03/30] policy: restore conservative relay and network controls
src/test/miner_tests.cpp
Before: src/test/miner_tests.cpp · After: src/test/miner_tests.cpp
File metadata
index 10f8be4b324dae7b7b5679619db84ede7b2b4f91..8a8b9344957722e887c034f8c53952ad51651581 100644
Download original patch · Release notes
Diff rows 1–32 of 32. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
src/test/miner_tests.cpp
CHANGED
|
@@ -151,6 +151,15 @@ void MinerTestingSetup::TestPackageSelection(const CScript& scriptPubKey, const
|
|
|
151
151
|
BOOST_CHECK(block.vtx[2]->GetHash() == hashHighFeeTx);
|
|
152
152
|
BOOST_CHECK(block.vtx[3]->GetHash() == hashMediumFeeTx);
|
|
153
153
|
|
|
154
|
+
// The fee-selected parent/child package must also respect an explicit
|
|
155
|
+
// serialized-size cap. The default-weight template above remains free to
|
|
156
|
+
// include the same package.
|
|
157
|
+
BlockAssembler::Options size_limited_options{options};
|
|
158
|
+
size_limited_options.nBlockMaxSize = DEFAULT_BLOCK_RESERVED_SIZE + ::GetSerializeSize(TX_WITH_WITNESS(parent_tx.GetTx()));
|
|
159
|
+
const auto size_limited_block = BlockAssembler{m_node.chainman->ActiveChainstate(), &tx_mempool, size_limited_options}.CreateNewBlock();
|
|
160
|
+
BOOST_REQUIRE(size_limited_block);
|
|
161
|
+
BOOST_CHECK_EQUAL(size_limited_block->block.vtx.size(), 1U);
|
|
162
|
+
|
|
154
163
|
// Test the inclusion of package feerates in the block template and ensure they are sequential.
|
|
155
164
|
const auto block_package_feerates = BlockAssembler{m_node.chainman->ActiveChainstate(), &tx_mempool, options}.CreateNewBlock()->m_package_feerates;
|
|
156
165
|
BOOST_CHECK(block_package_feerates.size() == 2);
|
|
@@ -220,7 +229,8 @@ void MinerTestingSetup::TestPackageSelection(const CScript& scriptPubKey, const
|
|
|
220
229
|
// This tx can't be mined by itself
|
|
221
230
|
tx.vin[0].prevout.hash = hashFreeTx2;
|
|
222
231
|
tx.vout.resize(1);
|
|
223
|
-
feeToUse = blockMinFeeRate.GetFee(freeTxSize);
|
|
232
|
+
const size_t lowFeeTx2VSize = GetVirtualTransactionSize(CTransaction{tx});
|
|
233
|
+
feeToUse = blockMinFeeRate.GetFee(lowFeeTx2VSize);
|
|
224
234
|
tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse;
|
|
225
235
|
Txid hashLowFeeTx2 = tx.GetHash();
|
|
226
236
|
AddToMempool(tx_mempool, entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx));
|
|
@@ -658,6 +668,8 @@ void MinerTestingSetup::TestPrioritisedMining(const CScript& scriptPubKey, const
|
|
|
658
668
|
// NOTE: These tests rely on CreateNewBlock doing its own self-validation!
|
|
659
669
|
BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|
660
670
|
{
|
|
671
|
+
gArgs.ForceSetArg("-blockprioritysize", "0");
|
|
672
|
+
|
|
661
673
|
auto mining{MakeMining()};
|
|
662
674
|
BOOST_REQUIRE(mining);
|
|
663
675
|
|