Changeset View
Changeset View
Standalone View
Standalone View
src/test/util/setup_common.cpp
Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node) { | ||||
}; | }; | ||||
const auto err{ApplyArgsManOptions( | const auto err{ApplyArgsManOptions( | ||||
*node.args, ::GetConfig().GetChainParams(), mempool_opts)}; | *node.args, ::GetConfig().GetChainParams(), mempool_opts)}; | ||||
Assert(!err); | Assert(!err); | ||||
return mempool_opts; | return mempool_opts; | ||||
} | } | ||||
ChainTestingSetup::ChainTestingSetup( | ChainTestingSetup::ChainTestingSetup( | ||||
const std::string &chainName, const std::vector<const char *> &extra_args) | const std::string &chainName, const std::vector<const char *> &extra_args, | ||||
const Config &config) | |||||
: BasicTestingSetup(chainName, extra_args) { | : BasicTestingSetup(chainName, extra_args) { | ||||
const Config &config = GetConfig(); | |||||
// 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. | ||||
m_node.scheduler = std::make_unique<CScheduler>(); | m_node.scheduler = std::make_unique<CScheduler>(); | ||||
m_node.scheduler->m_service_thread = | m_node.scheduler->m_service_thread = | ||||
std::thread(util::TraceThread, "scheduler", | std::thread(util::TraceThread, "scheduler", | ||||
[&] { m_node.scheduler->serviceQueue(); }); | [&] { m_node.scheduler->serviceQueue(); }); | ||||
GetMainSignals().RegisterBackgroundSignalScheduler(*m_node.scheduler); | GetMainSignals().RegisterBackgroundSignalScheduler(*m_node.scheduler); | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | if (!chainman.ActiveChainstate().ActivateBestChain(state)) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
strprintf("ActivateBestChain failed. (%s)", state.ToString())); | strprintf("ActivateBestChain failed. (%s)", state.ToString())); | ||||
} | } | ||||
} | } | ||||
TestingSetup::TestingSetup(const std::string &chainName, | TestingSetup::TestingSetup(const std::string &chainName, | ||||
const std::vector<const char *> &extra_args, | const std::vector<const char *> &extra_args, | ||||
const bool coins_db_in_memory, | const bool coins_db_in_memory, | ||||
const bool block_tree_db_in_memory) | const bool block_tree_db_in_memory, | ||||
: ChainTestingSetup(chainName, extra_args), | const Config &config) | ||||
: ChainTestingSetup(chainName, extra_args, config), | |||||
m_coins_db_in_memory(coins_db_in_memory), | m_coins_db_in_memory(coins_db_in_memory), | ||||
m_block_tree_db_in_memory(block_tree_db_in_memory) { | m_block_tree_db_in_memory(block_tree_db_in_memory) { | ||||
const Config &config = GetConfig(); | |||||
// Ideally we'd move all the RPC tests to the functional testing framework | // Ideally we'd move all the RPC tests to the functional testing framework | ||||
// instead of unit tests, but for now we need these here. | // instead of unit tests, but for now we need these here. | ||||
RPCServer rpcServer; | RPCServer rpcServer; | ||||
RegisterAllRPCCommands(config, rpcServer, tableRPC); | RegisterAllRPCCommands(config, rpcServer, tableRPC); | ||||
/** | /** | ||||
* RPC does not come out of the warmup state on its own. Normally, this is | * RPC does not come out of the warmup state on its own. Normally, this is | ||||
* 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 | ||||
▲ Show 20 Lines • Show All 337 Lines • Show Last 20 Lines |