Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/test/wallet_tests.cpp
Show First 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | // Import key into wallet and call dumpwallet to create backup file. | ||||
spk_man->mapKeyMetadata[coinbaseKey.GetPubKey().GetID()].nCreateTime = | spk_man->mapKeyMetadata[coinbaseKey.GetPubKey().GetID()].nCreateTime = | ||||
KEY_TIME; | KEY_TIME; | ||||
spk_man->AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey()); | spk_man->AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey()); | ||||
JSONRPCRequest request; | JSONRPCRequest request; | ||||
request.params.setArray(); | request.params.setArray(); | ||||
request.params.push_back(backup_file); | request.params.push_back(backup_file); | ||||
AddWallet(wallet); | 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 = | ||||
std::make_shared<CWallet>(Params(), chain.get(), WalletLocation(), | std::make_shared<CWallet>(Params(), chain.get(), WalletLocation(), | ||||
WalletDatabase::CreateDummy()); | WalletDatabase::CreateDummy()); | ||||
LOCK(wallet->cs_wallet); | |||||
wallet->SetupLegacyScriptPubKeyMan(); | wallet->SetupLegacyScriptPubKeyMan(); | ||||
JSONRPCRequest request; | JSONRPCRequest request; | ||||
request.params.setArray(); | request.params.setArray(); | ||||
request.params.push_back(backup_file); | request.params.push_back(backup_file); | ||||
AddWallet(wallet); | AddWallet(wallet); | ||||
wallet->SetLastBlockProcessed(::ChainActive().Height(), | |||||
::ChainActive().Tip()->GetBlockHash()); | |||||
::importwallet(GetConfig(), request); | ::importwallet(GetConfig(), request); | ||||
RemoveWallet(wallet); | RemoveWallet(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) { | ||||
bool found = wallet->GetWalletTx(m_coinbase_txns[i]->GetId()); | bool found = wallet->GetWalletTx(m_coinbase_txns[i]->GetId()); | ||||
bool expected = i >= 100; | bool expected = i >= 100; | ||||
BOOST_CHECK_EQUAL(found, expected); | BOOST_CHECK_EQUAL(found, expected); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 356 Lines • Show Last 20 Lines |