mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-09-27 22:47:35 +02:00
tests: Add fuzzing harness for various CTxOut related functions
This commit is contained in:
@@ -49,6 +49,7 @@ FUZZ_TARGETS = \
|
|||||||
test/fuzz/transaction \
|
test/fuzz/transaction \
|
||||||
test/fuzz/tx_in \
|
test/fuzz/tx_in \
|
||||||
test/fuzz/tx_in_deserialize \
|
test/fuzz/tx_in_deserialize \
|
||||||
|
test/fuzz/tx_out \
|
||||||
test/fuzz/txoutcompressor_deserialize \
|
test/fuzz/txoutcompressor_deserialize \
|
||||||
test/fuzz/txundo_deserialize
|
test/fuzz/txundo_deserialize
|
||||||
|
|
||||||
@@ -504,6 +505,12 @@ test_fuzz_tx_in_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
|||||||
test_fuzz_tx_in_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
test_fuzz_tx_in_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||||
test_fuzz_tx_in_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
test_fuzz_tx_in_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
||||||
|
|
||||||
|
test_fuzz_tx_out_SOURCES = $(FUZZ_SUITE) test/fuzz/tx_out.cpp
|
||||||
|
test_fuzz_tx_out_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
|
||||||
|
test_fuzz_tx_out_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||||
|
test_fuzz_tx_out_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||||
|
test_fuzz_tx_out_LDADD = $(FUZZ_SUITE_LD_COMMON)
|
||||||
|
|
||||||
endif # ENABLE_FUZZ
|
endif # ENABLE_FUZZ
|
||||||
|
|
||||||
nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES)
|
nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES)
|
||||||
|
35
src/test/fuzz/tx_out.cpp
Normal file
35
src/test/fuzz/tx_out.cpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
// 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>
|
||||||
|
|
||||||
|
void test_one_input(const std::vector<uint8_t>& buffer)
|
||||||
|
{
|
||||||
|
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
||||||
|
CTxOut tx_out;
|
||||||
|
try {
|
||||||
|
int version;
|
||||||
|
ds >> version;
|
||||||
|
ds.SetVersion(version);
|
||||||
|
ds >> tx_out;
|
||||||
|
} catch (const std::ios_base::failure&) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CFeeRate dust_relay_fee{DUST_RELAY_TX_FEE};
|
||||||
|
(void)GetDustThreshold(tx_out, dust_relay_fee);
|
||||||
|
(void)IsDust(tx_out, dust_relay_fee);
|
||||||
|
(void)RecursiveDynamicUsage(tx_out);
|
||||||
|
|
||||||
|
(void)tx_out.ToString();
|
||||||
|
(void)tx_out.IsNull();
|
||||||
|
tx_out.SetNull();
|
||||||
|
assert(tx_out.IsNull());
|
||||||
|
}
|
Reference in New Issue
Block a user