mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-04 13:55:23 -05:00
test: update assert_fee_amount() in test_framework/util.py
- update call to round() with satoshi_round() to avoid intermittent test failures - rename fee_per_kB to feerate_BTC_kvB for precision - store division result in feerate_BTC_vB
This commit is contained in:
parent
efa227f5df
commit
b658d7d5c5
1 changed files with 5 additions and 4 deletions
|
@ -34,13 +34,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_BTC_kvB):
|
||||
"""Assert the fee is in range."""
|
||||
feerate_BTC_vB = feerate_BTC_kvB / 1000
|
||||
target_fee = satoshi_round(tx_size * feerate_BTC_vB)
|
||||
if fee < target_fee:
|
||||
raise AssertionError("Fee of %s BTC too low! (Should be %s BTC)" % (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_BTC_vB:
|
||||
raise AssertionError("Fee of %s BTC too high! (Should be %s BTC)" % (str(fee), str(target_fee)))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue