Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/test/wallet_tests.cpp
Show First 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup) { | ||||
SetMockTime(KEY_TIME); | SetMockTime(KEY_TIME); | ||||
m_coinbase_txns.emplace_back( | m_coinbase_txns.emplace_back( | ||||
CreateAndProcessBlock({}, | CreateAndProcessBlock({}, | ||||
GetScriptForRawPubKey(coinbaseKey.GetPubKey())) | GetScriptForRawPubKey(coinbaseKey.GetPubKey())) | ||||
.vtx[0]); | .vtx[0]); | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
std::string backup_file = | |||||
(SetDataDir("importwallet_rescan") / "wallet.backup").string(); | |||||
// Import key into wallet and call dumpwallet to create backup file. | // Import key into wallet and call dumpwallet to create backup file. | ||||
{ | { | ||||
CWallet wallet(Params(), "dummy", CWalletDBWrapper::CreateDummy()); | CWallet wallet(Params(), "dummy", CWalletDBWrapper::CreateDummy()); | ||||
LOCK(wallet.cs_wallet); | LOCK(wallet.cs_wallet); | ||||
wallet.mapKeyMetadata[coinbaseKey.GetPubKey().GetID()].nCreateTime = | wallet.mapKeyMetadata[coinbaseKey.GetPubKey().GetID()].nCreateTime = | ||||
KEY_TIME; | KEY_TIME; | ||||
wallet.AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey()); | wallet.AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey()); | ||||
JSONRPCRequest request; | JSONRPCRequest request; | ||||
request.params.setArray(); | request.params.setArray(); | ||||
request.params.push_back((pathTemp / "wallet.backup").string()); | request.params.push_back(backup_file); | ||||
AddWallet(&wallet); | AddWallet(&wallet); | ||||
::dumpwallet(GetConfig(), request); | ::dumpwallet(GetConfig(), request); | ||||
RemoveWallet(&wallet); | RemoveWallet(&wallet); | ||||
} | } | ||||
// Call importwallet RPC and verify all blocks with timestamps >= BLOCK_TIME | // Call importwallet RPC and verify all blocks with timestamps >= BLOCK_TIME | ||||
// were scanned, and no prior blocks were scanned. | // were scanned, and no prior blocks were scanned. | ||||
{ | { | ||||
CWallet wallet(Params(), "dummy", CWalletDBWrapper::CreateDummy()); | CWallet wallet(Params(), "dummy", CWalletDBWrapper::CreateDummy()); | ||||
JSONRPCRequest request; | JSONRPCRequest request; | ||||
request.params.setArray(); | request.params.setArray(); | ||||
request.params.push_back((pathTemp / "wallet.backup").string()); | request.params.push_back(backup_file); | ||||
AddWallet(&wallet); | AddWallet(&wallet); | ||||
::importwallet(GetConfig(), request); | ::importwallet(GetConfig(), request); | ||||
RemoveWallet(&wallet); | RemoveWallet(&wallet); | ||||
LOCK(wallet.cs_wallet); | LOCK(wallet.cs_wallet); | ||||
BOOST_CHECK_EQUAL(wallet.mapWallet.size(), 3U); | BOOST_CHECK_EQUAL(wallet.mapWallet.size(), 3U); | ||||
BOOST_CHECK_EQUAL(m_coinbase_txns.size(), 103U); | BOOST_CHECK_EQUAL(m_coinbase_txns.size(), 103U); | ||||
for (size_t i = 0; i < m_coinbase_txns.size(); ++i) { | for (size_t i = 0; i < m_coinbase_txns.size(); ++i) { | ||||
▲ Show 20 Lines • Show All 206 Lines • Show Last 20 Lines |