LCOV - code coverage report
Current view: top level - src/test - policy_fee_tests.cpp (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 100.0 % 12 12
Test Date: 2024-08-28 04:44:32 Functions: 100.0 % 2 2
Branches: 51.2 % 84 43

             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/fees.h>
       7                 :             : 
       8                 :             : #include <boost/test/unit_test.hpp>
       9                 :             : 
      10                 :             : #include <set>
      11                 :             : 
      12                 :             : BOOST_AUTO_TEST_SUITE(policy_fee_tests)
      13                 :             : 
      14   [ +  -  +  -  :           7 : BOOST_AUTO_TEST_CASE(FeeRounder)
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                      - ]
      15                 :             : {
      16                 :           1 :     FastRandomContext rng{/*fDeterministic=*/true};
      17         [ +  - ]:           1 :     FeeFilterRounder fee_rounder{CFeeRate{1000}, rng};
      18                 :             : 
      19                 :             :     // check that 1000 rounds to 974 or 1071
      20                 :           1 :     std::set<CAmount> results;
      21         [ +  + ]:           5 :     while (results.size() < 2) {
      22   [ +  -  +  - ]:           4 :         results.emplace(fee_rounder.round(1000));
      23                 :             :     }
      24   [ +  -  +  - ]:           1 :     BOOST_CHECK_EQUAL(*results.begin(), 974);
      25   [ +  -  +  - ]:           1 :     BOOST_CHECK_EQUAL(*++results.begin(), 1071);
      26                 :             : 
      27                 :             :     // check that negative amounts rounds to 0
      28   [ +  -  +  -  :           1 :     BOOST_CHECK_EQUAL(fee_rounder.round(-0), 0);
                   +  - ]
      29   [ +  -  +  -  :           1 :     BOOST_CHECK_EQUAL(fee_rounder.round(-1), 0);
                   +  - ]
      30                 :             : 
      31                 :             :     // check that MAX_MONEY rounds to 9170997
      32   [ +  -  +  -  :           1 :     BOOST_CHECK_EQUAL(fee_rounder.round(MAX_MONEY), 9170997);
                   +  - ]
      33                 :           1 : }
      34                 :             : 
      35                 :             : BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1