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

Function FUZZ_TARGET_INIT

src/test/fuzz/script.cpp:41–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41FUZZ_TARGET_INIT(script, initialize_script)
42{
43 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
44 const CScript script{ConsumeScript(fuzzed_data_provider)};
45
46 CompressedScript compressed;
47 if (CompressScript(script, compressed)) {
48 const unsigned int size = compressed[0];
49 compressed.erase(compressed.begin());
50 assert(size <= 5);
51 CScript decompressed_script;
52 const bool ok = DecompressScript(decompressed_script, size, compressed);
53 assert(ok);
54 assert(script == decompressed_script);
55 }
56
57 TxoutType which_type;
58 bool is_standard_ret = IsStandard(script, which_type);
59 if (!is_standard_ret) {
60 assert(which_type == TxoutType::NONSTANDARD ||
61 which_type == TxoutType::NULL_DATA ||
62 which_type == TxoutType::MULTISIG);
63 }
64 if (which_type == TxoutType::NONSTANDARD) {
65 assert(!is_standard_ret);
66 }
67 if (which_type == TxoutType::NULL_DATA) {
68 assert(script.IsUnspendable());
69 }
70 if (script.IsUnspendable()) {
71 assert(which_type == TxoutType::NULL_DATA ||
72 which_type == TxoutType::NONSTANDARD);
73 }
74
75 CTxDestination address;
76 bool extract_destination_ret = ExtractDestination(script, address);
77 if (!extract_destination_ret) {
78 assert(which_type == TxoutType::PUBKEY ||
79 which_type == TxoutType::NONSTANDARD ||
80 which_type == TxoutType::NULL_DATA ||
81 which_type == TxoutType::MULTISIG);
82 }
83 if (which_type == TxoutType::NONSTANDARD ||
84 which_type == TxoutType::NULL_DATA ||
85 which_type == TxoutType::MULTISIG) {
86 assert(!extract_destination_ret);
87 }
88
89 const FlatSigningProvider signing_provider;
90 (void)InferDescriptor(script, signing_provider);
91 (void)IsSegWitOutput(signing_provider, script);
92 (void)IsSolvable(signing_provider, script);
93
94 (void)RecursiveDynamicUsage(script);
95
96 std::vector<std::vector<unsigned char>> solutions;
97 (void)Solver(script, solutions);
98

Callers

nothing calls this directly

Calls 15

ConsumeScriptFunction · 0.85
CompressScriptFunction · 0.85
DecompressScriptFunction · 0.85
IsStandardFunction · 0.85
ExtractDestinationFunction · 0.85
InferDescriptorFunction · 0.85
IsSegWitOutputFunction · 0.85
IsSolvableFunction · 0.85
RecursiveDynamicUsageFunction · 0.85
SolverFunction · 0.85

Tested by

no test coverage detected