Skip to content

Commit

Permalink
[fuzz] add ProcessNewPackage call in tx_pool fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
glozow committed May 24, 2021
1 parent 363e3d9 commit c9e1a26
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/test/fuzz/tx_pool.cpp
Expand Up @@ -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();
Expand Down

0 comments on commit c9e1a26

Please sign in to comment.