mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-02 16:53:23 +02:00
tests: Add fuzzing harness for various CTxIn related functions
This commit is contained in:
@@ -47,6 +47,7 @@ FUZZ_TARGETS = \
|
||||
test/fuzz/spanparsing \
|
||||
test/fuzz/sub_net_deserialize \
|
||||
test/fuzz/transaction \
|
||||
test/fuzz/tx_in \
|
||||
test/fuzz/tx_in_deserialize \
|
||||
test/fuzz/txoutcompressor_deserialize \
|
||||
test/fuzz/txundo_deserialize
|
||||
@@ -497,6 +498,12 @@ test_fuzz_tx_in_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
test_fuzz_tx_in_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
test_fuzz_tx_in_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
||||
|
||||
test_fuzz_tx_in_SOURCES = $(FUZZ_SUITE) test/fuzz/tx_in.cpp
|
||||
test_fuzz_tx_in_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
|
||||
test_fuzz_tx_in_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
test_fuzz_tx_in_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
test_fuzz_tx_in_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
||||
|
||||
endif # ENABLE_FUZZ
|
||||
|
||||
nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES)
|
||||
|
33
src/test/fuzz/tx_in.cpp
Normal file
33
src/test/fuzz/tx_in.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2019 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 <consensus/validation.h>
|
||||
#include <core_memusage.h>
|
||||
#include <policy/policy.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <streams.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
void test_one_input(const std::vector<uint8_t>& buffer)
|
||||
{
|
||||
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
||||
CTxIn tx_in;
|
||||
try {
|
||||
int version;
|
||||
ds >> version;
|
||||
ds.SetVersion(version);
|
||||
ds >> tx_in;
|
||||
} catch (const std::ios_base::failure&) {
|
||||
return;
|
||||
}
|
||||
|
||||
(void)GetTransactionInputWeight(tx_in);
|
||||
(void)GetVirtualTransactionInputSize(tx_in);
|
||||
(void)RecursiveDynamicUsage(tx_in);
|
||||
|
||||
(void)tx_in.ToString();
|
||||
}
|
Reference in New Issue
Block a user