diff options
author | fridokus <raxomukus@gmail.com> | 2019-09-19 14:53:40 +0200 |
---|---|---|
committer | fridokus <raxomukus@gmail.com> | 2019-09-19 14:53:40 +0200 |
commit | 96299a9d6c0a6b9125a58a63ee3147e55d1b086b (patch) | |
tree | 67a67bd03567613ba1c6d1afc837e08e32375d44 /test/functional/test_framework | |
parent | 9bf5768dd628b3a7c30dd42b5ed477a92c4d3540 (diff) | |
download | bitcoin-96299a9d6c0a6b9125a58a63ee3147e55d1b086b.tar.xz |
Test: Move common function assert_approx() into util.py
Diffstat (limited to 'test/functional/test_framework')
-rw-r--r-- | test/functional/test_framework/util.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 3175872b00..1c254b6755 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -25,6 +25,13 @@ logger = logging.getLogger("TestFramework.utils") # Assert functions ################## +def assert_approx(v, vexp, vspan=0.00001): + """Assert that `v` is within `vspan` of `vexp`""" + if v < vexp - vspan: + raise AssertionError("%s < [%s..%s]" % (str(v), str(vexp - vspan), str(vexp + vspan))) + if v > vexp + vspan: + 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) |