1919#include < boost/test/unit_test.hpp>
2020#include < univalue.h>
2121
22+ extern CWallet* pwalletMain;
23+
2224extern UniValue importmulti (const JSONRPCRequest& request);
2325extern UniValue dumpwallet (const JSONRPCRequest& request);
2426extern UniValue importwallet (const JSONRPCRequest& request);
@@ -402,8 +404,7 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup)
402404 // after.
403405 {
404406 CWallet wallet;
405- CWallet *backup = ::pwalletMain;
406- ::pwalletMain = &wallet;
407+ vpwallets.insert (vpwallets.begin (), &wallet);
407408 UniValue keys;
408409 keys.setArray ();
409410 UniValue key;
@@ -434,7 +435,7 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup)
434435 " downloading and rescanning the relevant blocks (see -reindex and -rescan "
435436 " options).\" }},{\" success\" :true}]" ,
436437 0 , oldTip->GetBlockTimeMax (), TIMESTAMP_WINDOW));
437- ::pwalletMain = backup ;
438+ vpwallets. erase (vpwallets. begin ()) ;
438439 }
439440}
440441
@@ -444,7 +445,6 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup)
444445// than or equal to key birthday.
445446BOOST_FIXTURE_TEST_CASE (importwallet_rescan, TestChain100Setup)
446447{
447- CWallet *pwalletMainBackup = ::pwalletMain;
448448 LOCK (cs_main);
449449
450450 // Create two blocks with same timestamp to verify that importwallet rescan
@@ -470,7 +470,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
470470 JSONRPCRequest request;
471471 request.params .setArray ();
472472 request.params .push_back (" wallet.backup" );
473- ::pwalletMain = &wallet;
473+ vpwallets. insert (vpwallets. begin (), &wallet) ;
474474 ::dumpwallet (request);
475475 }
476476
@@ -482,7 +482,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
482482 JSONRPCRequest request;
483483 request.params .setArray ();
484484 request.params .push_back (" wallet.backup" );
485- ::pwalletMain = &wallet;
485+ vpwallets[ 0 ] = &wallet;
486486 ::importwallet (request);
487487
488488 BOOST_CHECK_EQUAL (wallet.mapWallet .size (), 3 );
@@ -495,7 +495,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
495495 }
496496
497497 SetMockTime (0 );
498- ::pwalletMain = pwalletMainBackup ;
498+ vpwallets. erase (vpwallets. begin ()) ;
499499}
500500
501501// Check that GetImmatureCredit() returns a newly calculated value instead of
0 commit comments