MCPcopy Create free account
hub / github.com/ElementsProject/elements / FUZZ_TARGET_INIT

Function FUZZ_TARGET_INIT

src/test/fuzz/base_encode_decode.cpp:22–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22FUZZ_TARGET_INIT(base_encode_decode, initialize_base_encode_decode)
23{
24 const std::string random_encoded_string(buffer.begin(), buffer.end());
25
26 std::vector<unsigned char> decoded;
27 if (DecodeBase58(random_encoded_string, decoded, 100)) {
28 const std::string encoded_string = EncodeBase58(decoded);
29 assert(encoded_string == TrimString(encoded_string));
30 assert(ToLower(encoded_string) == ToLower(TrimString(random_encoded_string)));
31 }
32
33 if (DecodeBase58Check(random_encoded_string, decoded, 100)) {
34 const std::string encoded_string = EncodeBase58Check(decoded);
35 assert(encoded_string == TrimString(encoded_string));
36 assert(ToLower(encoded_string) == ToLower(TrimString(random_encoded_string)));
37 }
38
39 bool pf_invalid;
40 std::string decoded_string = DecodeBase32(random_encoded_string, &pf_invalid);
41 if (!pf_invalid) {
42 const std::string encoded_string = EncodeBase32(decoded_string);
43 assert(encoded_string == TrimString(encoded_string));
44 assert(ToLower(encoded_string) == ToLower(TrimString(random_encoded_string)));
45 }
46
47 decoded_string = DecodeBase64(random_encoded_string, &pf_invalid);
48 if (!pf_invalid) {
49 const std::string encoded_string = EncodeBase64(decoded_string);
50 assert(encoded_string == TrimString(encoded_string));
51 assert(ToLower(encoded_string) == ToLower(TrimString(random_encoded_string)));
52 }
53
54 PartiallySignedTransaction psbt;
55 std::string error;
56 (void)DecodeBase64PSBT(psbt, random_encoded_string, error);
57}

Callers

nothing calls this directly

Calls 13

DecodeBase58Function · 0.85
EncodeBase58Function · 0.85
TrimStringFunction · 0.85
DecodeBase58CheckFunction · 0.85
EncodeBase58CheckFunction · 0.85
DecodeBase32Function · 0.85
EncodeBase32Function · 0.85
DecodeBase64Function · 0.85
DecodeBase64PSBTFunction · 0.85
ToLowerFunction · 0.50
EncodeBase64Function · 0.50
beginMethod · 0.45

Tested by

no test coverage detected