Branch data Line data Source code
1 : : // Copyright (c) 2020-present 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 <primitives/transaction.h>
6 : : #include <test/fuzz/FuzzedDataProvider.h>
7 : : #include <test/fuzz/fuzz.h>
8 : : #include <test/fuzz/util.h>
9 : : #include <util/check.h>
10 : :
11 : : #include <cstdint>
12 : : #include <optional>
13 : : #include <string>
14 : : #include <vector>
15 : :
16 [ + - ]: 998 : FUZZ_TARGET(primitives_transaction)
17 : : {
18 : 522 : FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
19 : 522 : const CScript script = ConsumeScript(fuzzed_data_provider);
20 : 522 : const std::optional<COutPoint> out_point = ConsumeDeserializable<COutPoint>(fuzzed_data_provider);
21 [ + + ]: 522 : if (out_point) {
22 [ + - ]: 135 : const CTxIn tx_in{*out_point, script, fuzzed_data_provider.ConsumeIntegral<uint32_t>()};
23 : 135 : (void)tx_in;
24 : 135 : }
25 [ + - ]: 522 : const CTxOut tx_out_1{ConsumeMoney(fuzzed_data_provider), script};
26 [ + - ]: 522 : const CTxOut tx_out_2{ConsumeMoney(fuzzed_data_provider), ConsumeScript(fuzzed_data_provider)};
27 : 522 : assert((tx_out_1 == tx_out_2) != (tx_out_1 != tx_out_2));
28 : 522 : const std::optional<CMutableTransaction> mutable_tx_1 = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider, TX_WITH_WITNESS);
29 : 522 : const std::optional<CMutableTransaction> mutable_tx_2 = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider, TX_WITH_WITNESS);
30 [ + + + + ]: 522 : if (mutable_tx_1 && mutable_tx_2) {
31 [ + - ]: 275 : const CTransaction tx_1{*mutable_tx_1};
32 [ + - ]: 275 : const CTransaction tx_2{*mutable_tx_2};
33 : 275 : (void)tx_1.Equals(tx_2);
34 : 550 : }
35 [ + + ]: 1044 : }
|