Skip to content

Commit b658d7d

Browse files
committed
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
1 parent efa227f commit b658d7d

File tree

1 file changed

+5
-4
lines changed
  • test/functional/test_framework

1 file changed

+5
-4
lines changed

test/functional/test_framework/util.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ def assert_approx(v, vexp, vspan=0.00001):
3434
raise AssertionError("%s > [%s..%s]" % (str(v), str(vexp - vspan), str(vexp + vspan)))
3535

3636

37-
def assert_fee_amount(fee, tx_size, fee_per_kB):
38-
"""Assert the fee was in range"""
39-
target_fee = round(tx_size * fee_per_kB / 1000, 8)
37+
def assert_fee_amount(fee, tx_size, feerate_BTC_kvB):
38+
"""Assert the fee is in range."""
39+
feerate_BTC_vB = feerate_BTC_kvB / 1000
40+
target_fee = satoshi_round(tx_size * feerate_BTC_vB)
4041
if fee < target_fee:
4142
raise AssertionError("Fee of %s BTC too low! (Should be %s BTC)" % (str(fee), str(target_fee)))
4243
# allow the wallet's estimation to be at most 2 bytes off
43-
if fee > (tx_size + 2) * fee_per_kB / 1000:
44+
if fee > (tx_size + 2) * feerate_BTC_vB:
4445
raise AssertionError("Fee of %s BTC too high! (Should be %s BTC)" % (str(fee), str(target_fee)))
4546

4647

0 commit comments

Comments
 (0)