@@ -342,23 +342,12 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
342342 assert (!maybe_verify_error.has_value ());
343343
344344 m_node.dstxman = std::make_unique<CDSTXManager>();
345- m_node.banman = std::make_unique<BanMan>(m_args.GetDataDirBase () / " banlist" , nullptr , DEFAULT_MISBEHAVING_BANTIME);
346- m_node.peerman = PeerManager::make (chainparams, *m_node.connman , *m_node.addrman , m_node.banman .get (), *m_node.dstxman ,
347- *m_node.chainman , *m_node.mempool , *m_node.mn_metaman , *m_node.mn_sync ,
348- *m_node.govman , *m_node.sporkman , /* mn_activeman=*/ nullptr , m_node.dmnman ,
349- /* active_ctx=*/ nullptr , m_node.cj_ctx , m_node.llmq_ctx , /* ignore_incoming_txs=*/ false );
350- {
351- CConnman::Options options;
352- options.m_msgproc = m_node.peerman .get ();
353- options.socketEventsMode = ::g_socket_events_mode;
354- m_node.connman ->Init (options);
355- }
356-
345+ #ifdef ENABLE_WALLET
346+ // The test suite doesn't use masternode mode, so we may initialize it
357347 m_node.cj_ctx = CJContext::make (*m_node.chainman , *m_node.dmnman , *m_node.mn_metaman , *m_node.mempool ,
358- /* mn_activeman= */ nullptr , * m_node.mn_sync , *m_node.llmq_ctx ->isman ,
359- /* relay_txes= */ true );
348+ * m_node.mn_sync , *m_node.llmq_ctx ->isman , /* relay_txes= */ true );
349+ assert (m_node. cj_ctx );
360350
361- #ifdef ENABLE_WALLET
362351 // WalletInit::Construct()-like logic needed for wallet tests that run on
363352 // TestingSetup and its children (e.g. TestChain100Setup) instead of
364353 // WalletTestingSetup
@@ -369,6 +358,18 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
369358 m_node.chain_clients .emplace_back (std::move (wallet_loader));
370359#endif // ENABLE_WALLET
371360
361+ m_node.banman = std::make_unique<BanMan>(m_args.GetDataDirBase () / " banlist" , nullptr , DEFAULT_MISBEHAVING_BANTIME);
362+ m_node.peerman = PeerManager::make (chainparams, *m_node.connman , *m_node.addrman , m_node.banman .get (), *m_node.dstxman ,
363+ *m_node.chainman , *m_node.mempool , *m_node.mn_metaman , *m_node.mn_sync ,
364+ *m_node.govman , *m_node.sporkman , /* mn_activeman=*/ nullptr , m_node.dmnman ,
365+ /* active_ctx=*/ nullptr , m_node.cj_ctx .get (), m_node.llmq_ctx , /* ignore_incoming_txs=*/ false );
366+ {
367+ CConnman::Options options;
368+ options.m_msgproc = m_node.peerman .get ();
369+ options.socketEventsMode = ::g_socket_events_mode;
370+ m_node.connman ->Init (options);
371+ }
372+
372373 BlockValidationState state;
373374 if (!m_node.chainman ->ActiveChainstate ().ActivateBestChain (state)) {
374375 throw std::runtime_error (strprintf (" ActivateBestChain failed. (%s)" , state.ToString ()));
@@ -377,15 +378,17 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
377378
378379TestingSetup::~TestingSetup ()
379380{
381+ m_node.peerman .reset ();
382+ m_node.banman .reset ();
380383#ifdef ENABLE_WALLET
381384 for (auto & client : m_node.chain_clients ) {
382385 client.reset ();
383386 }
384387 m_node.wallet_loader = nullptr ;
385-
386388 m_node.coinjoin_loader .reset ();
387- #endif // ENABLE_WALLET
388389 m_node.cj_ctx .reset ();
390+ #endif // ENABLE_WALLET
391+ m_node.dstxman .reset ();
389392
390393 // Interrupt() and PrepareShutdown() routines
391394 if (m_node.llmq_ctx ) {
@@ -399,10 +402,6 @@ TestingSetup::~TestingSetup()
399402 // DashChainstateSetup() is called by LoadChainstate() internally but
400403 // winding them down is our responsibility
401404 DashChainstateSetupClose (m_node);
402-
403- m_node.peerman .reset ();
404- m_node.banman .reset ();
405- m_node.dstxman .reset ();
406405}
407406
408407TestChain100Setup::TestChain100Setup (const std::string& chain_name, const std::vector<const char *>& extra_args)
0 commit comments