Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/test/wallet_tests.cpp
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | // and new block files. | ||||
BOOST_CHECK_EQUAL(result.last_scanned_block, newTip->GetBlockHash()); | BOOST_CHECK_EQUAL(result.last_scanned_block, newTip->GetBlockHash()); | ||||
BOOST_CHECK_EQUAL(*result.last_scanned_height, newTip->nHeight); | BOOST_CHECK_EQUAL(*result.last_scanned_height, newTip->nHeight); | ||||
BOOST_CHECK_EQUAL(wallet.GetBalance().m_mine_immature, 100 * COIN); | BOOST_CHECK_EQUAL(wallet.GetBalance().m_mine_immature, 100 * COIN); | ||||
} | } | ||||
// Prune the older block file. | // Prune the older block file. | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
EnsureChainman(m_node).PruneOneBlockFile(oldTip->GetBlockPos().nFile); | Assert(m_node.chainman)->PruneOneBlockFile(oldTip->GetBlockPos().nFile); | ||||
} | } | ||||
UnlinkPrunedFiles({oldTip->GetBlockPos().nFile}); | UnlinkPrunedFiles({oldTip->GetBlockPos().nFile}); | ||||
// Verify ScanForWalletTransactions only picks transactions in the new block | // Verify ScanForWalletTransactions only picks transactions in the new block | ||||
// file. | // file. | ||||
{ | { | ||||
CWallet wallet(Params(), chain.get(), WalletLocation(), | CWallet wallet(Params(), chain.get(), WalletLocation(), | ||||
WalletDatabase::CreateDummy()); | WalletDatabase::CreateDummy()); | ||||
Show All 13 Lines | // file. | ||||
BOOST_CHECK_EQUAL(result.last_scanned_block, newTip->GetBlockHash()); | BOOST_CHECK_EQUAL(result.last_scanned_block, newTip->GetBlockHash()); | ||||
BOOST_CHECK_EQUAL(*result.last_scanned_height, newTip->nHeight); | BOOST_CHECK_EQUAL(*result.last_scanned_height, newTip->nHeight); | ||||
BOOST_CHECK_EQUAL(wallet.GetBalance().m_mine_immature, 50 * COIN); | BOOST_CHECK_EQUAL(wallet.GetBalance().m_mine_immature, 50 * COIN); | ||||
} | } | ||||
// Prune the remaining block file. | // Prune the remaining block file. | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
EnsureChainman(m_node).PruneOneBlockFile(newTip->GetBlockPos().nFile); | Assert(m_node.chainman)->PruneOneBlockFile(newTip->GetBlockPos().nFile); | ||||
} | } | ||||
UnlinkPrunedFiles({newTip->GetBlockPos().nFile}); | UnlinkPrunedFiles({newTip->GetBlockPos().nFile}); | ||||
// Verify ScanForWalletTransactions scans no blocks. | // Verify ScanForWalletTransactions scans no blocks. | ||||
{ | { | ||||
CWallet wallet(Params(), chain.get(), WalletLocation(), | CWallet wallet(Params(), chain.get(), WalletLocation(), | ||||
WalletDatabase::CreateDummy()); | WalletDatabase::CreateDummy()); | ||||
{ | { | ||||
Show All 23 Lines | BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup) { | ||||
CBlockIndex *newTip = ::ChainActive().Tip(); | CBlockIndex *newTip = ::ChainActive().Tip(); | ||||
NodeContext node; | NodeContext node; | ||||
auto chain = interfaces::MakeChain(node, Params()); | auto chain = interfaces::MakeChain(node, Params()); | ||||
// Prune the older block file. | // Prune the older block file. | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
EnsureChainman(m_node).PruneOneBlockFile(oldTip->GetBlockPos().nFile); | Assert(m_node.chainman)->PruneOneBlockFile(oldTip->GetBlockPos().nFile); | ||||
} | } | ||||
UnlinkPrunedFiles({oldTip->GetBlockPos().nFile}); | UnlinkPrunedFiles({oldTip->GetBlockPos().nFile}); | ||||
// Verify importmulti RPC returns failure for a key whose creation time is | // Verify importmulti RPC returns failure for a key whose creation time is | ||||
// before the missing block, and success for a key whose creation time is | // before the missing block, and success for a key whose creation time is | ||||
// after. | // after. | ||||
{ | { | ||||
std::shared_ptr<CWallet> wallet = | std::shared_ptr<CWallet> wallet = | ||||
▲ Show 20 Lines • Show All 535 Lines • Show Last 20 Lines |