LCOV - code coverage report
Current view: top level - src/test/fuzz - primitives_transaction.cpp (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 18 18
Test Date: 2024-09-01 05:20:30 Functions: 100.0 % 2 2
Branches: 57.9 % 38 22

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

Generated by: LCOV version 2.0-1