26 static const auto testing_setup = MakeNoLogFileContext<>();
37 uint32_t current_height{0};
38 const auto advance_height{
47 const std::optional<CMutableTransaction> mtx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider, TX_WITH_WITNESS); 52 const CTransaction tx{*mtx}; 53 const auto entry{ConsumeTxMemPoolEntry(fuzzed_data_provider, tx, current_height)}; 54 const auto tx_submitted_in_package = fuzzed_data_provider.ConsumeBool(); 55 const auto tx_has_mempool_parents = fuzzed_data_provider.ConsumeBool(); 56 const auto tx_info = NewMempoolTransactionInfo(entry.GetSharedTx(), entry.GetFee(), 57 entry.GetTxSize(), entry.GetHeight(), 58 /*mempool_limit_bypassed=*/false, 59 tx_submitted_in_package, 60 /*chainstate_is_current=*/true, 61 tx_has_mempool_parents); 62 block_policy_estimator.processTransaction(tx_info); 63 if (fuzzed_data_provider.ConsumeBool()) { 64 (void)block_policy_estimator.removeTx(tx.GetHash()); 68 std::list<CTxMemPoolEntry> mempool_entries; 69 LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) 71 const std::optional<CMutableTransaction> mtx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider, TX_WITH_WITNESS); 76 const CTransaction tx{*mtx}; 77 mempool_entries.push_back(ConsumeTxMemPoolEntry(fuzzed_data_provider, tx, current_height)); 79 std::vector<RemovedMempoolTransactionInfo> txs; 80 txs.reserve(mempool_entries.size()); 81 for (const CTxMemPoolEntry& mempool_entry : mempool_entries) { 82 txs.emplace_back(mempool_entry); 85 block_policy_estimator.processBlock(txs, current_height); 88 (void)block_policy_estimator.removeTx(Txid::FromUint256(ConsumeUInt256(fuzzed_data_provider))); 91 block_policy_estimator.FlushUnconfirmed(); 93 (void)block_policy_estimator.estimateFee(fuzzed_data_provider.ConsumeIntegral<int>()); 94 EstimationResult result; 95 auto conf_target = fuzzed_data_provider.ConsumeIntegral<int>(); 96 auto success_threshold = fuzzed_data_provider.ConsumeFloatingPoint<double>(); 97 auto horizon = fuzzed_data_provider.PickValueInArray(ALL_FEE_ESTIMATE_HORIZONS); 98 auto* result_ptr = fuzzed_data_provider.ConsumeBool() ? &result : nullptr; 99 (void)block_policy_estimator.estimateRawFee(conf_target, success_threshold, horizon, result_ptr); 101 FeeCalculation fee_calculation; 102 conf_target = fuzzed_data_provider.ConsumeIntegral<int>(); 103 auto* fee_calc_ptr = fuzzed_data_provider.ConsumeBool() ? &fee_calculation : nullptr; 104 auto conservative = fuzzed_data_provider.ConsumeBool(); 105 (void)block_policy_estimator.estimateSmartFee(conf_target, fee_calc_ptr, conservative); 107 (void)block_policy_estimator.HighestTargetTracked(fuzzed_data_provider.PickValueInArray(ALL_FEE_ESTIMATE_HORIZONS)); 110 FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider}; 111 AutoFile fuzzed_auto_file{fuzzed_file_provider.open()}; 112 block_policy_estimator.Write(fuzzed_auto_file); 113 block_policy_estimator.Read(fuzzed_auto_file); 114 (void)fuzzed_auto_file.fclose();
FUZZ_TARGET(policy_estimator,.init=initialize_policy_estimator)
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
const TestingSetup * g_setup
The BlockPolicyEstimator is used for estimating the feerate needed for a transaction to be included i...
FuzzedDataProvider & fuzzed_data_provider
fs::path FeeestPath(const ArgsManager &argsman)
T ConsumeIntegralInRange(T min, T max)
static constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES
void initialize_policy_estimator()