mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-29 01:26:37 +02:00
test: move-only-ish: factor out LoadVerifyActivateChainstate()
in TestingSetup(). This is used in the following commit to test reinitializing chainstates after snapshot validation and cleanup. Best reviewed with `git diff --color-moved=dimmed-zebra`.
This commit is contained in:
@@ -220,19 +220,8 @@ ChainTestingSetup::~ChainTestingSetup()
|
||||
m_node.chainman.reset();
|
||||
}
|
||||
|
||||
TestingSetup::TestingSetup(
|
||||
const std::string& chainName,
|
||||
const std::vector<const char*>& extra_args,
|
||||
const bool coins_db_in_memory,
|
||||
const bool block_tree_db_in_memory)
|
||||
: ChainTestingSetup(chainName, extra_args),
|
||||
m_coins_db_in_memory(coins_db_in_memory),
|
||||
m_block_tree_db_in_memory(block_tree_db_in_memory)
|
||||
void TestingSetup::LoadVerifyActivateChainstate()
|
||||
{
|
||||
// Ideally we'd move all the RPC tests to the functional testing framework
|
||||
// instead of unit tests, but for now we need these here.
|
||||
RegisterAllCoreRPCCommands(tableRPC);
|
||||
|
||||
node::ChainstateLoadOptions options;
|
||||
options.mempool = Assert(m_node.mempool.get());
|
||||
options.block_tree_db_in_memory = m_block_tree_db_in_memory;
|
||||
@@ -252,6 +241,22 @@ TestingSetup::TestingSetup(
|
||||
if (!m_node.chainman->ActiveChainstate().ActivateBestChain(state)) {
|
||||
throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", state.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
TestingSetup::TestingSetup(
|
||||
const std::string& chainName,
|
||||
const std::vector<const char*>& extra_args,
|
||||
const bool coins_db_in_memory,
|
||||
const bool block_tree_db_in_memory)
|
||||
: ChainTestingSetup(chainName, extra_args),
|
||||
m_coins_db_in_memory(coins_db_in_memory),
|
||||
m_block_tree_db_in_memory(block_tree_db_in_memory)
|
||||
{
|
||||
// Ideally we'd move all the RPC tests to the functional testing framework
|
||||
// instead of unit tests, but for now we need these here.
|
||||
RegisterAllCoreRPCCommands(tableRPC);
|
||||
|
||||
LoadVerifyActivateChainstate();
|
||||
|
||||
m_node.netgroupman = std::make_unique<NetGroupManager>(/*asmap=*/std::vector<bool>());
|
||||
m_node.addrman = std::make_unique<AddrMan>(*m_node.netgroupman,
|
||||
|
@@ -110,6 +110,8 @@ struct TestingSetup : public ChainTestingSetup {
|
||||
bool m_coins_db_in_memory{true};
|
||||
bool m_block_tree_db_in_memory{true};
|
||||
|
||||
void LoadVerifyActivateChainstate();
|
||||
|
||||
explicit TestingSetup(
|
||||
const std::string& chainName = CBaseChainParams::MAIN,
|
||||
const std::vector<const char*>& extra_args = {},
|
||||
|
Reference in New Issue
Block a user