Skip to content

Commit 6c15de1

Browse files
committed
scripted-diff: wallet/test: Use existing chainman
-BEGIN VERIFY SCRIPT- git ls-files -- src/wallet/test \ | 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 ee0ab1e commit 6c15de1

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/wallet/test/wallet_tests.cpp

+19-19
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,17 @@ static void AddKey(CWallet& wallet, const CKey& key)
8383
BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
8484
{
8585
// Cap last block file size, and mine new block in a new block file.
86-
CBlockIndex* oldTip = ::ChainActive().Tip();
86+
CBlockIndex* oldTip = m_node.chainman->ActiveChain().Tip();
8787
GetBlockFileInfo(oldTip->GetBlockPos().nFile)->nSize = MAX_BLOCKFILE_SIZE;
8888
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
89-
CBlockIndex* newTip = ::ChainActive().Tip();
89+
CBlockIndex* newTip = m_node.chainman->ActiveChain().Tip();
9090

9191
// Verify ScanForWalletTransactions fails to read an unknown start block.
9292
{
9393
CWallet wallet(m_node.chain.get(), "", CreateDummyWalletDatabase());
9494
{
9595
LOCK(wallet.cs_wallet);
96-
wallet.SetLastBlockProcessed(::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash());
96+
wallet.SetLastBlockProcessed(m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash());
9797
}
9898
AddKey(wallet, coinbaseKey);
9999
WalletRescanReserver reserver(wallet);
@@ -112,7 +112,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
112112
CWallet wallet(m_node.chain.get(), "", CreateDummyWalletDatabase());
113113
{
114114
LOCK(wallet.cs_wallet);
115-
wallet.SetLastBlockProcessed(::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash());
115+
wallet.SetLastBlockProcessed(m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash());
116116
}
117117
AddKey(wallet, coinbaseKey);
118118
WalletRescanReserver reserver(wallet);
@@ -138,7 +138,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
138138
CWallet wallet(m_node.chain.get(), "", CreateDummyWalletDatabase());
139139
{
140140
LOCK(wallet.cs_wallet);
141-
wallet.SetLastBlockProcessed(::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash());
141+
wallet.SetLastBlockProcessed(m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash());
142142
}
143143
AddKey(wallet, coinbaseKey);
144144
WalletRescanReserver reserver(wallet);
@@ -163,7 +163,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
163163
CWallet wallet(m_node.chain.get(), "", CreateDummyWalletDatabase());
164164
{
165165
LOCK(wallet.cs_wallet);
166-
wallet.SetLastBlockProcessed(::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash());
166+
wallet.SetLastBlockProcessed(m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash());
167167
}
168168
AddKey(wallet, coinbaseKey);
169169
WalletRescanReserver reserver(wallet);
@@ -180,10 +180,10 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
180180
BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
181181
{
182182
// Cap last block file size, and mine new block in a new block file.
183-
CBlockIndex* oldTip = ::ChainActive().Tip();
183+
CBlockIndex* oldTip = m_node.chainman->ActiveChain().Tip();
184184
GetBlockFileInfo(oldTip->GetBlockPos().nFile)->nSize = MAX_BLOCKFILE_SIZE;
185185
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
186-
CBlockIndex* newTip = ::ChainActive().Tip();
186+
CBlockIndex* newTip = m_node.chainman->ActiveChain().Tip();
187187

188188
// Prune the older block file.
189189
{
@@ -242,7 +242,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
242242
{
243243
// Create two blocks with same timestamp to verify that importwallet rescan
244244
// will pick up both blocks, not just the first.
245-
const int64_t BLOCK_TIME = ::ChainActive().Tip()->GetBlockTimeMax() + 5;
245+
const int64_t BLOCK_TIME = m_node.chainman->ActiveChain().Tip()->GetBlockTimeMax() + 5;
246246
SetMockTime(BLOCK_TIME);
247247
m_coinbase_txns.emplace_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
248248
m_coinbase_txns.emplace_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
@@ -265,7 +265,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
265265
spk_man->AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey());
266266

267267
AddWallet(wallet);
268-
wallet->SetLastBlockProcessed(::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash());
268+
wallet->SetLastBlockProcessed(m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash());
269269
}
270270
JSONRPCRequest request;
271271
request.params.setArray();
@@ -286,7 +286,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
286286
request.params.setArray();
287287
request.params.push_back(backup_file);
288288
AddWallet(wallet);
289-
wallet->SetLastBlockProcessed(::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash());
289+
wallet->SetLastBlockProcessed(m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash());
290290
::importwallet().HandleRequest(request);
291291
RemoveWallet(wallet, std::nullopt);
292292

@@ -313,9 +313,9 @@ BOOST_FIXTURE_TEST_CASE(coin_mark_dirty_immature_credit, TestChain100Setup)
313313
CWalletTx wtx(&wallet, m_coinbase_txns.back());
314314

315315
LOCK2(wallet.cs_wallet, spk_man->cs_KeyStore);
316-
wallet.SetLastBlockProcessed(::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash());
316+
wallet.SetLastBlockProcessed(m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash());
317317

318-
CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, ::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash(), 0);
318+
CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash(), 0);
319319
wtx.m_confirm = confirm;
320320

321321
// Call GetImmatureCredit() once before adding the key to the wallet to
@@ -483,16 +483,16 @@ class ListCoinsTestingSetup : public TestChain100Setup
483483
wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
484484
{
485485
LOCK2(wallet->cs_wallet, ::cs_main);
486-
wallet->SetLastBlockProcessed(::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash());
486+
wallet->SetLastBlockProcessed(m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash());
487487
}
488488
wallet->LoadWallet();
489489
AddKey(*wallet, coinbaseKey);
490490
WalletRescanReserver reserver(*wallet);
491491
reserver.reserve();
492-
CWallet::ScanResult result = wallet->ScanForWalletTransactions(::ChainActive().Genesis()->GetBlockHash(), 0 /* start_height */, {} /* max_height */, reserver, false /* update */);
492+
CWallet::ScanResult result = wallet->ScanForWalletTransactions(m_node.chainman->ActiveChain().Genesis()->GetBlockHash(), 0 /* start_height */, {} /* max_height */, reserver, false /* update */);
493493
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::SUCCESS);
494-
BOOST_CHECK_EQUAL(result.last_scanned_block, ::ChainActive().Tip()->GetBlockHash());
495-
BOOST_CHECK_EQUAL(*result.last_scanned_height, ::ChainActive().Height());
494+
BOOST_CHECK_EQUAL(result.last_scanned_block, m_node.chainman->ActiveChain().Tip()->GetBlockHash());
495+
BOOST_CHECK_EQUAL(*result.last_scanned_height, m_node.chainman->ActiveChain().Height());
496496
BOOST_CHECK(result.last_failed_block.IsNull());
497497
}
498498

@@ -521,10 +521,10 @@ class ListCoinsTestingSetup : public TestChain100Setup
521521
CreateAndProcessBlock({CMutableTransaction(blocktx)}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
522522

523523
LOCK(wallet->cs_wallet);
524-
wallet->SetLastBlockProcessed(wallet->GetLastBlockHeight() + 1, ::ChainActive().Tip()->GetBlockHash());
524+
wallet->SetLastBlockProcessed(wallet->GetLastBlockHeight() + 1, m_node.chainman->ActiveChain().Tip()->GetBlockHash());
525525
auto it = wallet->mapWallet.find(tx->GetHash());
526526
BOOST_CHECK(it != wallet->mapWallet.end());
527-
CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, ::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash(), 1);
527+
CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash(), 1);
528528
it->second.m_confirm = confirm;
529529
return it->second;
530530
}

0 commit comments

Comments
 (0)