aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz/tx_pool.cpp
diff options
context:
space:
mode:
authorlsilva01 <lsilva01@protonmail.com>2021-12-02 01:50:27 -0300
committerlsilva01 <lsilva01@protonmail.com>2021-12-07 18:56:29 -0300
commitf1f10c0514fe81318c8b064f9dad0e2f9a2cd037 (patch)
tree623a27c461312cfd878f4cdadecd41a6caaa778e /src/test/fuzz/tx_pool.cpp
parentdf562d698a386166ef93d03326c0480ea9bc11fe (diff)
Remove CTxMemPool params from ATMP
Co-authored-by: John Newbery <1063656+jnewbery@users.noreply.github.com> Co-authored-by: Jon Atack <jon@atack.com>
Diffstat (limited to 'src/test/fuzz/tx_pool.cpp')
-rw-r--r--src/test/fuzz/tx_pool.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/test/fuzz/tx_pool.cpp b/src/test/fuzz/tx_pool.cpp
index c32c965ab0..fe1b9c7c0c 100644
--- a/src/test/fuzz/tx_pool.cpp
+++ b/src/test/fuzz/tx_pool.cpp
@@ -29,6 +29,15 @@ struct MockedTxPool : public CTxMemPool {
}
};
+class DummyChainState final : public CChainState
+{
+public:
+ void SetMempool(CTxMemPool* mempool)
+ {
+ m_mempool = mempool;
+ }
+};
+
void initialize_tx_pool()
{
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
@@ -114,7 +123,7 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
{
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
const auto& node = g_setup->m_node;
- auto& chainstate = node.chainman->ActiveChainstate();
+ auto& chainstate{static_cast<DummyChainState&>(node.chainman->ActiveChainstate())};
MockTime(fuzzed_data_provider, chainstate);
SetMempoolConstraints(*node.args, fuzzed_data_provider);
@@ -134,6 +143,8 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
CTxMemPool tx_pool_{/*estimator=*/nullptr, /*check_ratio=*/1};
MockedTxPool& tx_pool = *static_cast<MockedTxPool*>(&tx_pool_);
+ chainstate.SetMempool(&tx_pool);
+
// Helper to query an amount
const CCoinsViewMemPool amount_view{WITH_LOCK(::cs_main, return &chainstate.CoinsTip()), tx_pool};
const auto GetAmount = [&](const COutPoint& outpoint) {
@@ -230,7 +241,7 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
Assert(it->second.m_result_type == MempoolAcceptResult::ResultType::VALID ||
it->second.m_result_type == MempoolAcceptResult::ResultType::INVALID);
- const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(tx_pool, chainstate, tx, GetTime(), bypass_limits, /* test_accept= */ false));
+ const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx, GetTime(), bypass_limits, /*test_accept=*/false));
const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
SyncWithValidationInterfaceQueue();
UnregisterSharedValidationInterface(txr);
@@ -330,7 +341,7 @@ FUZZ_TARGET_INIT(tx_pool, initialize_tx_pool)
const auto tx = MakeTransactionRef(mut_tx);
const bool bypass_limits = fuzzed_data_provider.ConsumeBool();
::fRequireStandard = fuzzed_data_provider.ConsumeBool();
- const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(tx_pool, chainstate, tx, GetTime(), bypass_limits, /* test_accept= */ false));
+ const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx, GetTime(), bypass_limits, /*test_accept=*/false));
const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
if (accepted) {
txids.push_back(tx->GetHash());