Skip to content
Bitcoin Roots

v29.4-roots.2 · Commit 3: [PATCH 03/21] 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. Before is on the left; after is on the right. Unified view fits narrow screens more easily.

src/test/miner_tests.cpp CHANGED
@@ -151,6 +151,15 @@ void MinerTestingSetup::TestPackageSelection(const CScript& scriptPubKey, const
151
  BOOST_CHECK(block.vtx[2]->GetHash() == hashHighFeeTx);
152
  BOOST_CHECK(block.vtx[3]->GetHash() == hashMediumFeeTx);
153
 
 
 
 
 
 
 
 
 
 
154
  // Test the inclusion of package feerates in the block template and ensure they are sequential.
155
  const auto block_package_feerates = BlockAssembler{m_node.chainman->ActiveChainstate(), &tx_mempool, options}.CreateNewBlock()->m_package_feerates;
156
  BOOST_CHECK(block_package_feerates.size() == 2);
@@ -220,7 +229,8 @@ void MinerTestingSetup::TestPackageSelection(const CScript& scriptPubKey, const
220
  // This tx can't be mined by itself
221
  tx.vin[0].prevout.hash = hashFreeTx2;
222
  tx.vout.resize(1);
223
- feeToUse = blockMinFeeRate.GetFee(freeTxSize);
 
224
  tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse;
225
  Txid hashLowFeeTx2 = tx.GetHash();
226
  AddToMempool(tx_mempool, entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx));
@@ -658,6 +668,8 @@ void MinerTestingSetup::TestPrioritisedMining(const CScript& scriptPubKey, const
658
  // NOTE: These tests rely on CreateNewBlock doing its own self-validation!
659
  BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
660
  {
 
 
661
  auto mining{MakeMining()};
662
  BOOST_REQUIRE(mining);
663
 
 
151
  BOOST_CHECK(block.vtx[2]->GetHash() == hashHighFeeTx);
152
  BOOST_CHECK(block.vtx[3]->GetHash() == hashMediumFeeTx);
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
+
163
  // Test the inclusion of package feerates in the block template and ensure they are sequential.
164
  const auto block_package_feerates = BlockAssembler{m_node.chainman->ActiveChainstate(), &tx_mempool, options}.CreateNewBlock()->m_package_feerates;
165
  BOOST_CHECK(block_package_feerates.size() == 2);
 
229
  // This tx can't be mined by itself
230
  tx.vin[0].prevout.hash = hashFreeTx2;
231
  tx.vout.resize(1);
232
+ const size_t lowFeeTx2VSize = GetVirtualTransactionSize(CTransaction{tx});
233
+ feeToUse = blockMinFeeRate.GetFee(lowFeeTx2VSize);
234
  tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse;
235
  Txid hashLowFeeTx2 = tx.GetHash();
236
  AddToMempool(tx_mempool, entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx));
 
668
  // NOTE: These tests rely on CreateNewBlock doing its own self-validation!
669
  BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
670
  {
671
+ gArgs.ForceSetArg("-blockprioritysize", "0");
672
+
673
  auto mining{MakeMining()};
674
  BOOST_REQUIRE(mining);
675