@@ -83,12 +83,9 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
83
83
CreateAndProcessBlock ({}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ()));
84
84
CBlockIndex* newTip = ::ChainActive ().Tip ();
85
85
86
- NodeContext node;
87
- auto chain = interfaces::MakeChain (node);
88
-
89
86
// Verify ScanForWalletTransactions fails to read an unknown start block.
90
87
{
91
- CWallet wallet (chain.get (), " " , CreateDummyWalletDatabase ());
88
+ CWallet wallet (m_node. chain .get (), " " , CreateDummyWalletDatabase ());
92
89
{
93
90
LOCK (wallet.cs_wallet );
94
91
wallet.SetLastBlockProcessed (::ChainActive ().Height (), ::ChainActive ().Tip ()->GetBlockHash ());
@@ -107,7 +104,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
107
104
// Verify ScanForWalletTransactions picks up transactions in both the old
108
105
// and new block files.
109
106
{
110
- CWallet wallet (chain.get (), " " , CreateDummyWalletDatabase ());
107
+ CWallet wallet (m_node. chain .get (), " " , CreateDummyWalletDatabase ());
111
108
{
112
109
LOCK (wallet.cs_wallet );
113
110
wallet.SetLastBlockProcessed (::ChainActive ().Height (), ::ChainActive ().Tip ()->GetBlockHash ());
@@ -133,7 +130,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
133
130
// Verify ScanForWalletTransactions only picks transactions in the new block
134
131
// file.
135
132
{
136
- CWallet wallet (chain.get (), " " , CreateDummyWalletDatabase ());
133
+ CWallet wallet (m_node. chain .get (), " " , CreateDummyWalletDatabase ());
137
134
{
138
135
LOCK (wallet.cs_wallet );
139
136
wallet.SetLastBlockProcessed (::ChainActive ().Height (), ::ChainActive ().Tip ()->GetBlockHash ());
@@ -158,7 +155,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
158
155
159
156
// Verify ScanForWalletTransactions scans no blocks.
160
157
{
161
- CWallet wallet (chain.get (), " " , CreateDummyWalletDatabase ());
158
+ CWallet wallet (m_node. chain .get (), " " , CreateDummyWalletDatabase ());
162
159
{
163
160
LOCK (wallet.cs_wallet );
164
161
wallet.SetLastBlockProcessed (::ChainActive ().Height (), ::ChainActive ().Tip ()->GetBlockHash ());
@@ -183,9 +180,6 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
183
180
CreateAndProcessBlock ({}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ()));
184
181
CBlockIndex* newTip = ::ChainActive ().Tip ();
185
182
186
- NodeContext node;
187
- auto chain = interfaces::MakeChain (node);
188
-
189
183
// Prune the older block file.
190
184
{
191
185
LOCK (cs_main);
@@ -197,7 +191,7 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
197
191
// before the missing block, and success for a key whose creation time is
198
192
// after.
199
193
{
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 ());
201
195
wallet->SetupLegacyScriptPubKeyMan ();
202
196
WITH_LOCK (wallet->cs_wallet , wallet->SetLastBlockProcessed (newTip->nHeight , newTip->GetBlockHash ()));
203
197
AddWallet (wallet);
@@ -255,14 +249,11 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
255
249
SetMockTime (KEY_TIME);
256
250
m_coinbase_txns.emplace_back (CreateAndProcessBlock ({}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ())).vtx [0 ]);
257
251
258
- NodeContext node;
259
- auto chain = interfaces::MakeChain (node);
260
-
261
252
std::string backup_file = (GetDataDir () / " wallet.backup" ).string ();
262
253
263
254
// Import key into wallet and call dumpwallet to create backup file.
264
255
{
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 ());
266
257
{
267
258
auto spk_man = wallet->GetOrCreateLegacyScriptPubKeyMan ();
268
259
LOCK2 (wallet->cs_wallet , spk_man->cs_KeyStore );
@@ -284,7 +275,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
284
275
// Call importwallet RPC and verify all blocks with timestamps >= BLOCK_TIME
285
276
// were scanned, and no prior blocks were scanned.
286
277
{
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 ());
288
279
LOCK (wallet->cs_wallet );
289
280
wallet->SetupLegacyScriptPubKeyMan ();
290
281
@@ -317,10 +308,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
317
308
// debit functions.
318
309
BOOST_FIXTURE_TEST_CASE (coin_mark_dirty_immature_credit, TestChain100Setup)
319
310
{
320
- NodeContext node;
321
- auto chain = interfaces::MakeChain (node);
322
-
323
- CWallet wallet (chain.get (), " " , CreateDummyWalletDatabase ());
311
+ CWallet wallet (m_node.chain .get (), " " , CreateDummyWalletDatabase ());
324
312
auto spk_man = wallet.GetOrCreateLegacyScriptPubKeyMan ();
325
313
CWalletTx wtx (&wallet, m_coinbase_txns.back ());
326
314
@@ -495,7 +483,7 @@ class ListCoinsTestingSetup : public TestChain100Setup
495
483
ListCoinsTestingSetup ()
496
484
{
497
485
CreateAndProcessBlock ({}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ()));
498
- wallet = MakeUnique<CWallet>(m_chain .get (), " " , CreateMockWalletDatabase ());
486
+ wallet = MakeUnique<CWallet>(m_node. chain .get (), " " , CreateMockWalletDatabase ());
499
487
{
500
488
LOCK2 (wallet->cs_wallet , ::cs_main);
501
489
wallet->SetLastBlockProcessed (::ChainActive ().Height (), ::ChainActive ().Tip ()->GetBlockHash ());
@@ -545,7 +533,6 @@ class ListCoinsTestingSetup : public TestChain100Setup
545
533
return it->second ;
546
534
}
547
535
548
- std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain(m_node);
549
536
std::unique_ptr<CWallet> wallet;
550
537
};
551
538
@@ -612,9 +599,7 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
612
599
613
600
BOOST_FIXTURE_TEST_CASE (wallet_disableprivkeys, TestChain100Setup)
614
601
{
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 ());
618
603
wallet->SetupLegacyScriptPubKeyMan ();
619
604
wallet->SetMinVersion (FEATURE_LATEST);
620
605
wallet->SetWalletFlag (WALLET_FLAG_DISABLE_PRIVATE_KEYS);
@@ -709,8 +694,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_descriptor_test, BasicTestingSetup)
709
694
BOOST_FIXTURE_TEST_CASE (CreateWallet, TestChain100Setup)
710
695
{
711
696
// 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 );
714
698
CKey key;
715
699
key.MakeNewKey (true );
716
700
AddKey (*wallet, key);
@@ -745,12 +729,12 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
745
729
auto block_tx = TestSimpleSpend (*m_coinbase_txns[0 ], 0 , coinbaseKey, GetScriptForRawPubKey (key.GetPubKey ()));
746
730
m_coinbase_txns.push_back (CreateAndProcessBlock ({block_tx}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ())).vtx [0 ]);
747
731
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));
749
733
750
734
751
735
// Reload wallet and make sure new transactions are detected despite events
752
736
// being blocked
753
- wallet = TestLoadWallet (*chain);
737
+ wallet = TestLoadWallet (*m_node. chain );
754
738
BOOST_CHECK (rescan_completed);
755
739
BOOST_CHECK_EQUAL (addtx_count, 2 );
756
740
{
@@ -783,12 +767,12 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
783
767
block_tx = TestSimpleSpend (*m_coinbase_txns[2 ], 0 , coinbaseKey, GetScriptForRawPubKey (key.GetPubKey ()));
784
768
m_coinbase_txns.push_back (CreateAndProcessBlock ({block_tx}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ())).vtx [0 ]);
785
769
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));
787
771
LEAVE_CRITICAL_SECTION (wallet->wallet ()->cs_wallet );
788
772
SyncWithValidationInterfaceQueue ();
789
773
ENTER_CRITICAL_SECTION (wallet->wallet ()->cs_wallet );
790
774
});
791
- wallet = TestLoadWallet (*chain);
775
+ wallet = TestLoadWallet (*m_node. chain );
792
776
BOOST_CHECK_EQUAL (addtx_count, 4 );
793
777
{
794
778
LOCK (wallet->cs_wallet );
0 commit comments