Skip to content

Commit c9c5275

Browse files
committed
refactor: get rid of DashPostChainstateSetup()
`validation_chainstatemanager_tests` can work without `CJContext`, we can safely reincorporate it into `TestingSetup`.
1 parent 6502e54 commit c9c5275

File tree

3 files changed

+10
-28
lines changed

3 files changed

+10
-28
lines changed

src/test/util/setup_common.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -118,24 +118,6 @@ void DashChainstateSetupClose(NodeContext& node)
118118
Assert(node.mempool.get()));
119119
}
120120

121-
void DashPostChainstateSetup(NodeContext& node)
122-
{
123-
node.cj_ctx = std::make_unique<CJContext>(*node.chainman, *node.connman, *node.dmnman, *node.mn_metaman, *node.mempool,
124-
/*mn_activeman=*/nullptr, *node.mn_sync, *node.llmq_ctx->isman, node.peerman,
125-
/*relay_txes=*/true);
126-
#ifdef ENABLE_WALLET
127-
node.coinjoin_loader = interfaces::MakeCoinJoinLoader(node);
128-
#endif // ENABLE_WALLET
129-
}
130-
131-
void DashPostChainstateSetupClose(NodeContext& node)
132-
{
133-
#ifdef ENABLE_WALLET
134-
node.coinjoin_loader.reset();
135-
#endif // ENABLE_WALLET
136-
node.cj_ctx.reset();
137-
}
138-
139121
BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args)
140122
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()},
141123
m_args{}
@@ -330,7 +312,12 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
330312
m_node.connman->Init(options);
331313
}
332314

333-
DashPostChainstateSetup(m_node);
315+
m_node.cj_ctx = std::make_unique<CJContext>(*m_node.chainman, *m_node.connman, *m_node.dmnman, *m_node.mn_metaman, *m_node.mempool,
316+
/*mn_activeman=*/nullptr, *m_node.mn_sync, *m_node.llmq_ctx->isman, m_node.peerman,
317+
/*relay_txes=*/true);
318+
#ifdef ENABLE_WALLET
319+
m_node.coinjoin_loader = interfaces::MakeCoinJoinLoader(m_node);
320+
#endif // ENABLE_WALLET
334321

335322
BlockValidationState state;
336323
if (!m_node.chainman->ActiveChainstate().ActivateBestChain(state)) {
@@ -340,7 +327,10 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
340327

341328
TestingSetup::~TestingSetup()
342329
{
343-
DashPostChainstateSetupClose(m_node);
330+
#ifdef ENABLE_WALLET
331+
m_node.coinjoin_loader.reset();
332+
#endif // ENABLE_WALLET
333+
m_node.cj_ctx.reset();
344334

345335
// Interrupt() and PrepareShutdown() routines
346336
if (m_node.llmq_ctx) {

src/test/util/setup_common.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ void DashChainstateSetup(ChainstateManager& chainman,
9191
const Consensus::Params& consensus_params);
9292
void DashChainstateSetupClose(NodeContext& node);
9393

94-
/** Initialize Dash-specific components after chainstate initialization */
95-
void DashPostChainstateSetup(NodeContext& node);
96-
void DashPostChainstateSetupClose(NodeContext& node);
97-
9894
/** Basic testing setup.
9995
* This just configures logging, data dir and chain parameters.
10096
*/

src/test/validation_chainstatemanager_tests.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
5050
WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23));
5151

5252
DashChainstateSetup(manager, m_node, /*fReset=*/false, /*fReindexChainState=*/false, consensus_params);
53-
DashPostChainstateSetup(m_node);
5453

5554
BOOST_CHECK(!manager.IsSnapshotActive());
5655
BOOST_CHECK(WITH_LOCK(::cs_main, return !manager.IsSnapshotValidated()));
@@ -68,7 +67,6 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
6867

6968
BOOST_CHECK(!manager.SnapshotBlockhash().has_value());
7069

71-
DashPostChainstateSetupClose(m_node);
7270
if (m_node.llmq_ctx) {
7371
m_node.llmq_ctx->Interrupt();
7472
m_node.llmq_ctx->Stop();
@@ -85,7 +83,6 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
8583
chainstates.push_back(&c2);
8684

8785
DashChainstateSetup(manager, m_node, /*fReset=*/false, /*fReindexChainState=*/false, consensus_params);
88-
DashPostChainstateSetup(m_node);
8986

9087
BOOST_CHECK_EQUAL(manager.SnapshotBlockhash().value(), snapshot_blockhash);
9188

@@ -120,7 +117,6 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
120117
// Let scheduler events finish running to avoid accessing memory that is going to be unloaded
121118
SyncWithValidationInterfaceQueue();
122119

123-
DashPostChainstateSetupClose(m_node);
124120
if (m_node.llmq_ctx) {
125121
m_node.llmq_ctx->Interrupt();
126122
m_node.llmq_ctx->Stop();

0 commit comments

Comments
 (0)