Skip to content

Commit 0d61634

Browse files
committed
scripted-diff: test: Use existing chainman in unit tests
-BEGIN VERIFY SCRIPT- git ls-files -- src/test \ | grep -v '^src/test/fuzz' \ | xargs sed -i -E \ -e 's@g_chainman\.m_blockman@m_node.chainman->m_blockman@g' \ -e 's@([^:])(Chain(state|)Active)@\1::\2@g' \ -e 's@::Chain(state|)Active\(\)@m_node.chainman->ActiveChain\1()@g' -END VERIFY SCRIPT-
1 parent e197076 commit 0d61634

10 files changed

+93
-93
lines changed

src/test/blockfilter_index_tests.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ CBlock BuildChainTestingSetup::CreateBlock(const CBlockIndex* prev,
6262
const CScript& scriptPubKey)
6363
{
6464
const CChainParams& chainparams = Params();
65-
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler(::ChainstateActive(), *m_node.mempool, chainparams).CreateNewBlock(scriptPubKey);
65+
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler(m_node.chainman->ActiveChainstate(), *m_node.mempool, chainparams).CreateNewBlock(scriptPubKey);
6666
CBlock& block = pblocktemplate->block;
6767
block.hashPrevBlock = prev->GetBlockHash();
6868
block.nTime = prev->nTime + 1;
@@ -117,9 +117,9 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, BuildChainTestingSetup)
117117
std::vector<BlockFilter> filters;
118118
std::vector<uint256> filter_hashes;
119119

120-
for (const CBlockIndex* block_index = ::ChainActive().Genesis();
120+
for (const CBlockIndex* block_index = m_node.chainman->ActiveChain().Genesis();
121121
block_index != nullptr;
122-
block_index = ::ChainActive().Next(block_index)) {
122+
block_index = m_node.chainman->ActiveChain().Next(block_index)) {
123123
BOOST_CHECK(!filter_index.LookupFilter(block_index, filter));
124124
BOOST_CHECK(!filter_index.LookupFilterHeader(block_index, filter_header));
125125
BOOST_CHECK(!filter_index.LookupFilterRange(block_index->nHeight, block_index, filters));
@@ -131,7 +131,7 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, BuildChainTestingSetup)
131131
// BlockUntilSyncedToCurrentChain should return false before index is started.
132132
BOOST_CHECK(!filter_index.BlockUntilSyncedToCurrentChain());
133133

134-
BOOST_REQUIRE(filter_index.Start(::ChainstateActive()));
134+
BOOST_REQUIRE(filter_index.Start(m_node.chainman->ActiveChainstate()));
135135

136136
// Allow filter index to catch up with the block index.
137137
constexpr int64_t timeout_ms = 10 * 1000;
@@ -145,9 +145,9 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, BuildChainTestingSetup)
145145
{
146146
LOCK(cs_main);
147147
const CBlockIndex* block_index;
148-
for (block_index = ::ChainActive().Genesis();
148+
for (block_index = m_node.chainman->ActiveChain().Genesis();
149149
block_index != nullptr;
150-
block_index = ::ChainActive().Next(block_index)) {
150+
block_index = m_node.chainman->ActiveChain().Next(block_index)) {
151151
CheckFilterLookups(filter_index, block_index, last_header);
152152
}
153153
}
@@ -156,7 +156,7 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, BuildChainTestingSetup)
156156
const CBlockIndex* tip;
157157
{
158158
LOCK(cs_main);
159-
tip = ::ChainActive().Tip();
159+
tip = m_node.chainman->ActiveChain().Tip();
160160
}
161161
CKey coinbase_key_A, coinbase_key_B;
162162
coinbase_key_A.MakeNewKey(true);
@@ -178,7 +178,7 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, BuildChainTestingSetup)
178178
const CBlockIndex* block_index;
179179
{
180180
LOCK(cs_main);
181-
block_index = g_chainman.m_blockman.LookupBlockIndex(block->GetHash());
181+
block_index = m_node.chainman->m_blockman.LookupBlockIndex(block->GetHash());
182182
}
183183

