Changeset View
Changeset View
Standalone View
Standalone View
src/test/util/setup_common.cpp
Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | TestingSetup::TestingSetup(const std::string &chainName, | ||||
// We have to run a scheduler thread to prevent ActivateBestChain | // We have to run a scheduler thread to prevent ActivateBestChain | ||||
// from blocking due to queue overrun. | // from blocking due to queue overrun. | ||||
threadGroup.create_thread([&] { m_node.scheduler->serviceQueue(); }); | threadGroup.create_thread([&] { m_node.scheduler->serviceQueue(); }); | ||||
GetMainSignals().RegisterBackgroundSignalScheduler(*m_node.scheduler); | GetMainSignals().RegisterBackgroundSignalScheduler(*m_node.scheduler); | ||||
pblocktree.reset(new CBlockTreeDB(1 << 20, true)); | pblocktree.reset(new CBlockTreeDB(1 << 20, true)); | ||||
m_node.mempool = &::g_mempool; | m_node.mempool = std::make_unique<CTxMemPool>(); | ||||
m_node.mempool->setSanityCheck(1.0); | m_node.mempool->setSanityCheck(1.0); | ||||
m_node.chainman = &::g_chainman; | m_node.chainman = &::g_chainman; | ||||
m_node.chainman->InitializeChainstate(*m_node.mempool); | m_node.chainman->InitializeChainstate(*m_node.mempool); | ||||
::ChainstateActive().InitCoinsDB( | ::ChainstateActive().InitCoinsDB( | ||||
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, | /* cache_size_bytes */ 1 << 23, /* in_memory */ true, | ||||
/* should_wipe */ false); | /* should_wipe */ false); | ||||
assert(!::ChainstateActive().CanFlushToDisk()); | assert(!::ChainstateActive().CanFlushToDisk()); | ||||
Show All 35 Lines | TestingSetup::~TestingSetup() { | ||||
} | } | ||||
threadGroup.interrupt_all(); | threadGroup.interrupt_all(); | ||||
threadGroup.join_all(); | threadGroup.join_all(); | ||||
GetMainSignals().FlushBackgroundCallbacks(); | GetMainSignals().FlushBackgroundCallbacks(); | ||||
GetMainSignals().UnregisterBackgroundSignalScheduler(); | GetMainSignals().UnregisterBackgroundSignalScheduler(); | ||||
m_node.connman.reset(); | m_node.connman.reset(); | ||||
m_node.banman.reset(); | m_node.banman.reset(); | ||||
m_node.args = nullptr; | m_node.args = nullptr; | ||||
UnloadBlockIndex(m_node.mempool); | UnloadBlockIndex(m_node.mempool.get()); | ||||
m_node.mempool = nullptr; | m_node.mempool.reset(); | ||||
m_node.scheduler.reset(); | m_node.scheduler.reset(); | ||||
m_node.chainman->Reset(); | m_node.chainman->Reset(); | ||||
m_node.chainman = nullptr; | m_node.chainman = nullptr; | ||||
pblocktree.reset(); | pblocktree.reset(); | ||||
} | } | ||||
TestChain100Setup::TestChain100Setup() { | TestChain100Setup::TestChain100Setup() { | ||||
// Generate a 100-block chain: | // Generate a 100-block chain: | ||||
▲ Show 20 Lines • Show All 173 Lines • Show Last 20 Lines |