Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/util.py
Show All 40 Lines | def assert_fee_amount(fee, tx_size, fee_per_kB, wiggleroom=2): | ||||
""" | """ | ||||
Assert the fee was in range | Assert the fee was in range | ||||
wiggleroom defines an amount that the test expects the wallet to be off by | wiggleroom defines an amount that the test expects the wallet to be off by | ||||
when estimating fees. This can be due to the dummy signature that is added | when estimating fees. This can be due to the dummy signature that is added | ||||
during fee calculation, or due to the wallet funding transactions using the | during fee calculation, or due to the wallet funding transactions using the | ||||
ceiling of the calculated fee. | ceiling of the calculated fee. | ||||
""" | """ | ||||
target_fee = round(tx_size * fee_per_kB / 1000, 8) | target_fee = satoshi_round(tx_size * fee_per_kB / 1000) | ||||
if fee < (tx_size - wiggleroom) * fee_per_kB / 1000: | if fee < (tx_size - wiggleroom) * fee_per_kB / 1000: | ||||
raise AssertionError( | raise AssertionError( | ||||
"Fee of {} XEC too low! (Should be {} XEC)".format(str(fee), str(target_fee))) | "Fee of {} XEC too low! (Should be {} XEC)".format(str(fee), str(target_fee))) | ||||
if fee > (tx_size + wiggleroom) * fee_per_kB / 1000: | if fee > (tx_size + wiggleroom) * fee_per_kB / 1000: | ||||
raise AssertionError( | raise AssertionError( | ||||
"Fee of {} XEC too high! (Should be {} XEC)".format(str(fee), str(target_fee))) | "Fee of {} XEC too high! (Should be {} XEC)".format(str(fee), str(target_fee))) | ||||
▲ Show 20 Lines • Show All 587 Lines • Show Last 20 Lines |