mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-01 03:01:09 +02:00
Merge bitcoin/bitcoin#22220: util: make ParseMoney return a std::optional<CAmount>
f7752adba5
util: check MoneyRange() inside ParseMoney() (fanquake)5ef2738089
util: make ParseMoney return a std::optional<CAmount> (fanquake) Pull request description: Related discussion in #22193. ACKs for top commit: MarcoFalke: review ACKf7752adba5
📄 Tree-SHA512: 88453f9e28f668deff4290d4bc0b2468cbd54699a3be1bfeac63a512276d309354672e7ea7deefa01466c3d9d826e837cc1ea244d4d74b4fa9c11c56f074e098
This commit is contained in:
@ -83,9 +83,8 @@ FUZZ_TARGET_INIT(integer, initialize_integer)
|
||||
(void)FormatISO8601Date(i64);
|
||||
(void)FormatISO8601DateTime(i64);
|
||||
{
|
||||
int64_t parsed_money;
|
||||
if (ParseMoney(FormatMoney(i64), parsed_money)) {
|
||||
assert(parsed_money == i64);
|
||||
if (std::optional<CAmount> parsed = ParseMoney(FormatMoney(i64))) {
|
||||
assert(parsed.value() == i64);
|
||||
}
|
||||
}
|
||||
(void)GetSizeOfCompactSize(u64);
|
||||
@ -126,9 +125,8 @@ FUZZ_TARGET_INIT(integer, initialize_integer)
|
||||
(void)ToLower(ch);
|
||||
(void)ToUpper(ch);
|
||||
{
|
||||
int64_t parsed_money;
|
||||
if (ParseMoney(ValueFromAmount(i64).getValStr(), parsed_money)) {
|
||||
assert(parsed_money == i64);
|
||||
if (std::optional<CAmount> parsed = ParseMoney(ValueFromAmount(i64).getValStr())) {
|
||||
assert(parsed.value() == i64);
|
||||
}
|
||||
}
|
||||
if (i32 >= 0 && i32 <= 16) {
|
||||
|
@ -12,8 +12,7 @@ FUZZ_TARGET(parse_numbers)
|
||||
{
|
||||
const std::string random_string(buffer.begin(), buffer.end());
|
||||
|
||||
CAmount amount;
|
||||
(void)ParseMoney(random_string, amount);
|
||||
(void)ParseMoney(random_string);
|
||||
|
||||
double d;
|
||||
(void)ParseDouble(random_string, &d);
|
||||
|
Reference in New Issue
Block a user