Skip to content

Commit fae8c73

Browse files
author
MarcoFalke
committed
test: Disallow fee_estimator construction in ChainTestingSetup
It is expensive to construct, and only one test uses it. Fix both issues by disallowing the construction and moving it to the single test that uses it.
1 parent 389cf32 commit fae8c73

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/test/policyestimator_tests.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright (c) 2011-2022 The Bitcoin Core developers
1+
// Copyright (c) 2011-present The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <policy/fees.h>
6+
#include <policy/fees_args.h>
67
#include <policy/policy.h>
78
#include <test/util/txmempool.h>
89
#include <txmempool.h>
@@ -18,7 +19,7 @@ BOOST_FIXTURE_TEST_SUITE(policyestimator_tests, ChainTestingSetup)
1819

1920
BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
2021
{
21-
CBlockPolicyEstimator& feeEst = *Assert(m_node.fee_estimator);
22+
CBlockPolicyEstimator feeEst{FeeestPath(*m_node.args), DEFAULT_ACCEPT_STALE_FEE_ESTIMATES};
2223
CTxMemPool& mpool = *Assert(m_node.mempool);
2324
m_node.validation_signals->RegisterValidationInterface(&feeEst);
2425
TestMemPoolEntryHelper entry;

src/test/util/setup_common.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2011-2022 The Bitcoin Core developers
1+
// Copyright (c) 2011-present The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -31,7 +31,6 @@
3131
#include <node/warnings.h>
3232
#include <noui.h>
3333
#include <policy/fees.h>
34-
#include <policy/fees_args.h>
3534
#include <pow.h>
3635
#include <random.h>
3736
#include <rpc/blockchain.h>
@@ -236,7 +235,6 @@ ChainTestingSetup::ChainTestingSetup(const ChainType chainType, TestOpts opts)
236235
m_node.validation_signals = std::make_unique<ValidationSignals>(std::make_unique<SerialTaskRunner>(*m_node.scheduler));
237236
}
238237

239-
m_node.fee_estimator = std::make_unique<CBlockPolicyEstimator>(FeeestPath(*m_node.args), DEFAULT_ACCEPT_STALE_FEE_ESTIMATES);
240238
bilingual_str error{};
241239
m_node.mempool = std::make_unique<CTxMemPool>(MemPoolOptionsForTest(m_node), error);
242240
Assert(error.empty());
@@ -276,7 +274,7 @@ ChainTestingSetup::~ChainTestingSetup()
276274
m_node.netgroupman.reset();
277275
m_node.args = nullptr;
278276
m_node.mempool.reset();
279-
m_node.fee_estimator.reset();
277+
Assert(!m_node.fee_estimator); // Each test must create a local object, if they wish to use the fee_estimator
280278
m_node.chainman.reset();
281279
m_node.validation_signals.reset();
282280
m_node.scheduler.reset();

0 commit comments

Comments
 (0)