From 2bcc2bd742392730b4f21e3d4f00438c34acac1f Mon Sep 17 00:00:00 2001 From: practicalswift Date: Thu, 30 Apr 2020 14:19:27 +0000 Subject: tests: Clarify how we avoid hitting the signed integer overflow in CFeeRate::GetFeePerK() when fuzzing --- src/test/fuzz/util.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/test/fuzz/util.h') 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(100); + // + // Reproduce using CFeeRate(348732081484775, 10).GetFeePerK() + const CAmount fee = std::min(ConsumeMoney(fuzzed_data_provider), std::numeric_limits::max() / static_cast(100000)); + assert(MoneyRange(fee)); const int64_t time = fuzzed_data_provider.ConsumeIntegral(); const unsigned int entry_height = fuzzed_data_provider.ConsumeIntegral(); const bool spends_coinbase = fuzzed_data_provider.ConsumeBool(); -- cgit v1.2.3