Skip to content

Commit

Permalink
Merge bitcoin#23136: test: update fee rate assertion helper in the fu…
Browse files Browse the repository at this point in the history
…nctional test framework

b658d7d test: update assert_fee_amount() in test_framework/util.py (Jon Atack)

Pull request description:

  Follow-up to 42e1b5d (bitcoin#12486).
  - update call to `round()` with our utility function `satoshi_round()` to avoid intermittent test failures
  - rename `fee_per_kB` to `feerate_BTC_kvB` for precision
  - store division result in `feerate_BTC_vB`

  Possibly resolves bitcoin#19418.

ACKs for top commit:
  meshcollider:
    utACK b658d7d

Tree-SHA512: f124ded98c913f98782dc047a85a05d3fdf5f0585041fa81129be562138f6261ec1bd9ee2af89729028277e75b591b0a7ad50244016c2b2fa935c6e400523183
  • Loading branch information
MarcoFalke authored and vijaydasmp committed Nov 24, 2024
1 parent 58077d0 commit 748209d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ def assert_approx(v, vexp, vspan=0.00001):
raise AssertionError("%s > [%s..%s]" % (str(v), str(vexp - vspan), str(vexp + vspan)))


def assert_fee_amount(fee, tx_size, fee_per_kB):
"""Assert the fee was in range"""
target_fee = round(tx_size * fee_per_kB / 1000, 8)
def assert_fee_amount(fee, tx_size, feerate_DASH_kvB):
"""Assert the fee is in range."""
feerate_DASH_vB = feerate_DASH_kvB / 1000
target_fee = satoshi_round(tx_size * feerate_DASH_vB)
if fee < target_fee:
raise AssertionError("Fee of %s DASH too low! (Should be %s DASH)" % (str(fee), str(target_fee)))
# allow the wallet's estimation to be at most 2 bytes off
if fee > (tx_size + 2) * fee_per_kB / 1000:
if fee > (tx_size + 2) * feerate_DASH_vB:
raise AssertionError("Fee of %s DASH too high! (Should be %s DASH)" % (str(fee), str(target_fee)))


Expand Down

0 comments on commit 748209d

Please sign in to comment.