Skip to content

Commit 99993f0

Browse files
author
MarcoFalke
committed
fuzz: Avoid excessively large min fee rate in tx_pool
1 parent 5925f1e commit 99993f0

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/test/fuzz/tx_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, CCh
8484
{
8585
BlockAssembler::Options options;
8686
options.nBlockMaxWeight = fuzzed_data_provider.ConsumeIntegralInRange(0U, MAX_BLOCK_WEIGHT);
87-
options.blockMinFeeRate = CFeeRate{ConsumeMoney(fuzzed_data_provider)};
87+
options.blockMinFeeRate = CFeeRate{ConsumeMoney(fuzzed_data_provider, /* max */ COIN)};
8888
auto assembler = BlockAssembler{chainstate, *static_cast<CTxMemPool*>(&tx_pool), ::Params(), options};
8989
auto block_template = assembler.CreateNewBlock(CScript{} << OP_TRUE);
9090
Assert(block_template->block.vtx.size() >= 1);

src/test/fuzz/util.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ void FillNode(FuzzedDataProvider& fuzzed_data_provider, CNode& node, bool init_v
217217
}
218218
}
219219

220+
CAmount ConsumeMoney(FuzzedDataProvider& fuzzed_data_provider, const std::optional<CAmount>& max) noexcept
221+
{
222+
return fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(0, max.value_or(MAX_MONEY));
223+
}
224+
220225
int64_t ConsumeTime(FuzzedDataProvider& fuzzed_data_provider, const std::optional<int64_t>& min, const std::optional<int64_t>& max) noexcept
221226
{
222227
// Avoid t=0 (1970-01-01T00:00:00Z) since SetMockTime(0) disables mocktime.

src/test/fuzz/util.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,7 @@ template <typename WeakEnumType, size_t size>
123123
return static_cast<opcodetype>(fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(0, MAX_OPCODE));
124124
}
125125

126-
[[nodiscard]] inline CAmount ConsumeMoney(FuzzedDataProvider& fuzzed_data_provider) noexcept
127-
{
128-
return fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(0, MAX_MONEY);
129-
}
126+
[[nodiscard]] CAmount ConsumeMoney(FuzzedDataProvider& fuzzed_data_provider, const std::optional<CAmount>& max = std::nullopt) noexcept;
130127

131128
[[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;
132129

0 commit comments

Comments
 (0)