184184
BOOST_CHECK(filter_index.BlockUntilSyncedToCurrentChain());
@@ -196,7 +196,7 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, BuildChainTestingSetup)
196196
const CBlockIndex* block_index;
197197
{
198198
LOCK(cs_main);
199-
block_index = g_chainman.m_blockman.LookupBlockIndex(block->GetHash());
199+
block_index = m_node.chainman->m_blockman.LookupBlockIndex(block->GetHash());
200200
}
201201

202202
BOOST_CHECK(filter_index.BlockUntilSyncedToCurrentChain());
@@ -210,7 +210,7 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, BuildChainTestingSetup)
210210
const CBlockIndex* block_index;
211211
{
212212
LOCK(cs_main);
213-
block_index = g_chainman.m_blockman.LookupBlockIndex(block->GetHash());
213+
block_index = m_node.chainman->m_blockman.LookupBlockIndex(block->GetHash());
214214
}
215215

216216
BOOST_CHECK(filter_index.BlockUntilSyncedToCurrentChain());
@@ -231,14 +231,14 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, BuildChainTestingSetup)
231231

232232
{
233233
LOCK(cs_main);
234-
block_index = g_chainman.m_blockman.LookupBlockIndex(chainA[i]->GetHash());
234+
block_index = m_node.chainman->m_blockman.LookupBlockIndex(chainA[i]->GetHash());
235235
}
236236
BOOST_CHECK(filter_index.BlockUntilSyncedToCurrentChain());
237237
CheckFilterLookups(filter_index, block_index, chainA_last_header);
238238

239239
{
240240
LOCK(cs_main);
241-
block_index = g_chainman.m_blockman.LookupBlockIndex(chainB[i]->GetHash());
241+
block_index = m_node.chainman->m_blockman.LookupBlockIndex(chainB[i]->GetHash());
242242
}
243243
BOOST_CHECK(filter_index.BlockUntilSyncedToCurrentChain());
244244
CheckFilterLookups(filter_index, block_index, chainB_last_header);
@@ -250,7 +250,7 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, BuildChainTestingSetup)
250250

251251
{
252252
LOCK(cs_main);
253-
tip = ::ChainActive().Tip();
253+
tip = m_node.chainman->ActiveChain().Tip();
254254
}
255255
BOOST_CHECK(filter_index.LookupFilterRange(0, tip, filters));
256256
BOOST_CHECK(filter_index.LookupFilterHashRange(0, tip, filter_hashes));

src/test/coinstatsindex_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
2222
const CBlockIndex* block_index;
2323
{
2424
LOCK(cs_main);
25-
block_index = ChainActive().Tip();
25+
block_index = m_node.chainman->ActiveChain().Tip();
2626
}
2727

2828
// CoinStatsIndex should not be found before it is started.
@@ -32,7 +32,7 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
3232
// is started.
3333
BOOST_CHECK(!coin_stats_index.BlockUntilSyncedToCurrentChain());
3434

35-
BOOST_REQUIRE(coin_stats_index.Start(::ChainstateActive()));
35+
BOOST_REQUIRE(coin_stats_index.Start(m_node.chainman->ActiveChainstate()));
3636

3737
// Allow the CoinStatsIndex to catch up with the block index that is syncing
3838
// in a background thread.
@@ -46,7 +46,7 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
4646
const CBlockIndex* genesis_block_index;
4747
{
4848
LOCK(cs_main);
49-
genesis_block_index = ChainActive().Genesis();
49+
genesis_block_index = m_node.chainman->ActiveChain().Genesis();
5050
}
5151
BOOST_CHECK(coin_stats_index.LookUpStats(genesis_block_index, coin_stats));
5252

@@ -64,7 +64,7 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
6464
const CBlockIndex* new_block_index;
6565
{
6666
LOCK(cs_main);
67-
new_block_index = ChainActive().Tip();
67+
new_block_index = m_node.chainman->ActiveChain().Tip();
6868
}
6969
coin_stats_index.LookUpStats(new_block_index, new_coin_stats);
7070

src/test/denialofservice_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
8383
// This test requires that we have a chain with non-zero work.
8484
{
8585
LOCK(cs_main);
86-
BOOST_CHECK(::ChainActive().Tip() != nullptr);
87-
BOOST_CHECK(::ChainActive().Tip()->nChainWork > 0);
86+
BOOST_CHECK(m_node.chainman->ActiveChain().Tip() != nullptr);
87+
BOOST_CHECK(m_node.chainman->ActiveChain().Tip()->nChainWork > 0);
8888
}
8989

