LCOV - code coverage report
Current view: top level - src/test/fuzz - fee_rate.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 4 24 16.7 %
Date: 2023-11-06 23:13:05 Functions: 1 5 20.0 %
Branches: 4 26 15.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 <consensus/amount.h>
       6                 :            : #include <policy/feerate.h>
       7                 :            : #include <test/fuzz/FuzzedDataProvider.h>
       8                 :            : #include <test/fuzz/fuzz.h>
       9                 :            : #include <test/fuzz/util.h>
      10                 :            : 
      11                 :            : #include <cstdint>
      12                 :            : #include <limits>
      13                 :            : #include <string>
      14                 :            : #include <vector>
      15                 :            : 
      16 [ +  - ][ +  - ]:          6 : FUZZ_TARGET(fee_rate)
      17         [ +  - ]:          2 : {
      18         [ +  - ]:          2 :     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      19                 :          0 :     const CAmount satoshis_per_k = ConsumeMoney(fuzzed_data_provider);
      20                 :          0 :     const CFeeRate fee_rate{satoshis_per_k};
      21                 :            : 
      22                 :          0 :     (void)fee_rate.GetFeePerK();
      23                 :          0 :     const auto bytes = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
      24         [ #  # ]:          0 :     if (!MultiplicationOverflow(int64_t{bytes}, satoshis_per_k)) {
      25                 :          2 :         (void)fee_rate.GetFee(bytes);
      26                 :          0 :     }
      27                 :          0 :     (void)fee_rate.ToString();
      28                 :            : 
      29                 :          0 :     const CAmount another_satoshis_per_k = ConsumeMoney(fuzzed_data_provider);
      30                 :          0 :     CFeeRate larger_fee_rate{another_satoshis_per_k};
      31                 :          0 :     larger_fee_rate += fee_rate;
      32 [ #  # ][ #  # ]:          0 :     if (satoshis_per_k != 0 && another_satoshis_per_k != 0) {
      33         [ #  # ]:          0 :         assert(fee_rate < larger_fee_rate);
      34         [ #  # ]:          0 :         assert(!(fee_rate > larger_fee_rate));
      35         [ #  # ]:          0 :         assert(!(fee_rate == larger_fee_rate));
      36         [ #  # ]:          0 :         assert(fee_rate <= larger_fee_rate);
      37         [ #  # ]:          0 :         assert(!(fee_rate >= larger_fee_rate));
      38         [ #  # ]:          0 :         assert(fee_rate != larger_fee_rate);
      39                 :          0 :     }
      40                 :          0 : }

Generated by: LCOV version 1.14