From 4cd51487c4a34f835236f3973c5209c3643e3365 Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 20 Sep 2019 16:42:24 +0800 Subject: [PATCH] fix: missing changes from Merge #16917: tests: Move common function assert_approx() into util.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- test/functional/wallet_avoidreuse.py | 8 +------- test/functional/wallet_groups.py | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/test/functional/wallet_avoidreuse.py b/test/functional/wallet_avoidreuse.py index b5fb557c5c..9e2fd009f9 100755 --- a/test/functional/wallet_avoidreuse.py +++ b/test/functional/wallet_avoidreuse.py @@ -6,17 +6,11 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( + assert_approx, assert_equal, assert_raises_rpc_error, ) -# TODO: Copied from wallet_groups.py -- should perhaps move into util.py -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))) - def reset_balance(node, discardaddr): '''Throw away all owned coins by the node so it gets a balance of 0.''' balance = node.getbalance(avoid_reuse=False) diff --git a/test/functional/wallet_groups.py b/test/functional/wallet_groups.py index 0e0a2b0d1e..2b6114cf3e 100755 --- a/test/functional/wallet_groups.py +++ b/test/functional/wallet_groups.py @@ -12,7 +12,6 @@ from test_framework.util import ( assert_equal, ) - class WalletGroupTest(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True