@@ -122,7 +122,7 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
122
122
uint256 hashHighFeeTx = tx.GetHash ();
123
123
m_node.mempool ->addUnchecked (entry.Fee (50000 ).Time (GetTime ()).SpendsCoinbase (false ).FromTx (tx));
124
124
125
- std::unique_ptr<CBlockTemplate> pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey);
125
+ std::unique_ptr<CBlockTemplate> pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey);
126
126
BOOST_REQUIRE_EQUAL (pblocktemplate->block .vtx .size (), 4U );
127
127
BOOST_CHECK (pblocktemplate->block .vtx [1 ]->GetHash () == hashParentTx);
128
128
BOOST_CHECK (pblocktemplate->block .vtx [2 ]->GetHash () == hashHighFeeTx);
@@ -143,7 +143,7 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
143
143
tx.vout [0 ].nValue = 5000000000LL - 1000 - 50000 - feeToUse;
144
144
uint256 hashLowFeeTx = tx.GetHash ();
145
145
m_node.mempool ->addUnchecked (entry.Fee (feeToUse).FromTx (tx));
146
- pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey);
146
+ pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey);
147
147
// Verify that the free tx and the low fee tx didn't get selected
148
148
for (size_t i=0 ; i<pblocktemplate->block .vtx .size (); ++i) {
149
149
BOOST_CHECK (pblocktemplate->block .vtx [i]->GetHash () != hashFreeTx);
@@ -157,7 +157,7 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
157
157
tx.vout [0 ].nValue -= 2 ; // Now we should be just over the min relay fee
158
158
hashLowFeeTx = tx.GetHash ();
159
159
m_node.mempool ->addUnchecked (entry.Fee (feeToUse+2 ).FromTx (tx));
160
- pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey);
160
+ pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey);
161
161
BOOST_REQUIRE_EQUAL (pblocktemplate->block .vtx .size (), 6U );
162
162
BOOST_CHECK (pblocktemplate->block .vtx [4 ]->GetHash () == hashFreeTx);
163
163
BOOST_CHECK (pblocktemplate->block .vtx [5 ]->GetHash () == hashLowFeeTx);
@@ -179,7 +179,7 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
179
179
tx.vout [0 ].nValue = 5000000000LL - 100000000 - feeToUse;
180
180
uint256 hashLowFeeTx2 = tx.GetHash ();
181
181
m_node.mempool ->addUnchecked (entry.Fee (feeToUse).SpendsCoinbase (false ).FromTx (tx));
182
- pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey);
182
+ pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey);
183
183
184
184
// Verify that this tx isn't selected.
185
185
for (size_t i=0 ; i<pblocktemplate->block .vtx .size (); ++i) {
@@ -192,7 +192,7 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
192
192
tx.vin [0 ].prevout .n = 1 ;
193
193
tx.vout [0 ].nValue = 100000000 - 10000 ; // 10k satoshi fee
194
194
m_node.mempool ->addUnchecked (entry.Fee (10000 ).FromTx (tx));
195
- pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey);
195
+ pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey);
196
196
BOOST_REQUIRE_EQUAL (pblocktemplate->block .vtx .size (), 9U );
197
197
BOOST_CHECK (pblocktemplate->block .vtx [8 ]->GetHash () == hashLowFeeTx2);
198
198
}
@@ -215,7 +215,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
215
215
fCheckpointsEnabled = false ;
216
216
217
217
// Simple block creation, nothing special yet:
218
- BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
218
+ BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey));
219
219
220
220
// We can't make transactions until we have inputs
221
221
// Therefore, load 110 blocks :)
@@ -252,7 +252,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
252
252
LOCK (m_node.mempool ->cs );
253
253
254
254
// Just to make sure we can still make simple blocks
255
- BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
255
+ BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey));
256
256
257
257
const CAmount BLOCKSUBSIDY = 50 *COIN;
258
258
const CAmount LOWFEE = CENT;
@@ -277,7 +277,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
277
277
tx.vin [0 ].prevout .hash = hash;
278
278
}
279
279
280
- BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" bad-blk-sigops" ));
280
+ BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey), std::runtime_error, HasReason (" bad-blk-sigops" ));
281
281
m_node.mempool ->clear ();
282
282
283
283
tx.vin [0 ].prevout .hash = txFirst[0 ]->GetHash ();
@@ -291,7 +291,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
291
291
m_node.mempool ->addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (spendsCoinbase).SigOpsCost (80 ).FromTx (tx));
292
292
tx.vin [0 ].prevout .hash = hash;
293
293
}
294
- BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
294
+ BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey));
295
295
m_node.mempool ->clear ();
296
296
297
297
// block size > limit
@@ -311,13 +311,13 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
311
311
m_node.mempool ->addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (spendsCoinbase).FromTx (tx));
312
312
tx.vin [0 ].prevout .hash = hash;
313
313
}
314
- BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
314
+ BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey));
315
315
m_node.mempool ->clear ();
316
316
317
317
// orphan in *m_node.mempool, template creation fails
318
318
hash = tx.GetHash ();
319
319
m_node.mempool ->addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).FromTx (tx));
320
- BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" bad-txns-inputs-missingorspent" ));
320
+ BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey), std::runtime_error, HasReason (" bad-txns-inputs-missingorspent" ));
321
321
m_node.mempool ->clear ();
322
322
323
323
// child with higher feerate than parent
@@ -334,7 +334,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
334
334
tx.vout [0 ].nValue = tx.vout [0 ].nValue +BLOCKSUBSIDY-HIGHERFEE; // First txn output + fresh coinbase - new txn fee
335
335
hash = tx.GetHash ();
336
336
m_node.mempool ->addUnchecked (entry.Fee (HIGHERFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
337
- BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
337
+ BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey));
338
338
m_node.mempool ->clear ();
339
339
340
340
// coinbase in *m_node.mempool, template creation fails
@@ -346,7 +346,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
346
346
// give it a fee so it'll get mined
347
347
m_node.mempool ->addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (false ).FromTx (tx));
348
348
// Should throw bad-cb-multiple
349
- BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" bad-cb-multiple" ));
349
+ BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey), std::runtime_error, HasReason (" bad-cb-multiple" ));
350
350
m_node.mempool ->clear ();
351
351
352
352
// double spend txn pair in *m_node.mempool, template creation fails
@@ -359,7 +359,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
359
359
tx.vout [0 ].scriptPubKey = CScript () << OP_2;
360
360
hash = tx.GetHash ();
361
361
m_node.mempool ->addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
362
- BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" bad-txns-inputs-missingorspent" ));
362
+ BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey), std::runtime_error, HasReason (" bad-txns-inputs-missingorspent" ));
363
363
m_node.mempool ->clear ();
364
364
365
365
// subsidy changing
@@ -375,7 +375,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
375
375
next->BuildSkip ();
376
376
::ChainActive ().SetTip(next);
377
377
}
378
- BOOST_CHECK (pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
378
+ BOOST_CHECK (pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(::ChainstateActive(), scriptPubKey));
379
379
// Extend to a 210000-long block chain.
380
380
while (::ChainActive().Tip()->nHeight < 210000) {
381
381
CBlockIndex* prev = ::ChainActive ().Tip ();
@@ -387,7 +387,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
387
387
next->BuildSkip ();
388
388
::ChainActive ().SetTip(next);
389
389
}
390
- BOOST_CHECK (pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
390
+ BOOST_CHECK (pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(::ChainstateActive(), scriptPubKey));
391
391
392
392
// invalid p2sh txn in *m_node.mempool, template creation fails
393
393
tx.vin[0 ].prevout.hash = txFirst[0 ]->GetHash ();
@@ -404,7 +404,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
404
404
hash = tx.GetHash ();
405
405
m_node.mempool ->addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (false ).FromTx (tx));
406
406
// Should throw block-validation-failed
407
- BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" block-validation-failed" ));
407
+ BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey), std::runtime_error, HasReason (" block-validation-failed" ));
408
408
m_node.mempool ->clear ();
409
409
410
410
// Delete the dummy blocks again.
@@ -492,7 +492,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
492
492
tx.vin [0 ].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | 1 ;
493
493
BOOST_CHECK (!TestSequenceLocks (CTransaction (tx), flags)); // Sequence locks fail
494
494
495
- BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
495
+ BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey));
496
496
497
497
// None of the of the absolute height/time locked tx should have made
498
498
// it into the template because we still check IsFinalTx in CreateNewBlock,
@@ -505,7 +505,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
505
505
::ChainActive ().Tip()->nHeight++;
506
506
SetMockTime (::ChainActive ().Tip ()->GetMedianTimePast () + 1 );
507
507
508
- BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
508
+ BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (:: ChainstateActive (), scriptPubKey));
509
509
BOOST_CHECK_EQUAL (pblocktemplate->block .vtx .size (), 5U );
510
510
511
511
::ChainActive ().Tip()->nHeight--;
0 commit comments