9 #include <blockfilter.h>
46 static const auto testing_setup = MakeNoLogFileContext<>();
47 g_setup = testing_setup.get();
50 #define FUZZ_TARGET_DESERIALIZE(name, code) \
51 FUZZ_TARGET(name, .init = initialize_deserialize) \
55 } catch (const invalid_fuzzing_input_exception&) { \
61 struct invalid_fuzzing_input_exception :
public std::exception {
64 template <
typename T,
typename P>
72 template <
typename T,
typename P>
80 template <
typename T,
typename P>
81 void DeserializeFromFuzzingInput(
FuzzBufferType buffer,
T&& obj,
const P& params)
86 }
catch (
const std::ios_base::failure&) {
87 throw invalid_fuzzing_input_exception();
100 template <
typename T>
108 template <
typename T>
114 }
catch (
const std::ios_base::failure&) {
115 throw invalid_fuzzing_input_exception();
120 template <
typename T,
typename P>
121 void AssertEqualAfterSerializeDeserialize(
const T& obj,
const P& params)
125 template <
typename T>
126 void AssertEqualAfterSerializeDeserialize(
const T& obj)
135 DeserializeFromFuzzingInput(buffer, block_filter);
140 (void)ConsumeDeserializable<AddrInfo>(fdp, ConsumeDeserializationParams<CAddress::SerParams>(fdp));
144 DeserializeFromFuzzingInput(buffer, block_file_info);
148 DeserializeFromFuzzingInput(buffer, block_header_and_short_txids);
152 DeserializeFromFuzzingInput(buffer, fee_rate);
153 AssertEqualAfterSerializeDeserialize(fee_rate);
157 DeserializeFromFuzzingInput(buffer, merkle_block);
161 DeserializeFromFuzzingInput(buffer, out_point);
162 AssertEqualAfterSerializeDeserialize(out_point);
166 DeserializeFromFuzzingInput(buffer, partial_merkle_tree);
170 DeserializeFromFuzzingInput(buffer, pub_key);
171 AssertEqualAfterSerializeDeserialize(pub_key);
175 DeserializeFromFuzzingInput(buffer, script);
179 DeserializeFromFuzzingInput(buffer, tx_in);
180 AssertEqualAfterSerializeDeserialize(tx_in);
184 DeserializeFromFuzzingInput(buffer, flat_file_pos);
185 AssertEqualAfterSerializeDeserialize(flat_file_pos);
189 DeserializeFromFuzzingInput(buffer, key_origin_info);
190 AssertEqualAfterSerializeDeserialize(key_origin_info);
194 DeserializeFromFuzzingInput(buffer, partially_signed_transaction);
198 DeserializeFromFuzzingInput(buffer, prefilled_transaction);
202 DeserializeFromFuzzingInput(buffer, psbt_input);
206 DeserializeFromFuzzingInput(buffer, psbt_output);
214 DeserializeFromFuzzingInput(buffer, bl);
224 DeserializeFromFuzzingInput(buffer, bh);
228 DeserializeFromFuzzingInput(buffer, tu);
232 DeserializeFromFuzzingInput(buffer, bu);
236 DeserializeFromFuzzingInput(buffer, coin);
241 const auto maybe_na{ConsumeDeserializable<CNetAddr>(fdp, ConsumeDeserializationParams<CNetAddr::SerParams>(fdp))};
242 if (!maybe_na)
return;
244 if (na.IsAddrV1Compatible()) {
252 const auto ser_params{ConsumeDeserializationParams<CNetAddr::SerParams>(fdp)};
253 const auto maybe_s{ConsumeDeserializable<CService>(fdp, ser_params)};
254 if (!maybe_s)
return;
256 if (s.IsAddrV1Compatible()) {
261 assert(s.IsAddrV1Compatible());
266 DeserializeFromFuzzingInput(buffer, mh);
272 const auto ser_enc{ConsumeDeserializationParams<CAddress::SerParams>(fdp)};
273 const auto maybe_a{ConsumeDeserializable<CAddress>(fdp, ser_enc)};
274 if (!maybe_a)
return;
286 if (a.IsAddrV1Compatible()) {
296 DeserializeFromFuzzingInput(buffer, i);
300 DeserializeFromFuzzingInput(buffer, bf);
304 DeserializeFromFuzzingInput(buffer, dbi);
308 auto toc = Using<TxOutCompression>(to);
309 DeserializeFromFuzzingInput(buffer, toc);
313 DeserializeFromFuzzingInput(buffer, bt);
317 DeserializeFromFuzzingInput(buffer, btr);
321 DeserializeFromFuzzingInput(buffer, snapshot_metadata);
325 DeserializeFromFuzzingInput(buffer, u160);
326 AssertEqualAfterSerializeDeserialize(u160);
330 DeserializeFromFuzzingInput(buffer, u256);
331 AssertEqualAfterSerializeDeserialize(u256);
Complete block filter struct as defined in BIP 157.
A CService with information about it as peer.
static constexpr SerParams V1_NETWORK
static constexpr SerParams V2_NETWORK
static constexpr SerParams V1_DISK
static constexpr SerParams V2_DISK
Undo information for a CBlock.
BloomFilter is a probabilistic filter which SPV clients provide so that we can filter the transaction...
Used to marshal pointers into hashes for db storage.
Fee rate in satoshis per kilovirtualbyte: CAmount / kvB.
Used to relay blocks as header + vector<merkle branch> to filtered nodes.
static constexpr SerParams V1
static constexpr SerParams V2
An outpoint - a combination of a transaction hash and an index n into its vout.
Data structure that represents a partial merkle tree.
An encapsulated public key.
Serialized script, used inside transaction inputs and outputs.
A combination of a network address (CNetAddr) and a (TCP) port.
An input of a transaction.
An output of a transaction.
Undo information for a CTransaction.
Double ended buffer combining vector and stream-like interfaces.
A Span is an object that can refer to a contiguous sequence of objects.
constexpr bool empty() const noexcept
#define FUZZ_TARGET_DESERIALIZE(name, code)
void initialize_deserialize()
#define T(expected, seed, data)
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
static constexpr TransactionSerParams TX_WITH_WITNESS
void Serialize(Stream &, V)=delete
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
A structure for PSBTs which contains per output information.
A version of CTransaction with the PSBT format.