LCOV - code coverage report
Current view: top level - src/test/fuzz - load_external_block_file.cpp (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 18 18
Test Date: 2026-03-31 04:13:53 Functions: 100.0 % 3 3
Branches: 58.3 % 24 14

             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 <chainparams.h>
       6                 :             : #include <clientversion.h>
       7                 :             : #include <flatfile.h>
       8                 :             : #include <test/fuzz/FuzzedDataProvider.h>
       9                 :             : #include <test/fuzz/fuzz.h>
      10                 :             : #include <test/fuzz/util.h>
      11                 :             : #include <test/util/setup_common.h>
      12                 :             : #include <test/util/time.h>
      13                 :             : #include <util/time.h>
      14                 :             : #include <validation.h>
      15                 :             : 
      16                 :             : #include <cstdint>
      17                 :             : #include <vector>
      18                 :             : 
      19                 :             : namespace {
      20                 :             : const TestingSetup* g_setup;
      21                 :             : } // namespace
      22                 :             : 
      23                 :           1 : void initialize_load_external_block_file()
      24                 :             : {
      25   [ +  -  +  -  :           1 :     static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
                   +  - ]
      26                 :           1 :     g_setup = testing_setup.get();
      27                 :           1 : }
      28                 :             : 
      29         [ +  - ]:         776 : FUZZ_TARGET(load_external_block_file, .init = initialize_load_external_block_file)
      30                 :             : {
      31                 :         318 :     FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
      32                 :         318 :     NodeClockContext clock_ctx{ConsumeTime(fuzzed_data_provider)};
      33         [ +  - ]:         318 :     FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
      34   [ +  -  +  - ]:         636 :     AutoFile fuzzed_block_file{fuzzed_file_provider.open()};
      35         [ +  + ]:         318 :     if (fuzzed_block_file.IsNull()) {
      36                 :           2 :         return;
      37                 :             :     }
      38         [ +  + ]:         316 :     if (fuzzed_data_provider.ConsumeBool()) {
      39                 :             :         // Corresponds to the -reindex case (track orphan blocks across files).
      40                 :         135 :         FlatFilePos flat_file_pos;
      41         [ +  - ]:         135 :         std::multimap<uint256, FlatFilePos> blocks_with_unknown_parent;
      42         [ +  - ]:         135 :         g_setup->m_node.chainman->LoadExternalBlockFile(fuzzed_block_file, &flat_file_pos, &blocks_with_unknown_parent);
      43                 :         135 :     } else {
      44                 :             :         // Corresponds to the -loadblock= case (orphan blocks aren't tracked across files).
      45         [ +  - ]:         181 :         g_setup->m_node.chainman->LoadExternalBlockFile(fuzzed_block_file);
      46                 :             :     }
      47                 :         318 : }
        

Generated by: LCOV version 2.0-1