LCOV - code coverage report
Current view: top level - src/test/fuzz - policy_estimator_io.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 3 17 17.6 %
Date: 2023-11-06 23:13:05 Functions: 1 7 14.3 %
Branches: 3 26 11.5 %

           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 <policy/fees.h>
       6                 :            : #include <policy/fees_args.h>
       7                 :            : #include <test/fuzz/FuzzedDataProvider.h>
       8                 :            : #include <test/fuzz/fuzz.h>
       9                 :            : #include <test/fuzz/util.h>
      10                 :            : #include <test/util/setup_common.h>
      11                 :            : 
      12                 :            : #include <cstdint>
      13                 :            : #include <vector>
      14                 :            : 
      15                 :            : namespace {
      16                 :            : const BasicTestingSetup* g_setup;
      17         [ +  - ]:          2 : } // namespace
      18         [ +  - ]:          2 : 
      19                 :          0 : void initialize_policy_estimator_io()
      20                 :            : {
      21 [ #  # ][ #  # ]:          0 :     static const auto testing_setup = MakeNoLogFileContext<>();
                 [ #  # ]
      22                 :          0 :     g_setup = testing_setup.get();
      23                 :          0 : }
      24                 :            : 
      25         [ +  - ]:          4 : FUZZ_TARGET(policy_estimator_io, .init = initialize_policy_estimator_io)
      26                 :            : {
      27                 :          0 :     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      28                 :          0 :     FuzzedAutoFileProvider fuzzed_auto_file_provider = ConsumeAutoFile(fuzzed_data_provider);
      29                 :          0 :     AutoFile fuzzed_auto_file{fuzzed_auto_file_provider.open()};
      30                 :            :     // Re-using block_policy_estimator across runs to avoid costly creation of CBlockPolicyEstimator object.
      31 [ #  # ][ #  # ]:          0 :     static CBlockPolicyEstimator block_policy_estimator{FeeestPath(*g_setup->m_node.args), DEFAULT_ACCEPT_STALE_FEE_ESTIMATES};
         [ #  # ][ #  # ]
      32 [ #  # ][ #  # ]:          0 :     if (block_policy_estimator.Read(fuzzed_auto_file)) {
      33         [ #  # ]:          0 :         block_policy_estimator.Write(fuzzed_auto_file);
      34                 :          0 :     }
      35                 :          0 : }

Generated by: LCOV version 1.14