| 83 | |
| 84 | template <typename T> |
| 85 | void 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 | |
| 107 | template <typename T> |
| 108 | void AssertEqualAfterSerializeDeserialize(const T& obj, const int version = INIT_PROTO_VERSION, const int ser_type = SER_NETWORK) |
no test coverage detected