mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-20 10:58:09 +01:00
It is part of the node library. Also, it won't be moved to the kernel lib, as it will be pruned of ArgsManager. -BEGIN VERIFY SCRIPT- # Move module git mv src/mempool_args.cpp src/node/ git mv src/mempool_args.h src/node/ # Replacements sed -i 's:mempool_args\.h:node/mempool_args.h:g' $(git grep -l mempool_args) sed -i 's:mempool_args\.cpp:node/mempool_args.cpp:g' $(git grep -l mempool_args) sed -i 's:MEMPOOL_ARGS_H:NODE_MEMPOOL_ARGS_H:g' $(git grep -l MEMPOOL_ARGS_H) -END VERIFY SCRIPT-
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
// Copyright (c) 2020-2021 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 <node/mempool_args.h>
|
|
#include <policy/rbf.h>
|
|
#include <primitives/transaction.h>
|
|
#include <sync.h>
|
|
#include <test/fuzz/FuzzedDataProvider.h>
|
|
#include <test/fuzz/fuzz.h>
|
|
#include <test/fuzz/util.h>
|
|
#include <test/util/setup_common.h>
|
|
#include <txmempool.h>
|
|
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace {
|
|
const BasicTestingSetup* g_setup;
|
|
} // namespace
|
|
|
|
void initialize_rbf()
|
|
{
|
|
static const auto testing_setup = MakeNoLogFileContext<>();
|
|
g_setup = testing_setup.get();
|
|
}
|
|
|
|
FUZZ_TARGET_INIT(rbf, initialize_rbf)
|
|
{
|
|
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
|
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
|
std::optional<CMutableTransaction> mtx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
|
|
if (!mtx) {
|
|
return;
|
|
}
|
|
|
|
CTxMemPool pool{MemPoolOptionsForTest(g_setup->m_node)};
|
|
|
|
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000)
|
|
{
|
|
const std::optional<CMutableTransaction> another_mtx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
|
|
if (!another_mtx) {
|
|
break;
|
|
}
|
|
const CTransaction another_tx{*another_mtx};
|
|
if (fuzzed_data_provider.ConsumeBool() && !mtx->vin.empty()) {
|
|
mtx->vin[0].prevout = COutPoint{another_tx.GetHash(), 0};
|
|
}
|
|
LOCK2(cs_main, pool.cs);
|
|
pool.addUnchecked(ConsumeTxMemPoolEntry(fuzzed_data_provider, another_tx));
|
|
}
|
|
const CTransaction tx{*mtx};
|
|
if (fuzzed_data_provider.ConsumeBool()) {
|
|
LOCK2(cs_main, pool.cs);
|
|
pool.addUnchecked(ConsumeTxMemPoolEntry(fuzzed_data_provider, tx));
|
|
}
|
|
{
|
|
LOCK(pool.cs);
|
|
(void)IsRBFOptIn(tx, pool);
|
|
}
|
|
}
|