@@ -83,12 +83,9 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
8383 CreateAndProcessBlock ({}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ()));
8484 CBlockIndex* newTip = ::ChainActive ().Tip ();
8585
86- NodeContext node;
87- auto chain = interfaces::MakeChain (node);
88-
8986 // Verify ScanForWalletTransactions fails to read an unknown start block.
9087 {
91- CWallet wallet (chain.get (), " " , CreateDummyWalletDatabase ());
88+ CWallet wallet (m_node. chain .get (), " " , CreateDummyWalletDatabase ());
9289 {
9390 LOCK (wallet.cs_wallet );
9491 wallet.SetLastBlockProcessed (::ChainActive ().Height (), ::ChainActive ().Tip ()->GetBlockHash ());
@@ -107,7 +104,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
107104 // Verify ScanForWalletTransactions picks up transactions in both the old
108105 // and new block files.
109106 {
110- CWallet wallet (chain.get (), " " , CreateDummyWalletDatabase ());
107+ CWallet wallet (m_node. chain .get (), " " , CreateDummyWalletDatabase ());
111108 {
112109 LOCK (wallet.cs_wallet );
113110 wallet.SetLastBlockProcessed (::ChainActive ().Height (), ::ChainActive ().Tip ()->GetBlockHash ());
@@ -133,7 +130,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
133130 // Verify ScanForWalletTransactions only picks transactions in the new block
134131 // file.
135132 {
136- CWallet wallet (chain.get (), " " , CreateDummyWalletDatabase ());
133+ CWallet wallet (m_node. chain .get (), " " , CreateDummyWalletDatabase ());
137134 {
138135 LOCK (wallet.cs_wallet );
139136 wallet.SetLastBlockProcessed (::ChainActive ().Height (), ::ChainActive ().Tip ()->GetBlockHash ());
@@ -158,7 +155,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
158155
159156 // Verify ScanForWalletTransactions scans no blocks.
160157 {
161- CWallet wallet (chain.get (), " " , CreateDummyWalletDatabase ());
158+ CWallet wallet (m_node. chain .get (), " " , CreateDummyWalletDatabase ());
162159 {
163160 LOCK (wallet.cs_wallet );
164161 wallet.SetLastBlockProcessed (::ChainActive ().Height (), ::ChainActive ().Tip ()->GetBlockHash ());
@@ -183,9 +180,6 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
183180 CreateAndProcessBlock ({}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ()));
184181 CBlockIndex* newTip = ::ChainActive ().Tip ();
185182
186- NodeContext node;
187- auto chain = interfaces::MakeChain (node);
188-
189183 // Prune the older block file.
190184 {
191185 LOCK (cs_main);
@@ -197,7 +191,7 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
197191 // before the missing block, and success for a key whose creation time is
198192 // after.
199193 {
200- std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(chain.get (), " " , CreateDummyWalletDatabase ());
194+ std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node. chain .get (), " " , CreateDummyWalletDatabase ());
201195 wallet->SetupLegacyScriptPubKeyMan ();
202196 WITH_LOCK (wallet->cs_wallet , wallet->SetLastBlockProcessed (newTip->nHeight , newTip->GetBlockHash ()));
203197 AddWallet (wallet);
@@ -255,14 +249,11 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
255249 SetMockTime (KEY_TIME);
256250 m_coinbase_txns.emplace_back (CreateAndProcessBlock ({}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ())).vtx [0 ]);
257251
258- NodeContext node;
259- auto chain = interfaces::MakeChain (node);
260-
261252 std::string backup_file = (GetDataDir () / " wallet.backup" ).string ();
262253
263254 // Import key into wallet and call dumpwallet to create backup file.
264255 {
265- std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(chain.get (), " " , CreateDummyWalletDatabase ());
256+ std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node. chain .get (), " " , CreateDummyWalletDatabase ());
266257 {
267258 auto spk_man = wallet->GetOrCreateLegacyScriptPubKeyMan ();
268259 LOCK2 (wallet->cs_wallet , spk_man->cs_KeyStore );
@@ -284,7 +275,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
284275 // Call importwallet RPC and verify all blocks with timestamps >= BLOCK_TIME
285276 // were scanned, and no prior blocks were scanned.
286277 {
287- std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(chain.get (), " " , CreateDummyWalletDatabase ());
278+ std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node. chain .get (), " " , CreateDummyWalletDatabase ());
288279 LOCK (wallet->cs_wallet );
289280 wallet->SetupLegacyScriptPubKeyMan ();
290281
@@ -317,10 +308,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
317308// debit functions.
318309BOOST_FIXTURE_TEST_CASE (coin_mark_dirty_immature_credit, TestChain100Setup)
319310{
320- NodeContext node;
321- auto chain = interfaces::MakeChain (node);
322-
323- CWallet wallet (chain.get (), " " , CreateDummyWalletDatabase ());
311+ CWallet wallet (m_node.chain .get (), " " , CreateDummyWalletDatabase ());
324312 auto spk_man = wallet.GetOrCreateLegacyScriptPubKeyMan ();
325313 CWalletTx wtx (&wallet, m_coinbase_txns.back ());
326314
@@ -495,7 +483,7 @@ class ListCoinsTestingSetup : public TestChain100Setup
495483 ListCoinsTestingSetup ()
496484 {
497485 CreateAndProcessBlock ({}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ()));
498- wallet = MakeUnique<CWallet>(m_chain .get (), " " , CreateMockWalletDatabase ());
486+ wallet = MakeUnique<CWallet>(m_node. chain .get (), " " , CreateMockWalletDatabase ());
499487 {
500488 LOCK2 (wallet->cs_wallet , ::cs_main);
501489 wallet->SetLastBlockProcessed (::ChainActive ().Height (), ::ChainActive ().Tip ()->GetBlockHash ());
@@ -545,7 +533,6 @@ class ListCoinsTestingSetup : public TestChain100Setup
545533 return it->second ;
546534 }
547535
548- std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain(m_node);
549536 std::unique_ptr<CWallet> wallet;
550537};
551538
@@ -612,9 +599,7 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
612599
613600BOOST_FIXTURE_TEST_CASE (wallet_disableprivkeys, TestChain100Setup)
614601{
615- NodeContext node;
616- auto chain = interfaces::MakeChain (node);
617- std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(chain.get (), " " , CreateDummyWalletDatabase ());
602+ std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain .get (), " " , CreateDummyWalletDatabase ());
618603 wallet->SetupLegacyScriptPubKeyMan ();
619604 wallet->SetMinVersion (FEATURE_LATEST);
620605 wallet->SetWalletFlag (WALLET_FLAG_DISABLE_PRIVATE_KEYS);
@@ -709,8 +694,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_descriptor_test, BasicTestingSetup)
709694BOOST_FIXTURE_TEST_CASE (CreateWallet, TestChain100Setup)
710695{
711696 // Create new wallet with known key and unload it.
712- auto chain = interfaces::MakeChain (m_node);
713- auto wallet = TestLoadWallet (*chain);
697+ auto wallet = TestLoadWallet (*m_node.chain );
714698 CKey key;
715699 key.MakeNewKey (true );
716700 AddKey (*wallet, key);
@@ -745,12 +729,12 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
745729 auto block_tx = TestSimpleSpend (*m_coinbase_txns[0 ], 0 , coinbaseKey, GetScriptForRawPubKey (key.GetPubKey ()));
746730 m_coinbase_txns.push_back (CreateAndProcessBlock ({block_tx}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ())).vtx [0 ]);
747731 auto mempool_tx = TestSimpleSpend (*m_coinbase_txns[1 ], 0 , coinbaseKey, GetScriptForRawPubKey (key.GetPubKey ()));
748- BOOST_CHECK (chain->broadcastTransaction (MakeTransactionRef (mempool_tx), DEFAULT_TRANSACTION_MAXFEE, false , error));
732+ BOOST_CHECK (m_node. chain ->broadcastTransaction (MakeTransactionRef (mempool_tx), DEFAULT_TRANSACTION_MAXFEE, false , error));
749733
750734
751735 // Reload wallet and make sure new transactions are detected despite events
752736 // being blocked
753- wallet = TestLoadWallet (*chain);
737+ wallet = TestLoadWallet (*m_node. chain );
754738 BOOST_CHECK (rescan_completed);
755739 BOOST_CHECK_EQUAL (addtx_count, 2 );
756740 {
@@ -783,12 +767,12 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
783767 block_tx = TestSimpleSpend (*m_coinbase_txns[2 ], 0 , coinbaseKey, GetScriptForRawPubKey (key.GetPubKey ()));
784768 m_coinbase_txns.push_back (CreateAndProcessBlock ({block_tx}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ())).vtx [0 ]);
785769 mempool_tx = TestSimpleSpend (*m_coinbase_txns[3 ], 0 , coinbaseKey, GetScriptForRawPubKey (key.GetPubKey ()));
786- BOOST_CHECK (chain->broadcastTransaction (MakeTransactionRef (mempool_tx), DEFAULT_TRANSACTION_MAXFEE, false , error));
770+ BOOST_CHECK (m_node. chain ->broadcastTransaction (MakeTransactionRef (mempool_tx), DEFAULT_TRANSACTION_MAXFEE, false , error));
787771 LEAVE_CRITICAL_SECTION (wallet->wallet ()->cs_wallet );
788772 SyncWithValidationInterfaceQueue ();
789773 ENTER_CRITICAL_SECTION (wallet->wallet ()->cs_wallet );
790774 });
791- wallet = TestLoadWallet (*chain);
775+ wallet = TestLoadWallet (*m_node. chain );
792776 BOOST_CHECK_EQUAL (addtx_count, 4 );
793777 {
794778 LOCK (wallet->cs_wallet );
0 commit comments