@@ -45,7 +45,7 @@ BlockAssembler MinerTestingSetup::AssemblerForTest(const CChainParams& params)
45
45
46
46
options.nBlockMaxWeight = MAX_BLOCK_WEIGHT;
47
47
options.blockMinFeeRate = blockMinFeeRate;
48
- return BlockAssembler (:: ChainstateActive (), *m_node.mempool , params, options);
48
+ return BlockAssembler (m_node. chainman -> ActiveChainstate (), *m_node.mempool , params, options);
49
49
}
50
50
51
51
constexpr static struct {
@@ -228,17 +228,17 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
228
228
{
229
229
LOCK (cs_main);
230
230
pblock->nVersion = 1 ;
231
- pblock->nTime = :: ChainActive ().Tip ()->GetMedianTimePast ()+1 ;
231
+ pblock->nTime = m_node. chainman -> ActiveChain ().Tip ()->GetMedianTimePast ()+1 ;
232
232
CMutableTransaction txCoinbase (*pblock->vtx [0 ]);
233
233
txCoinbase.nVersion = 1 ;
234
234
txCoinbase.vin [0 ].scriptSig = CScript ();
235
235
txCoinbase.vin [0 ].scriptSig .push_back (bi.extranonce );
236
- txCoinbase.vin [0 ].scriptSig .push_back (:: ChainActive ().Height ());
236
+ txCoinbase.vin [0 ].scriptSig .push_back (m_node. chainman -> ActiveChain ().Height ());
237
237
txCoinbase.vout .resize (1 ); // Ignore the (optional) segwit commitment added by CreateNewBlock (as the hardcoded nonces don't account for this)
238
238
txCoinbase.vout [0 ].scriptPubKey = CScript ();
239
239
pblock->vtx [0 ] = MakeTransactionRef (std::move (txCoinbase));
240
240
if (txFirst.size () == 0 )
241
- baseheight = :: ChainActive ().Height ();
241
+ baseheight = m_node. chainman -> ActiveChain ().Height ();
242
242
if (txFirst.size () < 4 )
243
243
txFirst.push_back (pblock->vtx [0 ]);
244
244
pblock->hashMerkleRoot = BlockMerkleRoot (*pblock);
@@ -364,29 +364,29 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
364
364
m_node.mempool ->clear ();
365
365
366
366
// subsidy changing
367
- int nHeight = :: ChainActive ().Height ();
367
+ int nHeight = m_node. chainman -> ActiveChain ().Height ();
368
368
// Create an actual 209999-long block chain (without valid blocks).
369
- while (:: ChainActive ().Tip ()->nHeight < 209999 ) {
370
- CBlockIndex* prev = :: ChainActive ().Tip ();
369
+ while (m_node. chainman -> ActiveChain ().Tip ()->nHeight < 209999 ) {
370
+ CBlockIndex* prev = m_node. chainman -> ActiveChain ().Tip ();
371
371
CBlockIndex* next = new CBlockIndex ();
372
372
next->phashBlock = new uint256 (InsecureRand256 ());
373
- ::ChainstateActive ().CoinsTip().SetBestBlock(next->GetBlockHash ());
373
+ m_node. chainman -> ActiveChainstate ().CoinsTip ().SetBestBlock (next->GetBlockHash ());
374
374
next->pprev = prev;
375
375
next->nHeight = prev->nHeight + 1 ;
376
376
next->BuildSkip ();
377
- ::ChainActive ().SetTip(next);
377
+ m_node. chainman -> ActiveChain ().SetTip (next);
378
378
}
379
379
BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
380
380
// Extend to a 210000-long block chain.
381
- while (::ChainActive ().Tip()->nHeight < 210000) {
382
- CBlockIndex* prev = :: ChainActive ().Tip ();
381
+ while (m_node. chainman -> ActiveChain ().Tip ()->nHeight < 210000 ) {
382
+ CBlockIndex* prev = m_node. chainman -> ActiveChain ().Tip ();
383
383
CBlockIndex* next = new CBlockIndex ();
384
384
next->phashBlock = new uint256 (InsecureRand256 ());
385
- ::ChainstateActive ().CoinsTip().SetBestBlock(next->GetBlockHash ());
385
+ m_node. chainman -> ActiveChainstate ().CoinsTip ().SetBestBlock (next->GetBlockHash ());
386
386
next->pprev = prev;
387
387
next->nHeight = prev->nHeight + 1 ;
388
388
next->BuildSkip ();
389
- ::ChainActive ().SetTip(next);
389
+ m_node. chainman -> ActiveChain ().SetTip (next);
390
390
}
391
391
BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
392
392
@@ -409,16 +409,16 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
409
409
m_node.mempool ->clear ();
410
410
411
411
// Delete the dummy blocks again.
412
- while (:: ChainActive ().Tip ()->nHeight > nHeight) {
413
- CBlockIndex* del = :: ChainActive ().Tip ();
414
- ::ChainActive ().SetTip(del->pprev);
415
- ::ChainstateActive ().CoinsTip().SetBestBlock(del->pprev->GetBlockHash ());
412
+ while (m_node. chainman -> ActiveChain ().Tip ()->nHeight > nHeight) {
413
+ CBlockIndex* del = m_node. chainman -> ActiveChain ().Tip ();
414
+ m_node. chainman -> ActiveChain ().SetTip (del->pprev );
415
+ m_node. chainman -> ActiveChainstate ().CoinsTip ().SetBestBlock (del->pprev ->GetBlockHash ());
416
416
delete del->phashBlock ;
417
417
delete del;
418
418
}
419
419
420
420
// non-final txs in mempool
421
- SetMockTime (::ChainActive ().Tip()->GetMedianTimePast()+1);
421
+ SetMockTime (m_node. chainman -> ActiveChain ().Tip ()->GetMedianTimePast ()+1 );
422
422
int flags = LOCKTIME_VERIFY_SEQUENCE|LOCKTIME_MEDIAN_TIME_PAST;
423
423
// height map
424
424
std::vector<int > prevheights;
@@ -430,15 +430,15 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
430
430
tx.vin [0 ].prevout .hash = txFirst[0 ]->GetHash (); // only 1 transaction
431
431
tx.vin [0 ].prevout .n = 0 ;
432
432
tx.vin [0 ].scriptSig = CScript () << OP_1;
433
- tx.vin [0 ].nSequence = :: ChainActive ().Tip ()->nHeight + 1 ; // txFirst[0] is the 2nd block
433
+ tx.vin [0 ].nSequence = m_node. chainman -> ActiveChain ().Tip ()->nHeight + 1 ; // txFirst[0] is the 2nd block
434
434
prevheights[0 ] = baseheight + 1 ;
435
435
tx.vout .resize (1 );
436
436
tx.vout [0 ].nValue = BLOCKSUBSIDY-HIGHFEE;
437
437
tx.vout [0 ].scriptPubKey = CScript () << OP_1;
438
438
tx.nLockTime = 0 ;
439
439
hash = tx.GetHash ();
440
440
m_node.mempool ->addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
441
- BOOST_CHECK (CheckFinalTx (:: ChainActive ().Tip (), CTransaction (tx), flags)); // Locktime passes
441
+ BOOST_CHECK (CheckFinalTx (m_node. chainman -> ActiveChain ().Tip (), CTransaction (tx), flags)); // Locktime passes
442
442
BOOST_CHECK (!TestSequenceLocks (CTransaction (tx), flags)); // Sequence locks fail
443
443
444
444
{
@@ -448,11 +448,11 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
448
448
449
449
// relative time locked
450
450
tx.vin [0 ].prevout .hash = txFirst[1 ]->GetHash ();
451
- tx.vin [0 ].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | (((:: ChainActive ().Tip ()->GetMedianTimePast ()+1 -:: ChainActive ()[1 ]->GetMedianTimePast ()) >> CTxIn::SEQUENCE_LOCKTIME_GRANULARITY) + 1 ); // txFirst[1] is the 3rd block
451
+ tx.vin [0 ].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | (((m_node. chainman -> ActiveChain ().Tip ()->GetMedianTimePast ()+1 -m_node. chainman -> ActiveChain ()[1 ]->GetMedianTimePast ()) >> CTxIn::SEQUENCE_LOCKTIME_GRANULARITY) + 1 ); // txFirst[1] is the 3rd block
452
452
prevheights[0 ] = baseheight + 2 ;
453
453
hash = tx.GetHash ();
454
454
m_node.mempool ->addUnchecked (entry.Time (GetTime ()).FromTx (tx));
455
- BOOST_CHECK (CheckFinalTx (:: ChainActive ().Tip (), CTransaction (tx), flags)); // Locktime passes
455
+ BOOST_CHECK (CheckFinalTx (m_node. chainman -> ActiveChain ().Tip (), CTransaction (tx), flags)); // Locktime passes
456
456
BOOST_CHECK (!TestSequenceLocks (CTransaction (tx), flags)); // Sequence locks fail
457
457
458
458
for (int i = 0 ; i < CBlockIndex::nMedianTimeSpan; i++)
@@ -464,36 +464,36 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
464
464
}
465
465
466
466
for (int i = 0 ; i < CBlockIndex::nMedianTimeSpan; i++)
467
- ::ChainActive ().Tip()->GetAncestor(::ChainActive ().Tip()->nHeight - i)->nTime -= 512; // undo tricked MTP
467
+ m_node. chainman -> ActiveChain ().Tip ()->GetAncestor (m_node. chainman -> ActiveChain ().Tip ()->nHeight - i)->nTime -= 512 ; // undo tricked MTP
468
468
469
469
// absolute height locked
470
470
tx.vin [0 ].prevout .hash = txFirst[2 ]->GetHash ();
471
471
tx.vin [0 ].nSequence = CTxIn::SEQUENCE_FINAL - 1 ;
472
472
prevheights[0 ] = baseheight + 3 ;
473
- tx.nLockTime = :: ChainActive ().Tip ()->nHeight + 1 ;
473
+ tx.nLockTime = m_node. chainman -> ActiveChain ().Tip ()->nHeight + 1 ;
474
474
hash = tx.GetHash ();
475
475
m_node.mempool ->addUnchecked (entry.Time (GetTime ()).FromTx (tx));
476
- BOOST_CHECK (!CheckFinalTx (:: ChainActive ().Tip (), CTransaction (tx), flags)); // Locktime fails
476
+ BOOST_CHECK (!CheckFinalTx (m_node. chainman -> ActiveChain ().Tip (), CTransaction (tx), flags)); // Locktime fails
477
477
BOOST_CHECK (TestSequenceLocks (CTransaction (tx), flags)); // Sequence locks pass
478
- BOOST_CHECK (IsFinalTx (CTransaction (tx), :: ChainActive ().Tip ()->nHeight + 2 , :: ChainActive ().Tip ()->GetMedianTimePast ())); // Locktime passes on 2nd block
478
+ BOOST_CHECK (IsFinalTx (CTransaction (tx), m_node. chainman -> ActiveChain ().Tip ()->nHeight + 2 , m_node. chainman -> ActiveChain ().Tip ()->GetMedianTimePast ())); // Locktime passes on 2nd block
479
479
480
480
// absolute time locked
481
481
tx.vin [0 ].prevout .hash = txFirst[3 ]->GetHash ();
482
- tx.nLockTime = :: ChainActive ().Tip ()->GetMedianTimePast ();
482
+ tx.nLockTime = m_node. chainman -> ActiveChain ().Tip ()->GetMedianTimePast ();
483
483
prevheights.resize (1 );
484
484
prevheights[0 ] = baseheight + 4 ;
485
485
hash = tx.GetHash ();
486
486
m_node.mempool ->addUnchecked (entry.Time (GetTime ()).FromTx (tx));
487
- BOOST_CHECK (!CheckFinalTx (:: ChainActive ().Tip (), CTransaction (tx), flags)); // Locktime fails
487
+ BOOST_CHECK (!CheckFinalTx (m_node. chainman -> ActiveChain ().Tip (), CTransaction (tx), flags)); // Locktime fails
488
488
BOOST_CHECK (TestSequenceLocks (CTransaction (tx), flags)); // Sequence locks pass
489
- BOOST_CHECK (IsFinalTx (CTransaction (tx), :: ChainActive ().Tip ()->nHeight + 2 , :: ChainActive ().Tip ()->GetMedianTimePast () + 1 )); // Locktime passes 1 second later
489
+ BOOST_CHECK (IsFinalTx (CTransaction (tx), m_node. chainman -> ActiveChain ().Tip ()->nHeight + 2 , m_node. chainman -> ActiveChain ().Tip ()->GetMedianTimePast () + 1 )); // Locktime passes 1 second later
490
490
491
491
// mempool-dependent transactions (not added)
492
492
tx.vin [0 ].prevout .hash = hash;
493
- prevheights[0 ] = :: ChainActive ().Tip ()->nHeight + 1 ;
493
+ prevheights[0 ] = m_node. chainman -> ActiveChain ().Tip ()->nHeight + 1 ;
494
494
tx.nLockTime = 0 ;
495
495
tx.vin [0 ].nSequence = 0 ;
496
- BOOST_CHECK (CheckFinalTx (:: ChainActive ().Tip (), CTransaction (tx), flags)); // Locktime passes
496
+ BOOST_CHECK (CheckFinalTx (m_node. chainman -> ActiveChain ().Tip (), CTransaction (tx), flags)); // Locktime passes
497
497
BOOST_CHECK (TestSequenceLocks (CTransaction (tx), flags)); // Sequence locks pass
498
498
tx.vin [0 ].nSequence = 1 ;
499
499
BOOST_CHECK (!TestSequenceLocks (CTransaction (tx), flags)); // Sequence locks fail
@@ -511,14 +511,14 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
511
511
BOOST_CHECK_EQUAL (pblocktemplate->block .vtx .size (), 3U );
512
512
// However if we advance height by 1 and time by 512, all of them should be mined
513
513
for (int i = 0 ; i < CBlockIndex::nMedianTimeSpan; i++)
514
- ::ChainActive ().Tip()->GetAncestor(::ChainActive ().Tip()->nHeight - i)->nTime += 512; // Trick the MedianTimePast
515
- ::ChainActive ().Tip()->nHeight++;
516
- SetMockTime (:: ChainActive ().Tip ()->GetMedianTimePast () + 1 );
514
+ m_node. chainman -> ActiveChain ().Tip ()->GetAncestor (m_node. chainman -> ActiveChain ().Tip ()->nHeight - i)->nTime += 512 ; // Trick the MedianTimePast
515
+ m_node. chainman -> ActiveChain ().Tip ()->nHeight ++;
516
+ SetMockTime (m_node. chainman -> ActiveChain ().Tip ()->GetMedianTimePast () + 1 );
517
517
518
518
BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
519
519
BOOST_CHECK_EQUAL (pblocktemplate->block .vtx .size (), 5U );
520
520
521
- ::ChainActive ().Tip()->nHeight--;
521
+ m_node. chainman -> ActiveChain ().Tip ()->nHeight --;
522
522
SetMockTime (0 );
523
523
m_node.mempool ->clear ();
524
524
0 commit comments