LCOV - code coverage report
Current view: top level - src/test/fuzz - merkleblock.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 2 33 6.1 %
Date: 2023-11-06 23:13:05 Functions: 1 5 20.0 %
Branches: 2 42 4.8 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2020-2021 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 <merkleblock.h>
       6                 :            : #include <test/fuzz/FuzzedDataProvider.h>
       7                 :            : #include <test/fuzz/fuzz.h>
       8                 :            : #include <test/fuzz/util.h>
       9                 :            : #include <uint256.h>
      10                 :            : 
      11                 :            : #include <cstdint>
      12                 :            : #include <optional>
      13                 :            : #include <string>
      14                 :            : #include <vector>
      15                 :            : 
      16 [ +  - ][ +  - ]:          6 : FUZZ_TARGET(merkleblock)
      17                 :            : {
      18                 :          0 :     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      19                 :          0 :     CPartialMerkleTree partial_merkle_tree;
      20         [ #  # ]:          0 :     CallOneOf(
      21                 :            :         fuzzed_data_provider,
      22                 :          0 :         [&] {
      23                 :          0 :             const std::optional<CPartialMerkleTree> opt_partial_merkle_tree = ConsumeDeserializable<CPartialMerkleTree>(fuzzed_data_provider);
      24         [ #  # ]:          0 :             if (opt_partial_merkle_tree) {
      25         [ #  # ]:          2 :                 partial_merkle_tree = *opt_partial_merkle_tree;
      26                 :          0 :             }
      27                 :          0 :         },
      28                 :          0 :         [&] {
      29                 :          0 :             CMerkleBlock merkle_block;
      30                 :          0 :             const std::optional<CBlock> opt_block = ConsumeDeserializable<CBlock>(fuzzed_data_provider);
      31         [ #  # ]:          0 :             CBloomFilter bloom_filter;
      32                 :          0 :             std::set<uint256> txids;
      33 [ #  # ][ #  # ]:          0 :             if (opt_block && !opt_block->vtx.empty()) {
      34 [ #  # ][ #  # ]:          0 :                 if (fuzzed_data_provider.ConsumeBool()) {
      35         [ #  # ]:          0 :                     merkle_block = CMerkleBlock{*opt_block, bloom_filter};
      36 [ #  # ][ #  # ]:          0 :                 } else if (fuzzed_data_provider.ConsumeBool()) {
      37 [ #  # ][ #  # ]:          0 :                     LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
                 [ #  # ]
      38         [ #  # ]:          0 :                         txids.insert(ConsumeUInt256(fuzzed_data_provider));
      39                 :          0 :                     }
      40         [ #  # ]:          0 :                     merkle_block = CMerkleBlock{*opt_block, txids};
      41                 :          0 :                 }
      42                 :          0 :             }
      43         [ #  # ]:          0 :             partial_merkle_tree = merkle_block.txn;
      44                 :          0 :         });
      45         [ #  # ]:          0 :     (void)partial_merkle_tree.GetNumTransactions();
      46                 :          0 :     std::vector<uint256> matches;
      47                 :          0 :     std::vector<unsigned int> indices;
      48         [ #  # ]:          0 :     (void)partial_merkle_tree.ExtractMatches(matches, indices);
      49                 :          0 : }

Generated by: LCOV version 1.14