mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #16917: tests: Move common function assert_approx() into util.py
96299a9d6c0a6b9125a58a63ee3147e55d1b086b Test: Move common function assert_approx() into util.py (fridokus)
Pull request description:
To reduce code duplication, move `assert_approx` into common framework `util.py`.
`assert_approx()` is used in two functional tests.
ACKs for top commit:
theStack:
ACK 96299a9
practicalswift:
ACK 96299a9d6c0a6b9125a58a63ee3147e55d1b086b -- DRY is good and diff looks correct
fanquake:
ACK 96299a9d6c0a6b9125a58a63ee3147e55d1b086b - thanks for contributing 🍻
Tree-SHA512: 8e9d397222c49536c7b3d6d0756cc5af17113e5af8707ac48a500fff1811167fb2e03f3c0445b0b9e80f34935f4d57cfb935c4790f6f5463a32a67df5f736939
This commit is contained in:
parent
d03d75fba8
commit
a7d94ed55f
@ -37,6 +37,13 @@ def set_timeout_scale(_timeout_scale):
|
|||||||
# Assert functions
|
# 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):
|
def assert_fee_amount(fee, tx_size, fee_per_kB):
|
||||||
"""Assert the fee was in range"""
|
"""Assert the fee was in range"""
|
||||||
target_fee = round(tx_size * fee_per_kB / 1000, 8)
|
target_fee = round(tx_size * fee_per_kB / 1000, 8)
|
||||||
|
@ -7,15 +7,10 @@
|
|||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.messages import CTransaction, FromHex, ToHex
|
from test_framework.messages import CTransaction, FromHex, ToHex
|
||||||
from test_framework.util import (
|
from test_framework.util import (
|
||||||
|
assert_approx,
|
||||||
assert_equal,
|
assert_equal,
|
||||||
)
|
)
|
||||||
|
|
||||||
def assert_approx(v, vexp, vspan=0.00001):
|
|
||||||
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)))
|
|
||||||
|
|
||||||
class WalletGroupTest(BitcoinTestFramework):
|
class WalletGroupTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
|
Loading…
Reference in New Issue
Block a user