mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Merge bitcoin/bitcoin#26286: test: Remove unused txmempool include from tests
1c48dae76f
test: Use C++11 member initializers for TestMemPoolEntryHelper (MacroFake)fad7f2239c
test: Remove unused txmempool include from tests (MacroFake) Pull request description: Seems odd to include this heavy header in all tests despite it only being used in a few tests. Can be reviewed with `--color-moved=dimmed-zebra --ignore-all-space` ACKs for top commit: aureleoules: reACK1c48dae76f
hebasto: ACK1c48dae76f
, I have reviewed the code and it looks OK, I agree it can be merged. w0xlt: ACK1c48dae76f
Tree-SHA512: 31f2808d04ec33bfc2409832b8e59e6c870eaa98fbcf879e1c786492c7d07134711b30f8290bdb34e1b8f7b8f2f11dae8e10c64e7eb31f584b2f5c58fcc7743b
This commit is contained in:
commit
003050dfaf
17 changed files with 110 additions and 69 deletions
|
@ -54,6 +54,9 @@
|
|||
<ProjectReference Include="..\libbitcoin_zmq\libbitcoin_zmq.vcxproj">
|
||||
<Project>{792d487f-f14c-49fc-a9de-3fc150f31c3f}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\libtest_util\libtest_util.vcxproj">
|
||||
<Project>{1e065f03-3566-47d0-8fa9-daa72b084e7d}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\libleveldb\libleveldb.vcxproj">
|
||||
<Project>{18430fef-6b61-4c53-b396-718e02850f1b}</Project>
|
||||
</ProjectReference>
|
||||
|
|
|
@ -5,20 +5,21 @@
|
|||
LIBTEST_UTIL=libtest_util.a
|
||||
|
||||
EXTRA_LIBRARIES += \
|
||||
$(LIBTEST_UTIL)
|
||||
$(LIBTEST_UTIL)
|
||||
|
||||
TEST_UTIL_H = \
|
||||
test/util/blockfilter.h \
|
||||
test/util/chainstate.h \
|
||||
test/util/logging.h \
|
||||
test/util/mining.h \
|
||||
test/util/net.h \
|
||||
test/util/script.h \
|
||||
test/util/setup_common.h \
|
||||
test/util/str.h \
|
||||
test/util/transaction_utils.h \
|
||||
test/util/validation.h \
|
||||
test/util/wallet.h
|
||||
test/util/blockfilter.h \
|
||||
test/util/chainstate.h \
|
||||
test/util/logging.h \
|
||||
test/util/mining.h \
|
||||
test/util/net.h \
|
||||
test/util/script.h \
|
||||
test/util/setup_common.h \
|
||||
test/util/str.h \
|
||||
test/util/transaction_utils.h \
|
||||
test/util/txmempool.h \
|
||||
test/util/validation.h \
|
||||
test/util/wallet.h
|
||||
|
||||
libtest_util_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
|
||||
libtest_util_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
|
@ -31,6 +32,7 @@ libtest_util_a_SOURCES = \
|
|||
test/util/setup_common.cpp \
|
||||
test/util/str.cpp \
|
||||
test/util/transaction_utils.cpp \
|
||||
test/util/txmempool.cpp \
|
||||
test/util/validation.cpp \
|
||||
test/util/wallet.cpp \
|
||||
$(TEST_UTIL_H)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <consensus/merkle.h>
|
||||
#include <pow.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/txmempool.h>
|
||||
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <test/fuzz/util.h>
|
||||
#include <test/fuzz/util/mempool.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <test/util/txmempool.h>
|
||||
#include <txmempool.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <test/util/mining.h>
|
||||
#include <test/util/script.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <test/util/txmempool.h>
|
||||
#include <util/rbf.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <test/fuzz/util.h>
|
||||
#include <test/fuzz/util/mempool.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <test/util/txmempool.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/time.h>
|
||||
#include <validation.h>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <policy/policy.h>
|
||||
#include <test/util/txmempool.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/system.h>
|
||||
#include <util/time.h>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <node/miner.h>
|
||||
#include <policy/policy.h>
|
||||
#include <script/standard.h>
|
||||
#include <test/util/txmempool.h>
|
||||
#include <timedata.h>
|
||||
#include <txmempool.h>
|
||||
#include <uint256.h>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <policy/fees.h>
|
||||
#include <policy/policy.h>
|
||||
#include <test/util/txmempool.h>
|
||||
#include <txmempool.h>
|
||||
#include <uint256.h>
|
||||
#include <util/time.h>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#include <policy/rbf.h>
|
||||
#include <random.h>
|
||||
#include <test/util/txmempool.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/system.h>
|
||||
#include <util/time.h>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <coins.h>
|
||||
#include <consensus/consensus.h>
|
||||
#include <consensus/tx_verify.h>
|
||||
#include <key.h>
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <shutdown.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/net.h>
|
||||
#include <test/util/txmempool.h>
|
||||
#include <timedata.h>
|
||||
#include <txdb.h>
|
||||
#include <txmempool.h>
|
||||
|
@ -60,7 +61,6 @@ using node::ApplyArgsManOptions;
|
|||
using node::BlockAssembler;
|
||||
using node::CalculateCacheSizes;
|
||||
using node::LoadChainstate;
|
||||
using node::NodeContext;
|
||||
using node::RegenerateCommitments;
|
||||
using node::VerifyLoadedChainstate;
|
||||
|
||||
|
@ -162,19 +162,6 @@ BasicTestingSetup::~BasicTestingSetup()
|
|||
gArgs.ClearArgs();
|
||||
}
|
||||
|
||||
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext& node)
|
||||
{
|
||||
CTxMemPool::Options mempool_opts{
|
||||
.estimator = node.fee_estimator.get(),
|
||||
// Default to always checking mempool regardless of
|
||||
// chainparams.DefaultConsistencyChecks for tests
|
||||
.check_ratio = 1,
|
||||
};
|
||||
const auto err{ApplyArgsManOptions(*node.args, ::Params(), mempool_opts)};
|
||||
Assert(!err);
|
||||
return mempool_opts;
|
||||
}
|
||||
|
||||
ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args)
|
||||
: BasicTestingSetup(chainName, extra_args)
|
||||
{
|
||||
|
@ -438,17 +425,6 @@ std::vector<CTransactionRef> TestChain100Setup::PopulateMempool(FastRandomContex
|
|||
return mempool_transactions;
|
||||
}
|
||||
|
||||
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction& tx) const
|
||||
{
|
||||
return FromTx(MakeTransactionRef(tx));
|
||||
}
|
||||
|
||||
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CTransactionRef& tx) const
|
||||
{
|
||||
return CTxMemPoolEntry(tx, nFee, nTime, nHeight,
|
||||
spendsCoinbase, sigOpCost, lp);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns a real block (0000000000013b8ab2cd513b0261a14096412195a72a0c4827d229dcc7e0f7af)
|
||||
* with 9 txs.
|
||||
|
|
|
@ -8,21 +8,23 @@
|
|||
#include <chainparamsbase.h>
|
||||
#include <fs.h>
|
||||
#include <key.h>
|
||||
#include <util/system.h>
|
||||
#include <node/caches.h>
|
||||
#include <node/context.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <pubkey.h>
|
||||
#include <random.h>
|
||||
#include <stdexcept>
|
||||
#include <txmempool.h>
|
||||
#include <util/check.h>
|
||||
#include <util/string.h>
|
||||
#include <util/system.h>
|
||||
#include <util/vector.h>
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
class Chainstate;
|
||||
|
||||
/** This is connected to the logger. Can be used to redirect logs to any other log */
|
||||
extern const std::function<void(const std::string&)> G_TEST_LOG_FUN;
|
||||
|
||||
|
@ -90,9 +92,6 @@ struct BasicTestingSetup {
|
|||
ArgsManager m_args;
|
||||
};
|
||||
|
||||
|
||||
CTxMemPool::Options MemPoolOptionsForTest(const node::NodeContext& node);
|
||||
|
||||
/** Testing setup that performs all steps up until right before
|
||||
* ChainstateManager gets initialized. Meant for testing ChainstateManager
|
||||
* initialization behaviour.
|
||||
|
@ -213,33 +212,6 @@ std::unique_ptr<T> MakeNoLogFileContext(const std::string& chain_name = CBaseCha
|
|||
return std::make_unique<T>(chain_name, arguments);
|
||||
}
|
||||
|
||||
class CTxMemPoolEntry;
|
||||
|
||||
struct TestMemPoolEntryHelper
|
||||
{
|
||||
// Default values
|
||||
CAmount nFee;
|
||||
int64_t nTime;
|
||||
unsigned int nHeight;
|
||||
bool spendsCoinbase;
|
||||
unsigned int sigOpCost;
|
||||
LockPoints lp;
|
||||
|
||||
TestMemPoolEntryHelper() :
|
||||
nFee(0), nTime(0), nHeight(1),
|
||||
spendsCoinbase(false), sigOpCost(4) { }
|
||||
|
||||
CTxMemPoolEntry FromTx(const CMutableTransaction& tx) const;
|
||||
CTxMemPoolEntry FromTx(const CTransactionRef& tx) const;
|
||||
|
||||
// Change the default value
|
||||
TestMemPoolEntryHelper &Fee(CAmount _fee) { nFee = _fee; return *this; }
|
||||
TestMemPoolEntryHelper &Time(int64_t _time) { nTime = _time; return *this; }
|
||||
TestMemPoolEntryHelper &Height(unsigned int _height) { nHeight = _height; return *this; }
|
||||
TestMemPoolEntryHelper &SpendsCoinbase(bool _flag) { spendsCoinbase = _flag; return *this; }
|
||||
TestMemPoolEntryHelper &SigOpsCost(unsigned int _sigopsCost) { sigOpCost = _sigopsCost; return *this; }
|
||||
};
|
||||
|
||||
CBlock getBlock13b8a();
|
||||
|
||||
// define an implicit conversion here so that uint256 may be used directly in BOOST_CHECK_*
|
||||
|
|
39
src/test/util/txmempool.cpp
Normal file
39
src/test/util/txmempool.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) 2022 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <test/util/txmempool.h>
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <node/context.h>
|
||||
#include <node/mempool_args.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/check.h>
|
||||
#include <util/time.h>
|
||||
#include <util/translation.h>
|
||||
|
||||
using node::NodeContext;
|
||||
|
||||
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext& node)
|
||||
{
|
||||
CTxMemPool::Options mempool_opts{
|
||||
.estimator = node.fee_estimator.get(),
|
||||
// Default to always checking mempool regardless of
|
||||
// chainparams.DefaultConsistencyChecks for tests
|
||||
.check_ratio = 1,
|
||||
};
|
||||
const auto err{ApplyArgsManOptions(*node.args, ::Params(), mempool_opts)};
|
||||
Assert(!err);
|
||||
return mempool_opts;
|
||||
}
|
||||
|
||||
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction& tx) const
|
||||
{
|
||||
return FromTx(MakeTransactionRef(tx));
|
||||
}
|
||||
|
||||
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CTransactionRef& tx) const
|
||||
{
|
||||
return CTxMemPoolEntry(tx, nFee, nTime, nHeight,
|
||||
spendsCoinbase, sigOpCost, lp);
|
||||
}
|
37
src/test/util/txmempool.h
Normal file
37
src/test/util/txmempool.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) 2022 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_TEST_UTIL_TXMEMPOOL_H
|
||||
#define BITCOIN_TEST_UTIL_TXMEMPOOL_H
|
||||
|
||||
#include <txmempool.h>
|
||||
|
||||
namespace node {
|
||||
struct NodeContext;
|
||||
}
|
||||
|
||||
CTxMemPool::Options MemPoolOptionsForTest(const node::NodeContext& node);
|
||||
|
||||
struct TestMemPoolEntryHelper
|
||||
{
|
||||
// Default values
|
||||
CAmount nFee{0};
|
||||
int64_t nTime{0};
|
||||
unsigned int nHeight{1};
|
||||
bool spendsCoinbase{false};
|
||||
unsigned int sigOpCost{4};
|
||||
LockPoints lp;
|
||||
|
||||
CTxMemPoolEntry FromTx(const CMutableTransaction& tx) const;
|
||||
CTxMemPoolEntry FromTx(const CTransactionRef& tx) const;
|
||||
|
||||
// Change the default value
|
||||
TestMemPoolEntryHelper &Fee(CAmount _fee) { nFee = _fee; return *this; }
|
||||
TestMemPoolEntryHelper &Time(int64_t _time) { nTime = _time; return *this; }
|
||||
TestMemPoolEntryHelper &Height(unsigned int _height) { nHeight = _height; return *this; }
|
||||
TestMemPoolEntryHelper &SpendsCoinbase(bool _flag) { spendsCoinbase = _flag; return *this; }
|
||||
TestMemPoolEntryHelper &SigOpsCost(unsigned int _sigopsCost) { sigOpCost = _sigopsCost; return *this; }
|
||||
};
|
||||
|
||||
#endif // BITCOIN_TEST_UTIL_TXMEMPOOL_H
|
|
@ -26,6 +26,7 @@
|
|||
#include <util/bitdeque.h>
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <consensus/validation.h>
|
||||
#include <policy/policy.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <script/script.h>
|
||||
#include <util/strencodings.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue