diff options
Diffstat (limited to 'src/test/util')
-rw-r--r-- | src/test/util/net.cpp | 3 | ||||
-rw-r--r-- | src/test/util/net.h | 11 | ||||
-rw-r--r-- | src/test/util/setup_common.cpp | 26 | ||||
-rw-r--r-- | src/test/util/setup_common.h | 3 |
4 files changed, 39 insertions, 4 deletions
diff --git a/src/test/util/net.cpp b/src/test/util/net.cpp index 62b770753a..071193b550 100644 --- a/src/test/util/net.cpp +++ b/src/test/util/net.cpp @@ -5,6 +5,7 @@ #include <test/util/net.h> #include <chainparams.h> +#include <node/eviction.h> #include <net.h> #include <span.h> @@ -58,6 +59,8 @@ std::vector<NodeEvictionCandidate> GetRandomNodeEvictionCandidates(int n_candida /*prefer_evict=*/random_context.randbool(), /*m_is_local=*/random_context.randbool(), /*m_network=*/ALL_NETWORKS[random_context.randrange(ALL_NETWORKS.size())], + /*m_noban=*/false, + /*m_conn_type=*/ConnectionType::INBOUND, }); } return candidates; diff --git a/src/test/util/net.h b/src/test/util/net.h index edb45d7c8e..34ab9958c6 100644 --- a/src/test/util/net.h +++ b/src/test/util/net.h @@ -6,6 +6,7 @@ #define BITCOIN_TEST_UTIL_NET_H #include <compat.h> +#include <node/eviction.h> #include <netaddress.h> #include <net.h> #include <util/sock.h> @@ -122,6 +123,10 @@ public: int Connect(const sockaddr*, socklen_t) const override { return 0; } + int Bind(const sockaddr*, socklen_t) const override { return 0; } + + int Listen(int) const override { return 0; } + std::unique_ptr<Sock> Accept(sockaddr* addr, socklen_t* addr_len) const override { if (addr != nullptr) { @@ -147,6 +152,12 @@ public: int SetSockOpt(int, int, const void*, socklen_t) const override { return 0; } + int GetSockName(sockaddr* name, socklen_t* name_len) const override + { + std::memset(name, 0x0, *name_len); + return 0; + } + bool Wait(std::chrono::milliseconds timeout, Event requested, Event* occurred = nullptr) const override diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index d9fff85bf5..0c9e880d67 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -14,13 +14,16 @@ #include <init.h> #include <init/common.h> #include <interfaces/chain.h> +#include <mempool_args.h> #include <net.h> #include <net_processing.h> #include <node/blockstorage.h> #include <node/chainstate.h> +#include <node/context.h> #include <node/miner.h> #include <noui.h> #include <policy/fees.h> +#include <policy/fees_args.h> #include <pow.h> #include <rpc/blockchain.h> #include <rpc/register.h> @@ -32,6 +35,8 @@ #include <test/util/net.h> #include <timedata.h> #include <txdb.h> +#include <txmempool.h> +#include <util/designator.h> #include <util/strencodings.h> #include <util/string.h> #include <util/thread.h> @@ -50,11 +55,12 @@ using node::BlockAssembler; using node::CalculateCacheSizes; +using node::fPruneMode; +using node::fReindex; using node::LoadChainstate; +using node::NodeContext; using node::RegenerateCommitments; using node::VerifyLoadedChainstate; -using node::fPruneMode; -using node::fReindex; const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr; UrlDecodeFn* const URL_DECODE = nullptr; @@ -149,6 +155,18 @@ BasicTestingSetup::~BasicTestingSetup() gArgs.ClearArgs(); } +CTxMemPool::Options MemPoolOptionsForTest(const NodeContext& node) +{ + CTxMemPool::Options mempool_opts{ + Desig(estimator) node.fee_estimator.get(), + // Default to always checking mempool regardless of + // chainparams.DefaultConsistencyChecks for tests + Desig(check_ratio) 1, + }; + ApplyArgsManOptions(*node.args, mempool_opts); + return mempool_opts; +} + ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args) : BasicTestingSetup(chainName, extra_args) { @@ -160,8 +178,8 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve m_node.scheduler->m_service_thread = std::thread(util::TraceThread, "scheduler", [&] { m_node.scheduler->serviceQueue(); }); GetMainSignals().RegisterBackgroundSignalScheduler(*m_node.scheduler); - m_node.fee_estimator = std::make_unique<CBlockPolicyEstimator>(); - m_node.mempool = std::make_unique<CTxMemPool>(m_node.fee_estimator.get(), m_node.args->GetIntArg("-checkmempool", 1)); + m_node.fee_estimator = std::make_unique<CBlockPolicyEstimator>(FeeestPath(*m_node.args)); + m_node.mempool = std::make_unique<CTxMemPool>(MemPoolOptionsForTest(m_node)); m_cache_sizes = CalculateCacheSizes(m_args); diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index 37407bcb92..ed2c5db7e6 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -90,6 +90,9 @@ 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. |