LCOV - code coverage report
Current view: top level - src/test/fuzz - validation_load_mempool.cpp (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 73.7 % 19 14
Test Date: 2024-09-01 05:20:30 Functions: 75.0 % 4 3
Branches: 39.3 % 28 11

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2020-2022 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 <node/mempool_persist.h>
       6                 :             : 
       7                 :             : #include <node/mempool_args.h>
       8                 :             : #include <node/mempool_persist_args.h>
       9                 :             : #include <test/fuzz/FuzzedDataProvider.h>
      10                 :             : #include <test/fuzz/fuzz.h>
      11                 :             : #include <test/fuzz/util.h>
      12                 :             : #include <test/fuzz/util/mempool.h>
      13                 :             : #include <test/util/setup_common.h>
      14                 :             : #include <test/util/txmempool.h>
      15                 :             : #include <txmempool.h>
      16                 :             : #include <util/check.h>
      17                 :             : #include <util/time.h>
      18                 :             : #include <util/translation.h>
      19                 :             : #include <validation.h>
      20                 :             : 
      21                 :             : #include <cstdint>
      22                 :             : #include <vector>
      23                 :             : 
      24                 :             : using node::DumpMempool;
      25                 :             : using node::LoadMempool;
      26                 :             : 
      27                 :             : using node::MempoolPath;
      28                 :             : 
      29                 :             : namespace {
      30                 :             : const TestingSetup* g_setup;
      31                 :             : } // namespace
      32                 :             : 
      33                 :           0 : void initialize_validation_load_mempool()
      34                 :             : {
      35   [ #  #  #  #  :           0 :     static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
                   #  # ]
      36                 :           0 :     g_setup = testing_setup.get();
      37                 :           0 : }
      38                 :             : 
      39         [ +  - ]:        1696 : FUZZ_TARGET(validation_load_mempool, .init = initialize_validation_load_mempool)
      40                 :             : {
      41                 :        1694 :     FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
      42                 :        1694 :     SetMockTime(ConsumeTime(fuzzed_data_provider));
      43                 :        1694 :     FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
      44                 :             : 
      45                 :        1694 :     bilingual_str error;
      46   [ +  -  +  - ]:        1694 :     CTxMemPool pool{MemPoolOptionsForTest(g_setup->m_node), error};
      47   [ +  -  +  - ]:        1694 :     Assert(error.empty());
      48                 :             : 
      49         [ +  - ]:        1694 :     auto& chainstate{static_cast<DummyChainState&>(g_setup->m_node.chainman->ActiveChainstate())};
      50         [ +  - ]:        1694 :     chainstate.SetMempool(&pool);
      51                 :             : 
      52                 :        5082 :     auto fuzzed_fopen = [&](const fs::path&, const char*) {
      53                 :        3388 :         return fuzzed_file_provider.open();
      54                 :             :     };
      55   [ +  -  +  -  :        1694 :     (void)LoadMempool(pool, MempoolPath(g_setup->m_args), chainstate,
             +  -  +  - ]
      56                 :        3388 :                       {
      57                 :        1694 :                           .mockable_fopen_function = fuzzed_fopen,
      58                 :             :                       });
      59                 :             :     pool.SetLoadTried(true);
      60                 :             :     (void)DumpMempool(pool, MempoolPath(g_setup->m_args), fuzzed_fopen, true);
      61                 :           0 : }
        

Generated by: LCOV version 2.0-1