9090
// Test starts here

src/test/interfaces_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE(findCommonAncestor)
9898
auto* orig_tip = active.Tip();
9999
for (int i = 0; i < 10; ++i) {
100100
BlockValidationState state;
101-
ChainstateActive().InvalidateBlock(state, Params(), active.Tip());
101+
m_node.chainman->ActiveChainstate().InvalidateBlock(state, Params(), active.Tip());
102102
}
103103
BOOST_CHECK_EQUAL(active.Height(), orig_tip->nHeight - 10);
104104
coinbaseKey.MakeNewKey(true);

src/test/miner_tests.cpp

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ BlockAssembler MinerTestingSetup::AssemblerForTest(const CChainParams& params)
4545

4646
options.nBlockMaxWeight = MAX_BLOCK_WEIGHT;
4747
options.blockMinFeeRate = blockMinFeeRate;
48-
return BlockAssembler(::ChainstateActive(), *m_node.mempool, params, options);
48+
return BlockAssembler(m_node.chainman->ActiveChainstate(), *m_node.mempool, params, options);
4949
}
5050

5151
constexpr static struct {
@@ -228,17 +228,17 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
228228
{
229229
LOCK(cs_main);
230230
pblock->nVersion = 1;
231-
pblock->nTime = ::ChainActive().Tip()->GetMedianTimePast()+1;
231+
pblock->nTime = m_node.chainman->ActiveChain().Tip()->GetMedianTimePast()+1;
232232
CMutableTransaction txCoinbase(*pblock->vtx[0]);
233233
txCoinbase.nVersion = 1;
234234
txCoinbase.vin[0].scriptSig = CScript();
235235
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());
237237
txCoinbase.vout.resize(1); // Ignore the (optional) segwit commitment added by CreateNewBlock (as the hardcoded nonces don't account for this)
238238
txCoinbase.vout[0].scriptPubKey = CScript();
239239
pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
240240
if (txFirst.size() == 0)
241-
baseheight = ::ChainActive().Height();
241+
baseheight = m_node.chainman->ActiveChain().Height();
242242
if (txFirst.size() < 4)
243243
txFirst.push_back(pblock->vtx[0]);
244244
pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
@@ -364,29 +364,29 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
364364
m_node.mempool->clear();
365365

366366
// subsidy changing
367-
int nHeight = ::ChainActive().Height();
367+
int nHeight = m_node.chainman->ActiveChain().Height();
368368
// 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();
371371
CBlockIndex* next = new CBlockIndex();
372372
next->phashBlock = new uint256(InsecureRand256());
373-
::ChainstateActive().CoinsTip().SetBestBlock(next->GetBlockHash());
373+
m_node.chainman->ActiveChainstate().CoinsTip().SetBestBlock(next->GetBlockHash());
374374
next->pprev = prev;
375375
next->nHeight = prev->nHeight + 1;
376376
next->BuildSkip();
377-
::ChainActive().SetTip(next);
377+
m_node.chainman->ActiveChain().SetTip(next);
378378
}
379379
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
380380
// 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();
383383
CBlockIndex* next = new CBlockIndex();
384384
next->phashBlock = new uint256(InsecureRand256());
385-
::ChainstateActive().CoinsTip().SetBestBlock(next->GetBlockHash());
385+
m_node.chainman->ActiveChainstate().CoinsTip().SetBestBlock(next->GetBlockHash());
386386
next->pprev = prev;
387387
next->nHeight = prev->nHeight + 1;
388388
next->BuildSkip();
389-
::ChainActive().SetTip(next);
389+
m_node.chainman->ActiveChain().SetTip(next);
390390
}
391391
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
392392

@@ -409,16 +409,16 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
409409
m_node.mempool->clear();
410410

411411
// 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());
416416
delete del->phashBlock;
417417
delete del;
418418
}
419419

