Changeset View
Changeset View
Standalone View
Standalone View
src/test/validation_chainstatemanager_tests.cpp
Show All 40 Lines | CChainState &c1 = | ||||
*WITH_LOCK(::cs_main, return &manager.InitializeChainstate(&mempool)); | *WITH_LOCK(::cs_main, return &manager.InitializeChainstate(&mempool)); | ||||
chainstates.push_back(&c1); | chainstates.push_back(&c1); | ||||
c1.InitCoinsDB( | c1.InitCoinsDB( | ||||
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, | /* cache_size_bytes */ 1 << 23, /* in_memory */ true, | ||||
/* should_wipe */ false); | /* should_wipe */ false); | ||||
WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23)); | WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23)); | ||||
BOOST_CHECK(!manager.IsSnapshotActive()); | BOOST_CHECK(!manager.IsSnapshotActive()); | ||||
BOOST_CHECK(!manager.IsSnapshotValidated()); | BOOST_CHECK(WITH_LOCK(::cs_main, return !manager.IsSnapshotValidated())); | ||||
auto all = manager.GetAll(); | auto all = manager.GetAll(); | ||||
BOOST_CHECK_EQUAL_COLLECTIONS(all.begin(), all.end(), chainstates.begin(), | BOOST_CHECK_EQUAL_COLLECTIONS(all.begin(), all.end(), chainstates.begin(), | ||||
chainstates.end()); | chainstates.end()); | ||||
auto &active_chain = manager.ActiveChain(); | auto &active_chain = manager.ActiveChain(); | ||||
BOOST_CHECK_EQUAL(&active_chain, &c1.m_chain); | BOOST_CHECK_EQUAL(&active_chain, &c1.m_chain); | ||||
BOOST_CHECK_EQUAL(manager.ActiveHeight(), -1); | BOOST_CHECK_EQUAL(manager.ActiveHeight(), -1); | ||||
Show All 19 Lines | c2.InitCoinsDB( | ||||
/* should_wipe */ false); | /* should_wipe */ false); | ||||
WITH_LOCK(::cs_main, c2.InitCoinsCache(1 << 23)); | WITH_LOCK(::cs_main, c2.InitCoinsCache(1 << 23)); | ||||
// Unlike c1, which doesn't have any blocks. Gets us different tip, height. | // Unlike c1, which doesn't have any blocks. Gets us different tip, height. | ||||
c2.LoadGenesisBlock(); | c2.LoadGenesisBlock(); | ||||
BlockValidationState _; | BlockValidationState _; | ||||
BOOST_CHECK(c2.ActivateBestChain(GetConfig(), _, nullptr)); | BOOST_CHECK(c2.ActivateBestChain(GetConfig(), _, nullptr)); | ||||
BOOST_CHECK(manager.IsSnapshotActive()); | BOOST_CHECK(manager.IsSnapshotActive()); | ||||
BOOST_CHECK(!manager.IsSnapshotValidated()); | BOOST_CHECK(WITH_LOCK(::cs_main, return !manager.IsSnapshotValidated())); | ||||
BOOST_CHECK_EQUAL(&c2, &manager.ActiveChainstate()); | BOOST_CHECK_EQUAL(&c2, &manager.ActiveChainstate()); | ||||
BOOST_CHECK(&c1 != &manager.ActiveChainstate()); | BOOST_CHECK(&c1 != &manager.ActiveChainstate()); | ||||
auto all2 = manager.GetAll(); | auto all2 = manager.GetAll(); | ||||
BOOST_CHECK_EQUAL_COLLECTIONS(all2.begin(), all2.end(), chainstates.begin(), | BOOST_CHECK_EQUAL_COLLECTIONS(all2.begin(), all2.end(), chainstates.begin(), | ||||
chainstates.end()); | chainstates.end()); | ||||
auto &active_chain2 = manager.ActiveChain(); | auto &active_chain2 = manager.ActiveChain(); | ||||
BOOST_CHECK_EQUAL(&active_chain2, &c2.m_chain); | BOOST_CHECK_EQUAL(&active_chain2, &c2.m_chain); | ||||
▲ Show 20 Lines • Show All 321 Lines • Show Last 20 Lines |