From b30f0fa4417ccb29314551ca74f660eb61206f25 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 1 Sep 2024 15:16:42 +0000 Subject: [PATCH] test: remove `connman` local from `BasicTestingSetup` `NodeContext` member was moved from `TestingSetup` to `BasicTestingSetup` in bitcoin#18571 but `connman` (which was a remnant from when `NodeContext` was absent) wasn't removed. Let's resolve that. --- src/test/util/setup_common.cpp | 15 +++++++-------- src/test/util/setup_common.h | 1 - 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 0c3d69b35d..135c0c89fc 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -177,8 +177,11 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve SetupNetworking(); InitSignatureCache(); InitScriptExecutionCache(); - m_node.addrman = std::make_unique(/* asmap */ std::vector(), /* deterministic */ false, /* consistency_check_ratio */ 0); m_node.chain = interfaces::MakeChain(m_node); + + m_node.addrman = std::make_unique(/* asmap */ std::vector(), /* deterministic */ false, /* consistency_check_ratio */ 0); + m_node.connman = std::make_unique(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests. + // while g_wallet_init_interface is init here at very early stage // we can't get rid of unique_ptr from wallet/contex.h // TODO: remove unique_ptr from wallet/context.h after bitcoin/bitcoin#22219 @@ -186,7 +189,6 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve fCheckBlockIndex = true; m_node.evodb = std::make_unique(1 << 20, true, true); m_node.mnhf_manager = std::make_unique(*m_node.evodb); - connman = std::make_unique(0x1337, 0x1337, *m_node.addrman); llmq::quorumSnapshotManager.reset(new llmq::CQuorumSnapshotManager(*m_node.evodb)); m_node.cpoolman = std::make_unique(*m_node.evodb); static bool noui_connected = false; @@ -200,11 +202,12 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve BasicTestingSetup::~BasicTestingSetup() { SetMockTime(0s); // Reset mocktime for following tests - connman.reset(); - llmq::quorumSnapshotManager.reset(); m_node.cpoolman.reset(); + llmq::quorumSnapshotManager.reset(); m_node.mnhf_manager.reset(); m_node.evodb.reset(); + m_node.connman.reset(); + m_node.addrman.reset(); LogInstance().DisconnectTestLogger(); fs::remove_all(m_path_root); @@ -227,8 +230,6 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve m_node.chainman = std::make_unique(); m_node.chainman->m_blockman.m_block_tree_db = std::make_unique(1 << 20, true); - m_node.connman = std::make_unique(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests. - m_node.mn_metaman = std::make_unique(); m_node.netfulfilledman = std::make_unique(); m_node.sporkman = std::make_unique(); @@ -252,8 +253,6 @@ ChainTestingSetup::~ChainTestingSetup() m_node.sporkman.reset(); m_node.netfulfilledman.reset(); m_node.mn_metaman.reset(); - m_node.connman.reset(); - m_node.addrman.reset(); m_node.args = nullptr; m_node.mempool.reset(); m_node.scheduler.reset(); diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index 28af81f0f1..f819c4d8d9 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -88,7 +88,6 @@ struct BasicTestingSetup { explicit BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN, const std::vector& extra_args = {}); ~BasicTestingSetup(); - std::unique_ptr connman; const fs::path m_path_root; ArgsManager m_args; };