aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@pm.me>2022-04-28 10:57:25 -0400
committerJames O'Beirne <james.obeirne@pm.me>2022-09-13 13:31:23 -0400
commitcced4e7336d93a2dc88e4a61c49941887766bd72 (patch)
treea592d65460deb9bdf5687927e4d070f8dd132512 /src/test
parent51fc9241c08a00f1f407f1534853a5cddbbc0a23 (diff)
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`.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/util/setup_common.cpp29
-rw-r--r--src/test/util/setup_common.h2
2 files changed, 19 insertions, 12 deletions
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index 852c04e2d9..9ac6c468e2 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -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,
diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h
index 9fe2692c26..3a7d1b54b3 100644
--- a/src/test/util/setup_common.h
+++ b/src/test/util/setup_common.h
@@ -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 = {},