diff options
author | merge-script <fanquake@gmail.com> | 2024-07-25 13:53:50 +0100 |
---|---|---|
committer | merge-script <fanquake@gmail.com> | 2024-07-25 13:53:50 +0100 |
commit | bee23ce9ec3dc68def1eb9141a6be451e5053711 (patch) | |
tree | 64482f0a94598ca0dbb6ee9f67946bd880e60fac /src/test/util | |
parent | 30e8a79aefd4fee86df0a1f2f4e0430bb9387cf4 (diff) | |
parent | f46b2202560a76b473e229b77303b8f877c16cac (diff) |
Merge bitcoin/bitcoin#30399: test: Add arguments for creating a slimmer TestingSetup
f46b2202560a76b473e229b77303b8f877c16cac fuzz: Use BasicTestingSetup for coins_view target (TheCharlatan)
9e2a723d5da4fc277a42fed37424f578e348ebf8 test: Add arguments for creating a slimmer setup (TheCharlatan)
Pull request description:
This adds arguments to some of the testing setup constructors for creating an environment without networking and a validation interface. This is useful for improving the performance of the utxo snapshot fuzz test, which constructs a new TestingSetup on each iteration.
Using this slimmed down `TestingSetup` in future might also make the tests a bit faster when run in aggregate.
ACKs for top commit:
maflcko:
review ACK f46b2202560a76b473e229b77303b8f877c16cac
dergoegge:
utACK f46b2202560a76b473e229b77303b8f877c16cac
Tree-SHA512: 9dc62512b127b781fc9e2d8ef2b5a9b06ebb927a8294b6d872001c553984a7eb1f348e0257b32435b34b5505b5d0323f73bdd572a673da272d3e1e8538ab49d6
Diffstat (limited to 'src/test/util')
-rw-r--r-- | src/test/util/setup_common.cpp | 12 | ||||
-rw-r--r-- | src/test/util/setup_common.h | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index d0c465d189..abe3d6a505 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -230,9 +230,11 @@ ChainTestingSetup::ChainTestingSetup(const ChainType chainType, TestOpts opts) // We have to run a scheduler thread to prevent ActivateBestChain // from blocking due to queue overrun. - m_node.scheduler = std::make_unique<CScheduler>(); - m_node.scheduler->m_service_thread = std::thread(util::TraceThread, "scheduler", [&] { m_node.scheduler->serviceQueue(); }); - m_node.validation_signals = std::make_unique<ValidationSignals>(std::make_unique<SerialTaskRunner>(*m_node.scheduler)); + if (opts.setup_validation_interface) { + m_node.scheduler = std::make_unique<CScheduler>(); + m_node.scheduler->m_service_thread = std::thread(util::TraceThread, "scheduler", [&] { m_node.scheduler->serviceQueue(); }); + m_node.validation_signals = std::make_unique<ValidationSignals>(std::make_unique<SerialTaskRunner>(*m_node.scheduler)); + } m_node.fee_estimator = std::make_unique<CBlockPolicyEstimator>(FeeestPath(*m_node.args), DEFAULT_ACCEPT_STALE_FEE_ESTIMATES); bilingual_str error{}; @@ -267,7 +269,7 @@ ChainTestingSetup::ChainTestingSetup(const ChainType chainType, TestOpts opts) ChainTestingSetup::~ChainTestingSetup() { if (m_node.scheduler) m_node.scheduler->stop(); - m_node.validation_signals->FlushBackgroundCallbacks(); + if (m_node.validation_signals) m_node.validation_signals->FlushBackgroundCallbacks(); m_node.connman.reset(); m_node.banman.reset(); m_node.addrman.reset(); @@ -318,6 +320,8 @@ TestingSetup::TestingSetup( LoadVerifyActivateChainstate(); + if (!opts.setup_net) return; + m_node.netgroupman = std::make_unique<NetGroupManager>(/*asmap=*/std::vector<bool>()); m_node.addrman = std::make_unique<AddrMan>(*m_node.netgroupman, /*deterministic=*/false, diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index 6d8fcbbbfb..9515f0255e 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -53,6 +53,8 @@ struct TestOpts { std::vector<const char*> extra_args{}; bool coins_db_in_memory{true}; bool block_tree_db_in_memory{true}; + bool setup_net{true}; + bool setup_validation_interface{true}; }; /** Basic testing setup. |