Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/test/wallet_tests.cpp
Show First 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup) { | ||||
std::string backup_file = (GetDataDir() / "wallet.backup").string(); | std::string backup_file = (GetDataDir() / "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. | ||||
{ | { | ||||
std::shared_ptr<CWallet> wallet = | std::shared_ptr<CWallet> wallet = | ||||
std::make_shared<CWallet>(Params(), chain.get(), WalletLocation(), | std::make_shared<CWallet>(Params(), chain.get(), WalletLocation(), | ||||
WalletDatabase::CreateDummy()); | WalletDatabase::CreateDummy()); | ||||
{ | |||||
auto spk_man = wallet->GetOrCreateLegacyScriptPubKeyMan(); | auto spk_man = wallet->GetOrCreateLegacyScriptPubKeyMan(); | ||||
LOCK2(wallet->cs_wallet, spk_man->cs_KeyStore); | LOCK2(wallet->cs_wallet, spk_man->cs_KeyStore); | ||||
spk_man->mapKeyMetadata[coinbaseKey.GetPubKey().GetID()].nCreateTime = | spk_man->mapKeyMetadata[coinbaseKey.GetPubKey().GetID()] | ||||
KEY_TIME; | .nCreateTime = KEY_TIME; | ||||
spk_man->AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey()); | spk_man->AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey()); | ||||
AddWallet(wallet); | |||||
wallet->SetLastBlockProcessed( | |||||
::ChainActive().Height(), | |||||
::ChainActive().Tip()->GetBlockHash()); | |||||
} | |||||
JSONRPCRequest request; | JSONRPCRequest request; | ||||
request.params.setArray(); | request.params.setArray(); | ||||
request.params.push_back(backup_file); | request.params.push_back(backup_file); | ||||
AddWallet(wallet); | |||||
wallet->SetLastBlockProcessed(::ChainActive().Height(), | |||||
::ChainActive().Tip()->GetBlockHash()); | |||||
::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. | ||||
{ | { | ||||
std::shared_ptr<CWallet> wallet = | std::shared_ptr<CWallet> wallet = | ||||
▲ Show 20 Lines • Show All 378 Lines • Show Last 20 Lines |