Changeset View
Changeset View
Standalone View
Standalone View
src/test/util/setup_common.cpp
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | TestingSetup::TestingSetup(const std::string &chainName) | ||||
* handled in bitcoind's init path, but unit tests do not trigger this | * handled in bitcoind's init path, but unit tests do not trigger this | ||||
* codepath, so we call it explicitly as part of setup. | * codepath, so we call it explicitly as part of setup. | ||||
*/ | */ | ||||
std::string rpcWarmupStatus; | std::string rpcWarmupStatus; | ||||
if (RPCIsInWarmup(&rpcWarmupStatus)) { | if (RPCIsInWarmup(&rpcWarmupStatus)) { | ||||
SetRPCWarmupFinished(); | SetRPCWarmupFinished(); | ||||
} | } | ||||
m_node.scheduler = std::make_unique<CScheduler>(); | |||||
// 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(std::bind(&CScheduler::serviceQueue, &scheduler)); | threadGroup.create_thread([&] { m_node.scheduler->serviceQueue(); }); | ||||
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler); | GetMainSignals().RegisterBackgroundSignalScheduler(*g_rpc_node->scheduler); | ||||
pblocktree.reset(new CBlockTreeDB(1 << 20, true)); | pblocktree.reset(new CBlockTreeDB(1 << 20, true)); | ||||
pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true)); | pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true)); | ||||
pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get())); | pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get())); | ||||
if (!LoadGenesisBlock(chainparams)) { | if (!LoadGenesisBlock(chainparams)) { | ||||
throw std::runtime_error("LoadGenesisBlock failed."); | throw std::runtime_error("LoadGenesisBlock failed."); | ||||
} | } | ||||
{ | { | ||||
Show All 21 Lines | TestingSetup::~TestingSetup() { | ||||
threadGroup.interrupt_all(); | threadGroup.interrupt_all(); | ||||
threadGroup.join_all(); | threadGroup.join_all(); | ||||
GetMainSignals().FlushBackgroundCallbacks(); | GetMainSignals().FlushBackgroundCallbacks(); | ||||
GetMainSignals().UnregisterBackgroundSignalScheduler(); | GetMainSignals().UnregisterBackgroundSignalScheduler(); | ||||
g_rpc_node = nullptr; | g_rpc_node = nullptr; | ||||
m_node.connman.reset(); | m_node.connman.reset(); | ||||
m_node.banman.reset(); | m_node.banman.reset(); | ||||
m_node.mempool = nullptr; | m_node.mempool = nullptr; | ||||
m_node.scheduler.reset(); | |||||
UnloadBlockIndex(); | UnloadBlockIndex(); | ||||
pcoinsTip.reset(); | pcoinsTip.reset(); | ||||
pcoinsdbview.reset(); | pcoinsdbview.reset(); | ||||
pblocktree.reset(); | pblocktree.reset(); | ||||
} | } | ||||
TestChain100Setup::TestChain100Setup() { | TestChain100Setup::TestChain100Setup() { | ||||
// Generate a 100-block chain: | // Generate a 100-block chain: | ||||
▲ Show 20 Lines • Show All 172 Lines • Show Last 20 Lines |