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

Function DeserializeFromFuzzingInput

src/test/fuzz/deserialize.cpp:85–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83
84template <typename T>
85void DeserializeFromFuzzingInput(FuzzBufferType buffer, T& obj, const std::optional<int> protocol_version = std::nullopt, const int ser_type = SER_NETWORK)
86{
87 CDataStream ds(buffer, ser_type, INIT_PROTO_VERSION);
88 if (protocol_version) {
89 ds.SetVersion(*protocol_version);
90 } else {
91 try {
92 int version;
93 ds >> version;
94 ds.SetVersion(version);
95 } catch (const std::ios_base::failure&) {
96 throw invalid_fuzzing_input_exception();
97 }
98 }
99 try {
100 ds >> obj;
101 } catch (const std::ios_base::failure&) {
102 throw invalid_fuzzing_input_exception();
103 }
104 assert(buffer.empty() || !Serialize(obj).empty());
105}
106
107template <typename T>
108void AssertEqualAfterSerializeDeserialize(const T& obj, const int version = INIT_PROTO_VERSION, const int ser_type = SER_NETWORK)

Callers 1

deserialize.cppFile · 0.85

Calls 4

SerializeFunction · 0.70
SetVersionMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected