mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
move-only: test: make snapshot chainstate setup reusable
For use in next commit. Most easily reviewed with `--color-moved=dimmed_zebra --color-moved-ws=allow-indentation-change`.
This commit is contained in:
parent
8153bd9247
commit
3a29dfbfb2
1 changed files with 156 additions and 141 deletions
|
@ -154,11 +154,14 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
|
|||
BOOST_CHECK_CLOSE(c2.m_coinsdb_cache_size_bytes, max_cache * 0.95, 1);
|
||||
}
|
||||
|
||||
//! Test basic snapshot activation.
|
||||
BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100Setup)
|
||||
struct SnapshotTestSetup : TestChain100Setup {
|
||||
std::tuple<Chainstate*, Chainstate*> SetupSnapshot()
|
||||
{
|
||||
ChainstateManager& chainman = *Assert(m_node.chainman);
|
||||
|
||||
BOOST_CHECK(!chainman.IsSnapshotActive());
|
||||
WITH_LOCK(::cs_main, BOOST_CHECK(!chainman.IsSnapshotValidated()));
|
||||
|
||||
size_t initial_size;
|
||||
size_t initial_total_coins{100};
|
||||
|
||||
|
@ -179,6 +182,8 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100Setup)
|
|||
BOOST_CHECK_EQUAL(initial_size, initial_total_coins);
|
||||
}
|
||||
|
||||
Chainstate& validation_chainstate = chainman.ActiveChainstate();
|
||||
|
||||
// Snapshot should refuse to load at this height.
|
||||
BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(m_node, m_path_root));
|
||||
BOOST_CHECK(!chainman.ActiveChainstate().m_from_snapshot_blockhash);
|
||||
|
@ -232,6 +237,8 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100Setup)
|
|||
*chainman.ActiveChainstate().m_from_snapshot_blockhash,
|
||||
*chainman.SnapshotBlockhash());
|
||||
|
||||
Chainstate& snapshot_chainstate = chainman.ActiveChainstate();
|
||||
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
|
||||
|
@ -319,6 +326,14 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100Setup)
|
|||
BOOST_CHECK_EQUAL(
|
||||
*chainman.ActiveChainstate().m_from_snapshot_blockhash,
|
||||
loaded_snapshot_blockhash);
|
||||
return std::make_tuple(&validation_chainstate, &snapshot_chainstate);
|
||||
}
|
||||
};
|
||||
|
||||
//! Test basic snapshot activation.
|
||||
BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, SnapshotTestSetup)
|
||||
{
|
||||
this->SetupSnapshot();
|
||||
}
|
||||
|
||||
//! Test LoadBlockIndex behavior when multiple chainstates are in use.
|
||||
|
|
Loading…
Add table
Reference in a new issue