Skip to content

Commit c9e1a26

Browse files
committed
[fuzz] add ProcessNewPackage call in tx_pool fuzzer
1 parent 363e3d9 commit c9e1a26

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/test/fuzz/tx_pool.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
218218
RegisterSharedValidationInterface(txr);
219219
const bool bypass_limits = fuzzed_data_provider.ConsumeBool();
220220
::fRequireStandard = fuzzed_data_provider.ConsumeBool();
221+
222+
// Make sure ProcessNewPackage on one transaction works and always fully validates the transaction.
223+
// The result is not guaranteed to be the same as what is returned by ATMP.
224+
const auto result_package = WITH_LOCK(::cs_main,
225+
return ProcessNewPackage(node.chainman->ActiveChainstate(), tx_pool, {tx}, true));
226+
auto it = result_package.m_tx_results.find(tx->GetWitnessHash());
227+
Assert(it != result_package.m_tx_results.end());
228+
Assert(it->second.m_result_type == MempoolAcceptResult::ResultType::VALID ||
229+
it->second.m_result_type == MempoolAcceptResult::ResultType::INVALID);
230+
221231
const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx_pool, tx, bypass_limits));
222232
const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
223233
SyncWithValidationInterfaceQueue();

0 commit comments

Comments
 (0)