File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ FUZZ_TARGETS = \
69
69
test/fuzz/partially_signed_transaction_deserialize \
70
70
test/fuzz/pow \
71
71
test/fuzz/prefilled_transaction_deserialize \
72
+ test/fuzz/primitives_transaction \
72
73
test/fuzz/process_messages \
73
74
test/fuzz/process_message \
74
75
test/fuzz/process_message_addr \
@@ -686,6 +687,12 @@ test_fuzz_prefilled_transaction_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
686
687
test_fuzz_prefilled_transaction_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
687
688
test_fuzz_prefilled_transaction_deserialize_SOURCES = test/fuzz/deserialize.cpp
688
689
690
+ test_fuzz_primitives_transaction_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
691
+ test_fuzz_primitives_transaction_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
692
+ test_fuzz_primitives_transaction_LDADD = $(FUZZ_SUITE_LD_COMMON)
693
+ test_fuzz_primitives_transaction_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
694
+ test_fuzz_primitives_transaction_SOURCES = test/fuzz/primitives_transaction.cpp
695
+
689
696
test_fuzz_process_messages_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
690
697
test_fuzz_process_messages_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
691
698
test_fuzz_process_messages_LDADD = $(FUZZ_SUITE_LD_COMMON)
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2020 The Bitcoin Core developers
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
5
+ #include < optional.h>
6
+ #include < primitives/transaction.h>
7
+ #include < test/fuzz/FuzzedDataProvider.h>
8
+ #include < test/fuzz/fuzz.h>
9
+ #include < test/fuzz/util.h>
10
+
11
+ #include < cstdint>
12
+ #include < string>
13
+ #include < vector>
14
+
15
+ void test_one_input (const std::vector<uint8_t >& buffer)
16
+ {
17
+ FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
18
+ const CScript script = ConsumeScript (fuzzed_data_provider);
19
+ const Optional<COutPoint> out_point = ConsumeDeserializable<COutPoint>(fuzzed_data_provider);
20
+ if (out_point) {
21
+ const CTxIn tx_in{*out_point, script, fuzzed_data_provider.ConsumeIntegral <uint32_t >()};
22
+ (void )tx_in;
23
+ }
24
+ const CTxOut tx_out_1{ConsumeMoney (fuzzed_data_provider), script};
25
+ const CTxOut tx_out_2{ConsumeMoney (fuzzed_data_provider), ConsumeScript (fuzzed_data_provider)};
26
+ assert ((tx_out_1 == tx_out_2) != (tx_out_1 != tx_out_2));
27
+ const Optional<CMutableTransaction> mutable_tx_1 = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
28
+ const Optional<CMutableTransaction> mutable_tx_2 = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
29
+ if (mutable_tx_1 && mutable_tx_2) {
30
+ const CTransaction tx_1{*mutable_tx_1};
31
+ const CTransaction tx_2{*mutable_tx_2};
32
+ assert ((tx_1 == tx_2) != (tx_1 != tx_2));
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments