MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / FUZZ_TARGET

Function FUZZ_TARGET

src/test/fuzz/base_encode_decode.cpp:21–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19using util::TrimStringView;
20
21FUZZ_TARGET(base58_encode_decode)
22{
23 FuzzedDataProvider provider{buffer.data(), buffer.size()};
24 const auto random_string{provider.ConsumeRandomLengthString(100)};
25
26 const auto encoded{EncodeBase58(MakeUCharSpan(random_string))};
27 const auto decode_input{provider.ConsumeBool() ? random_string : encoded};
28 const int max_ret_len{provider.ConsumeIntegralInRange<int>(-1, decode_input.size() + 1)};
29 if (std::vector<unsigned char> decoded; DecodeBase58(decode_input, decoded, max_ret_len)) {
30 const auto encoded_string{EncodeBase58(decoded)};
31 assert(encoded_string == TrimStringView(decode_input));
32 if (decoded.size() > 0) {
33 assert(max_ret_len > 0);
34 assert(decoded.size() <= static_cast<size_t>(max_ret_len));
35 assert(!DecodeBase58(encoded_string, decoded, provider.ConsumeIntegralInRange<int>(0, decoded.size() - 1)));
36 }
37 }
38}
39
40FUZZ_TARGET(base58check_encode_decode)
41{

Callers

nothing calls this directly

Calls 15

EncodeBase58Function · 0.85
MakeUCharSpanFunction · 0.85
DecodeBase58Function · 0.85
TrimStringViewFunction · 0.85
EncodeBase58CheckFunction · 0.85
DecodeBase58CheckFunction · 0.85
DecodeBase32Function · 0.85
EncodeBase32Function · 0.85
DecodeBase64Function · 0.85
DecodeBase64PSBTFunction · 0.85
ConsumeBoolMethod · 0.80

Tested by

no test coverage detected