aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz
diff options
context:
space:
mode:
authorglozow <gzhao408@berkeley.edu>2021-04-10 15:37:47 -0700
committerglozow <gzhao408@berkeley.edu>2021-05-24 14:42:10 +0100
commitc9e1a26d1f17c8b98632b7796ffa8f8788b5a83c (patch)
tree6dbb7b3fb1b4d5b9002eb7c4f06112c4185472a7 /src/test/fuzz
parent363e3d916cc036488783bb4bdcfdd3665aecf711 (diff)
downloadbitcoin-c9e1a26d1f17c8b98632b7796ffa8f8788b5a83c.tar.xz
[fuzz] add ProcessNewPackage call in tx_pool fuzzer
Diffstat (limited to 'src/test/fuzz')
-rw-r--r--src/test/fuzz/tx_pool.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/test/fuzz/tx_pool.cpp b/src/test/fuzz/tx_pool.cpp
index 068e207118..1d32a69aa2 100644
--- a/src/test/fuzz/tx_pool.cpp
+++ b/src/test/fuzz/tx_pool.cpp
@@ -218,6 +218,16 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
RegisterSharedValidationInterface(txr);
const bool bypass_limits = fuzzed_data_provider.ConsumeBool();
::fRequireStandard = fuzzed_data_provider.ConsumeBool();
+
+ // Make sure ProcessNewPackage on one transaction works and always fully validates the transaction.
+ // The result is not guaranteed to be the same as what is returned by ATMP.
+ const auto result_package = WITH_LOCK(::cs_main,
+ return ProcessNewPackage(node.chainman->ActiveChainstate(), tx_pool, {tx}, true));
+ auto it = result_package.m_tx_results.find(tx->GetWitnessHash());
+ Assert(it != result_package.m_tx_results.end());
+ 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(chainstate, tx_pool, tx, bypass_limits));
const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
SyncWithValidationInterfaceQueue();