Skip to content

Commit fa26c42

Browse files
author
MarcoFalke
committed
[qa] util: Move check_fee_amount out of wallet.py
1 parent 44c1b1c commit fa26c42

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

qa/rpc-tests/test_framework/util.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,15 @@ def random_transaction(nodes, amount, min_fee, fee_increment, fee_variants):
477477

478478
return (txid, signresult["hex"], fee)
479479

480+
def assert_fee_amount(fee, tx_size, fee_per_kB):
481+
"""Assert the fee was in range"""
482+
target_fee = tx_size * fee_per_kB / 1000
483+
if fee < target_fee:
484+
raise AssertionError("Fee of %s BTC too low! (Should be %s BTC)"%(str(fee), str(target_fee)))
485+
# allow the wallet's estimation to be at most 2 bytes off
486+
if fee > (tx_size + 2) * fee_per_kB / 1000:
487+
raise AssertionError("Fee of %s BTC too high! (Should be %s BTC)"%(str(fee), str(target_fee)))
488+
480489
def assert_equal(thing1, thing2):
481490
if thing1 != thing2:
482491
raise AssertionError("%s != %s"%(str(thing1),str(thing2)))

qa/rpc-tests/wallet.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ class WalletTest (BitcoinTestFramework):
1111
def check_fee_amount(self, curr_balance, balance_with_fee, fee_per_byte, tx_size):
1212
"""Return curr_balance after asserting the fee was in range"""
1313
fee = balance_with_fee - curr_balance
14-
target_fee = fee_per_byte * tx_size
15-
if fee < target_fee:
16-
raise AssertionError("Fee of %s BTC too low! (Should be %s BTC)"%(str(fee), str(target_fee)))
17-
# allow the node's estimation to be at most 2 bytes off
18-
if fee > fee_per_byte * (tx_size + 2):
19-
raise AssertionError("Fee of %s BTC too high! (Should be %s BTC)"%(str(fee), str(target_fee)))
14+
assert_fee_amount(fee, tx_size, fee_per_byte * 1000)
2015
return curr_balance
2116

2217
def __init__(self):

0 commit comments

Comments
 (0)