LCOV - code coverage report
Current view: top level - src/test/fuzz/util - mempool.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 11 11 100.0 %
Date: 2023-10-05 15:40:34 Functions: 4 4 100.0 %
Branches: 12 24 50.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 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 <consensus/amount.h>
       6                 :            : #include <consensus/consensus.h>
       7                 :            : #include <kernel/mempool_entry.h>
       8                 :            : #include <primitives/transaction.h>
       9                 :            : #include <test/fuzz/FuzzedDataProvider.h>
      10                 :            : #include <test/fuzz/util.h>
      11                 :            : #include <test/fuzz/util/mempool.h>
      12                 :            : 
      13                 :            : #include <cassert>
      14                 :            : #include <cstdint>
      15                 :            : #include <limits>
      16                 :            : 
      17         [ +  - ]:     217742 : CTxMemPoolEntry ConsumeTxMemPoolEntry(FuzzedDataProvider& fuzzed_data_provider, const CTransaction& tx) noexcept
      18         [ +  - ]:        173 : {
      19                 :            :     // Avoid:
      20                 :            :     // policy/feerate.cpp:28:34: runtime error: signed integer overflow: 34873208148477500 * 1000 cannot be represented in type 'long'
      21                 :            :     //
      22                 :            :     // Reproduce using CFeeRate(348732081484775, 10).GetFeePerK()
      23         [ +  - ]:     217569 :     const CAmount fee{ConsumeMoney(fuzzed_data_provider, /*max=*/std::numeric_limits<CAmount>::max() / CAmount{100'000})};
      24   [ +  -  +  - ]:     217569 :     assert(MoneyRange(fee));
      25         [ +  - ]:     217569 :     const int64_t time = fuzzed_data_provider.ConsumeIntegral<int64_t>();
      26         [ +  - ]:     217569 :     const uint64_t entry_sequence{fuzzed_data_provider.ConsumeIntegral<uint64_t>()};
      27         [ +  - ]:     217569 :     const unsigned int entry_height = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
      28         [ +  - ]:     217569 :     const bool spends_coinbase = fuzzed_data_provider.ConsumeBool();
      29         [ +  - ]:     217569 :     const unsigned int sig_op_cost = fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(0, MAX_BLOCK_SIGOPS_COST);
      30   [ +  -  +  - ]:     217569 :     return CTxMemPoolEntry{MakeTransactionRef(tx), fee, time, entry_height, entry_sequence, spends_coinbase, sig_op_cost, {}};
      31                 :            : }

Generated by: LCOV version 1.14