LCOV - code coverage report
Current view: top level - src/test/fuzz - blockfilter.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 23 23 100.0 %
Date: 2023-10-05 15:40:34 Functions: 3 3 100.0 %
Branches: 31 56 55.4 %

           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 <blockfilter.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         [ -  + ]:        514 : FUZZ_TARGET(blockfilter)
      16                 :            : {
      17                 :        168 :     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      18                 :        168 :     const std::optional<BlockFilter> block_filter = ConsumeDeserializable<BlockFilter>(fuzzed_data_provider);
      19         [ +  + ]:        168 :     if (!block_filter) {
      20                 :         39 :         return;
      21                 :            :     }
      22                 :            :     {
      23   [ +  -  +  - ]:        129 :         (void)block_filter->ComputeHeader(ConsumeUInt256(fuzzed_data_provider));
      24   [ +  -  +  - ]:        129 :         (void)block_filter->GetBlockHash();
      25   [ +  -  +  -  :        302 :         (void)block_filter->GetEncodedFilter();
                   +  - ]
      26   [ +  -  +  - ]:        129 :         (void)block_filter->GetHash();
      27                 :            :     }
      28                 :            :     {
      29   [ +  -  +  - ]:        129 :         const BlockFilterType block_filter_type = block_filter->GetFilterType();
      30         [ +  - ]:        129 :         (void)BlockFilterTypeName(block_filter_type);
      31                 :            :     }
      32                 :            :     {
      33   [ +  -  +  -  :        129 :         const GCSFilter gcs_filter = block_filter->GetFilter();
                   +  - ]
      34         [ +  - ]:        129 :         (void)gcs_filter.GetN();
      35         [ +  - ]:        129 :         (void)gcs_filter.GetParams();
      36         [ +  - ]:        129 :         (void)gcs_filter.GetEncoded();
      37         [ +  - ]:        129 :         (void)gcs_filter.Match(ConsumeRandomLengthByteVector(fuzzed_data_provider));
      38         [ +  - ]:        129 :         GCSFilter::ElementSet element_set;
      39   [ +  -  +  +  :     152801 :         LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 30000)
                   +  + ]
      40                 :            :         {
      41         [ +  - ]:     152672 :             element_set.insert(ConsumeRandomLengthByteVector(fuzzed_data_provider));
      42                 :     152672 :         }
      43         [ +  - ]:        129 :         gcs_filter.MatchAny(element_set);
      44                 :        129 :     }
      45         [ -  + ]:        168 : }

Generated by: LCOV version 1.14