420420
// non-final txs in mempool
421-
SetMockTime(::ChainActive().Tip()->GetMedianTimePast()+1);
421+
SetMockTime(m_node.chainman->ActiveChain().Tip()->GetMedianTimePast()+1);
422422
int flags = LOCKTIME_VERIFY_SEQUENCE|LOCKTIME_MEDIAN_TIME_PAST;
423423
// height map
424424
std::vector<int> prevheights;
@@ -430,15 +430,15 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
430430
tx.vin[0].prevout.hash = txFirst[0]->GetHash(); // only 1 transaction
431431
tx.vin[0].prevout.n = 0;
432432
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
434434
prevheights[0] = baseheight + 1;
435435
tx.vout.resize(1);
436436
tx.vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
437437
tx.vout[0].scriptPubKey = CScript() << OP_1;
438438
tx.nLockTime = 0;
439439
hash = tx.GetHash();
440440
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
442442
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
443443

444444
{
@@ -448,11 +448,11 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
448448

449449
// relative time locked
450450
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
452452
prevheights[0] = baseheight + 2;
453453
hash = tx.GetHash();
454454
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
456456
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
457457

458458
for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++)
@@ -464,36 +464,36 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
464464
}
465465

466466
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
468468

469469
// absolute height locked
470470
tx.vin[0].prevout.hash = txFirst[2]->GetHash();
471471
tx.vin[0].nSequence = CTxIn::SEQUENCE_FINAL - 1;
472472
prevheights[0] = baseheight + 3;
473-
tx.nLockTime = ::ChainActive().Tip()->nHeight + 1;
473+
tx.nLockTime = m_node.chainman->ActiveChain().Tip()->nHeight + 1;
474474
hash = tx.GetHash();
475475
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
477477
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
479479

480480
// absolute time locked
481481
tx.vin[0].prevout.hash = txFirst[3]->GetHash();
482-
tx.nLockTime = ::ChainActive().Tip()->GetMedianTimePast();
482+
tx.nLockTime = m_node.chainman->ActiveChain().Tip()->GetMedianTimePast();
483483
prevheights.resize(1);
484484
prevheights[0] = baseheight + 4;
485485
hash = tx.GetHash();
486486
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
488488
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
490490

491491
// mempool-dependent transactions (not added)
492492
tx.vin[0].prevout.hash = hash;
493-
prevheights[0] = ::ChainActive().Tip()->nHeight + 1;
493+
prevheights[0] = m_node.chainman->ActiveChain().Tip()->nHeight + 1;
494494
tx.nLockTime = 0;
495495
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
497497
BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
498498
tx.vin[0].nSequence = 1;
499499
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
@@ -511,14 +511,14 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
511511
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 3U);
512512
// However if we advance height by 1 and time by 512, all of them should be mined
513513
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);
517517

518518
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
519519
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 5U);
520520

521-
::ChainActive().Tip()->nHeight--;
521+
m_node.chainman->ActiveChain().Tip()->nHeight--;
522522
SetMockTime(0);
523523
m_node.mempool->clear();
524524

src/test/txindex_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
2828
// BlockUntilSyncedToCurrentChain should return false before txindex is started.
2929
BOOST_CHECK(!txindex.BlockUntilSyncedToCurrentChain());
3030

31-
BOOST_REQUIRE(txindex.Start(::ChainstateActive()));
31+
BOOST_REQUIRE(txindex.Start(m_node.chainman->ActiveChainstate()));
3232

3333
// Allow tx index to catch up with the block index.
3434
constexpr int64_t timeout_ms = 10 * 1000;

src/test/txvalidation_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_reject_coinbase, TestChain100Setup)
3737
LOCK(cs_main);
3838

3939
unsigned int initialPoolSize = m_node.mempool->size();
40-
const MempoolAcceptResult result = AcceptToMemoryPool(::ChainstateActive(), *m_node.mempool, MakeTransactionRef(coinbaseTx),
40+
const MempoolAcceptResult result = AcceptToMemoryPool(m_node.chainman->ActiveChainstate(), *m_node.mempool, MakeTransactionRef(coinbaseTx),
4141
true /* bypass_limits */);
4242

4343
BOOST_CHECK(result.m_result_type == MempoolAcceptResult::ResultType::INVALID);

0 commit comments

Comments
 (0)