mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
tests: Add deserialization fuzzing of SnapshotMetadata (utxo_snapshot), uint160 and uint256
This commit is contained in:
parent
b5c7665e30
commit
7b169cae20
@ -64,6 +64,7 @@ FUZZ_TARGETS = \
|
||||
test/fuzz/script_ops \
|
||||
test/fuzz/scriptnum_ops \
|
||||
test/fuzz/service_deserialize \
|
||||
test/fuzz/snapshotmetadata_deserialize \
|
||||
test/fuzz/spanparsing \
|
||||
test/fuzz/strprintf \
|
||||
test/fuzz/sub_net_deserialize \
|
||||
@ -72,7 +73,9 @@ FUZZ_TARGETS = \
|
||||
test/fuzz/tx_in_deserialize \
|
||||
test/fuzz/tx_out \
|
||||
test/fuzz/txoutcompressor_deserialize \
|
||||
test/fuzz/txundo_deserialize
|
||||
test/fuzz/txundo_deserialize \
|
||||
test/fuzz/uint160_deserialize \
|
||||
test/fuzz/uint256_deserialize
|
||||
|
||||
if ENABLE_FUZZ
|
||||
noinst_PROGRAMS += $(FUZZ_TARGETS:=)
|
||||
@ -628,6 +631,12 @@ test_fuzz_sub_net_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
||||
test_fuzz_sub_net_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
test_fuzz_sub_net_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
|
||||
|
||||
test_fuzz_snapshotmetadata_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DSNAPSHOTMETADATA_DESERIALIZE=1
|
||||
test_fuzz_snapshotmetadata_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
test_fuzz_snapshotmetadata_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
||||
test_fuzz_snapshotmetadata_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
test_fuzz_snapshotmetadata_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
|
||||
|
||||
test_fuzz_transaction_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
|
||||
test_fuzz_transaction_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
test_fuzz_transaction_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
||||
@ -664,6 +673,18 @@ test_fuzz_txundo_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
||||
test_fuzz_txundo_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
test_fuzz_txundo_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
|
||||
|
||||
test_fuzz_uint160_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DUINT160_DESERIALIZE=1
|
||||
test_fuzz_uint160_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
test_fuzz_uint160_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
||||
test_fuzz_uint160_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
test_fuzz_uint160_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
|
||||
|
||||
test_fuzz_uint256_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DUINT256_DESERIALIZE=1
|
||||
test_fuzz_uint256_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
test_fuzz_uint256_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
||||
test_fuzz_uint256_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
test_fuzz_uint256_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
|
||||
|
||||
endif # ENABLE_FUZZ
|
||||
|
||||
nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES)
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <key.h>
|
||||
#include <merkleblock.h>
|
||||
#include <net.h>
|
||||
#include <node/utxo_snapshot.h>
|
||||
#include <primitives/block.h>
|
||||
#include <protocol.h>
|
||||
#include <psbt.h>
|
||||
@ -214,9 +215,24 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
||||
#elif BLOCKTRANSACTIONSREQUEST_DESERIALIZE
|
||||
BlockTransactionsRequest btr;
|
||||
DeserializeFromFuzzingInput(buffer, btr);
|
||||
#elif SNAPSHOTMETADATA_DESERIALIZE
|
||||
SnapshotMetadata snapshot_metadata;
|
||||
DeserializeFromFuzzingInput(buffer, snapshot_metadata);
|
||||
#elif UINT160_DESERIALIZE
|
||||
uint160 u160;
|
||||
DeserializeFromFuzzingInput(buffer, u160);
|
||||
AssertEqualAfterSerializeDeserialize(u160);
|
||||
#elif UINT256_DESERIALIZE
|
||||
uint256 u256;
|
||||
DeserializeFromFuzzingInput(buffer, u256);
|
||||
AssertEqualAfterSerializeDeserialize(u256);
|
||||
#else
|
||||
#error Need at least one fuzz target to compile
|
||||
#endif
|
||||
// Classes intentionally not covered in this file since their deserialization code is
|
||||
// fuzzed elsewhere:
|
||||
// * Deserialization of CTxOut is fuzzed in test/fuzz/tx_out.cpp
|
||||
// * Deserialization of CMutableTransaction is fuzzed in src/test/fuzz/transaction.cpp
|
||||
} catch (const invalid_fuzzing_input_exception&) {
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user