Skip to content

Commit eb19a2d

Browse files
committed
Merge bitcoin/bitcoin#34017: fuzz: Add a test case for ParseByteUnits()
57b888c fuzz: Add a test case for `ParseByteUnits()` (Chandra Pratap) Pull request description: `ParseByteUnits()` is the only parsing function in `strencodings.cpp` lacking a fuzz test. Add a test case to check the function against arbitrary strings and randomized `default_multiplier`. ACKs for top commit: maflcko: lgtm ACK 57b888c dergoegge: utACK 57b888c marcofleon: crACK 57b888c Tree-SHA512: c16557442987437e5e0c9d9a8b016df93e513e34acb78242a1f73dabc4482632ec57eb35cb4c84f9a1ea838fa6bda2094f2a8b52ace431f8064a79fad96e9a52
2 parents e685172 + 57b888c commit eb19a2d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/test/fuzz/string.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,19 @@ FUZZ_TARGET(string)
147147
const bilingual_str bs2{random_string_2, random_string_1};
148148
(void)(bs1 + bs2);
149149
}
150+
{
151+
const ByteUnit all_units[] = {
152+
ByteUnit::NOOP,
153+
ByteUnit::k,
154+
ByteUnit::K,
155+
ByteUnit::m,
156+
ByteUnit::M,
157+
ByteUnit::g,
158+
ByteUnit::G,
159+
ByteUnit::t,
160+
ByteUnit::T
161+
};
162+
ByteUnit default_multiplier = fuzzed_data_provider.PickValueInArray(all_units);
163+
(void)ParseByteUnits(random_string_1, default_multiplier);
164+
}
150165
}

0 commit comments

Comments
 (0)