mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
test: add small signet fuzzer
This commit is contained in:
parent
ec9b25d046
commit
4c189abdc4
@ -134,6 +134,7 @@ FUZZ_TARGETS = \
|
|||||||
test/fuzz/scriptnum_ops \
|
test/fuzz/scriptnum_ops \
|
||||||
test/fuzz/service_deserialize \
|
test/fuzz/service_deserialize \
|
||||||
test/fuzz/signature_checker \
|
test/fuzz/signature_checker \
|
||||||
|
test/fuzz/signet \
|
||||||
test/fuzz/snapshotmetadata_deserialize \
|
test/fuzz/snapshotmetadata_deserialize \
|
||||||
test/fuzz/span \
|
test/fuzz/span \
|
||||||
test/fuzz/spanparsing \
|
test/fuzz/spanparsing \
|
||||||
@ -1106,6 +1107,12 @@ test_fuzz_signature_checker_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
|||||||
test_fuzz_signature_checker_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
test_fuzz_signature_checker_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||||
test_fuzz_signature_checker_SOURCES = test/fuzz/signature_checker.cpp
|
test_fuzz_signature_checker_SOURCES = test/fuzz/signature_checker.cpp
|
||||||
|
|
||||||
|
test_fuzz_signet_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
|
||||||
|
test_fuzz_signet_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||||
|
test_fuzz_signet_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
||||||
|
test_fuzz_signet_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||||
|
test_fuzz_signet_SOURCES = test/fuzz/signet.cpp
|
||||||
|
|
||||||
test_fuzz_snapshotmetadata_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DSNAPSHOTMETADATA_DESERIALIZE=1
|
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_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||||
test_fuzz_snapshotmetadata_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
test_fuzz_snapshotmetadata_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
||||||
|
34
src/test/fuzz/signet.cpp
Normal file
34
src/test/fuzz/signet.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (c) 2020 The Bitcoin Core developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#include <chainparams.h>
|
||||||
|
#include <consensus/validation.h>
|
||||||
|
#include <primitives/block.h>
|
||||||
|
#include <signet.h>
|
||||||
|
#include <streams.h>
|
||||||
|
#include <test/fuzz/fuzz.h>
|
||||||
|
#include <test/fuzz/FuzzedDataProvider.h>
|
||||||
|
#include <test/fuzz/util.h>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <optional>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
void initialize()
|
||||||
|
{
|
||||||
|
InitializeFuzzingContext(CBaseChainParams::SIGNET);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_one_input(const std::vector<uint8_t>& buffer)
|
||||||
|
{
|
||||||
|
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
||||||
|
const std::optional<CBlock> block = ConsumeDeserializable<CBlock>(fuzzed_data_provider);
|
||||||
|
if (!block) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(void)CheckSignetBlockSolution(*block, Params().GetConsensus());
|
||||||
|
if (GetWitnessCommitmentIndex(*block) != NO_WITNESS_COMMITMENT) {
|
||||||
|
(void)SignetTxs(*block, ConsumeScript(fuzzed_data_provider));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user