Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/util.py
Show All 22 Lines | |||||
# Assert functions | # Assert functions | ||||
################## | ################## | ||||
def assert_fee_amount(fee, tx_size, fee_per_kB): | def assert_fee_amount(fee, tx_size, fee_per_kB): | ||||
"""Assert the fee was in range""" | """Assert the fee was in range""" | ||||
target_fee = tx_size * fee_per_kB / 1000 | target_fee = tx_size * fee_per_kB / 1000 | ||||
if fee < target_fee: | if fee < (tx_size - 10) * fee_per_kB / 1000: | ||||
raise AssertionError( | raise AssertionError( | ||||
"Fee of %s BTC too low! (Should be %s BTC)" % (str(fee), str(target_fee))) | "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 | # 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 + 10) * fee_per_kB / 1000: | ||||
raise AssertionError( | raise AssertionError( | ||||
"Fee of %s BTC too high! (Should be %s BTC)" % (str(fee), str(target_fee))) | "Fee of %s BTC too high! (Should be %s BTC)" % (str(fee), str(target_fee))) | ||||
def assert_equal(thing1, thing2, *args): | def assert_equal(thing1, thing2, *args): | ||||
if thing1 != thing2 or any(thing1 != arg for arg in args): | if thing1 != thing2 or any(thing1 != arg for arg in args): | ||||
raise AssertionError("not(%s)" % " == ".join(str(arg) | raise AssertionError("not(%s)" % " == ".join(str(arg) | ||||
for arg in (thing1, thing2) + args)) | for arg in (thing1, thing2) + args)) | ||||
▲ Show 20 Lines • Show All 587 Lines • Show Last 20 Lines |