diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-05-09 10:59:16 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-05-09 10:53:24 +0200 |
commit | 99993f066405863c66ccaec0a8427129f4515768 (patch) | |
tree | 844c20b28b9cade6c5438217a3ba93c0ecb427c9 /src | |
parent | 5925f1e652768a9502831b9ccf78d16cf3c37d29 (diff) | |
download | bitcoin-99993f066405863c66ccaec0a8427129f4515768.tar.xz |
fuzz: Avoid excessively large min fee rate in tx_pool
Diffstat (limited to 'src')
-rw-r--r-- | src/test/fuzz/tx_pool.cpp | 2 | ||||
-rw-r--r-- | src/test/fuzz/util.cpp | 5 | ||||
-rw-r--r-- | src/test/fuzz/util.h | 5 |
3 files changed, 7 insertions, 5 deletions
diff --git a/src/test/fuzz/tx_pool.cpp b/src/test/fuzz/tx_pool.cpp index 59229987ba..068e207118 100644 --- a/src/test/fuzz/tx_pool.cpp +++ b/src/test/fuzz/tx_pool.cpp @@ -84,7 +84,7 @@ void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, CCh { BlockAssembler::Options options; options.nBlockMaxWeight = fuzzed_data_provider.ConsumeIntegralInRange(0U, MAX_BLOCK_WEIGHT); - options.blockMinFeeRate = CFeeRate{ConsumeMoney(fuzzed_data_provider)}; + options.blockMinFeeRate = CFeeRate{ConsumeMoney(fuzzed_data_provider, /* max */ COIN)}; auto assembler = BlockAssembler{chainstate, *static_cast<CTxMemPool*>(&tx_pool), ::Params(), options}; auto block_template = assembler.CreateNewBlock(CScript{} << OP_TRUE); Assert(block_template->block.vtx.size() >= 1); diff --git a/src/test/fuzz/util.cpp b/src/test/fuzz/util.cpp index 574b694d1a..bcf0b0ce72 100644 --- a/src/test/fuzz/util.cpp +++ b/src/test/fuzz/util.cpp @@ -217,6 +217,11 @@ void FillNode(FuzzedDataProvider& fuzzed_data_provider, CNode& node, bool init_v } } +CAmount ConsumeMoney(FuzzedDataProvider& fuzzed_data_provider, const std::optional<CAmount>& max) noexcept +{ + return fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(0, max.value_or(MAX_MONEY)); +} + int64_t ConsumeTime(FuzzedDataProvider& fuzzed_data_provider, const std::optional<int64_t>& min, const std::optional<int64_t>& max) noexcept { // Avoid t=0 (1970-01-01T00:00:00Z) since SetMockTime(0) disables mocktime. diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index 1a83f7a57a..48b7877896 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -123,10 +123,7 @@ template <typename WeakEnumType, size_t size> return static_cast<opcodetype>(fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(0, MAX_OPCODE)); } -[[nodiscard]] inline CAmount ConsumeMoney(FuzzedDataProvider& fuzzed_data_provider) noexcept -{ - return fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(0, MAX_MONEY); -} +[[nodiscard]] CAmount ConsumeMoney(FuzzedDataProvider& fuzzed_data_provider, const std::optional<CAmount>& max = std::nullopt) noexcept; [[nodiscard]] int64_t ConsumeTime(FuzzedDataProvider& fuzzed_data_provider, const std::optional<int64_t>& min = std::nullopt, const std::optional<int64_t>& max = std::nullopt) noexcept; |