diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2020-04-07 15:40:13 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2020-04-08 14:45:27 +0000 |
commit | 44fb2a596b4a1aa70253c4145c35be6de68da22a (patch) | |
tree | 4aea1b48dbc6c2947636d4e2c029fcf615d5b3be /src/test | |
parent | 63dad673487d3623f9076721d2a1924263272eb9 (diff) | |
download | bitcoin-44fb2a596b4a1aa70253c4145c35be6de68da22a.tar.xz |
tests: Add fuzzing harness for FeeFilterRounder
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/fuzz/fees.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/fuzz/fees.cpp b/src/test/fuzz/fees.cpp new file mode 100644 index 0000000000..090994263e --- /dev/null +++ b/src/test/fuzz/fees.cpp @@ -0,0 +1,26 @@ +// Copyright (c) 2020 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 <amount.h> +#include <optional.h> +#include <policy/fees.h> +#include <test/fuzz/FuzzedDataProvider.h> +#include <test/fuzz/fuzz.h> +#include <test/fuzz/util.h> + +#include <cstdint> +#include <string> +#include <vector> + +void test_one_input(const std::vector<uint8_t>& buffer) +{ + FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); + const CFeeRate minimal_incremental_fee{ConsumeMoney(fuzzed_data_provider)}; + FeeFilterRounder fee_filter_rounder{minimal_incremental_fee}; + while (fuzzed_data_provider.ConsumeBool()) { + const CAmount current_minimum_fee = ConsumeMoney(fuzzed_data_provider); + const CAmount rounded_fee = fee_filter_rounder.round(current_minimum_fee); + assert(MoneyRange(rounded_fee)); + } +} |