test: Fix dangling wallet pointer in vpwallets

This commit is contained in:
João Barbosa 2018-04-17 18:28:54 +01:00
parent 58bbc55212
commit d41a420562

View File

@ -142,6 +142,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
request.params.push_back((pathTemp / "wallet.backup").string()); request.params.push_back((pathTemp / "wallet.backup").string());
vpwallets.insert(vpwallets.begin(), &wallet); vpwallets.insert(vpwallets.begin(), &wallet);
::dumpwallet(request); ::dumpwallet(request);
vpwallets.erase(vpwallets.begin());
} }
// Call importwallet RPC and verify all blocks with timestamps >= BLOCK_TIME // Call importwallet RPC and verify all blocks with timestamps >= BLOCK_TIME
@ -152,8 +153,9 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
JSONRPCRequest request; JSONRPCRequest request;
request.params.setArray(); request.params.setArray();
request.params.push_back((pathTemp / "wallet.backup").string()); request.params.push_back((pathTemp / "wallet.backup").string());
vpwallets[0] = &wallet; vpwallets.insert(vpwallets.begin(), &wallet);
::importwallet(request); ::importwallet(request);
vpwallets.erase(vpwallets.begin());
LOCK(wallet.cs_wallet); LOCK(wallet.cs_wallet);
BOOST_CHECK_EQUAL(wallet.mapWallet.size(), 3U); BOOST_CHECK_EQUAL(wallet.mapWallet.size(), 3U);
@ -166,7 +168,6 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
} }
SetMockTime(0); SetMockTime(0);
vpwallets.erase(vpwallets.begin());
} }
// Check that GetImmatureCredit() returns a newly calculated value instead of // Check that GetImmatureCredit() returns a newly calculated value instead of