aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2020-04-30 14:19:27 +0000
committerpracticalswift <practicalswift@users.noreply.github.com>2020-04-30 14:19:49 +0000
commit2bcc2bd742392730b4f21e3d4f00438c34acac1f (patch)
tree3766d615cd7144a22ffe868ed7a1ccc4a586bb44 /src
parent13c1f6b24fa5e53f100d90d36b47b7dd3bc91b9f (diff)
tests: Clarify how we avoid hitting the signed integer overflow in CFeeRate::GetFeePerK() when fuzzing
Diffstat (limited to 'src')
-rw-r--r--src/test/fuzz/util.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h
index 98fe30fcec..501bb1de5a 100644
--- a/src/test/fuzz/util.h
+++ b/src/test/fuzz/util.h
@@ -104,7 +104,10 @@ NODISCARD inline CTxMemPoolEntry ConsumeTxMemPoolEntry(FuzzedDataProvider& fuzze
{
// Avoid:
// policy/feerate.cpp:28:34: runtime error: signed integer overflow: 34873208148477500 * 1000 cannot be represented in type 'long'
- const CAmount fee = ConsumeMoney(fuzzed_data_provider) / static_cast<CAmount>(100);
+ //
+ // Reproduce using CFeeRate(348732081484775, 10).GetFeePerK()
+ const CAmount fee = std::min<CAmount>(ConsumeMoney(fuzzed_data_provider), std::numeric_limits<CAmount>::max() / static_cast<CAmount>(100000));
+ assert(MoneyRange(fee));
const int64_t time = fuzzed_data_provider.ConsumeIntegral<int64_t>();
const unsigned int entry_height = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
const bool spends_coinbase = fuzzed_data_provider.ConsumeBool();