| 19 | using util::TrimStringView; |
| 20 | |
| 21 | FUZZ_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 | |
| 40 | FUZZ_TARGET(base58check_encode_decode) |
| 41 | { |
nothing calls this directly
no test coverage detected