diff options
author | fanquake <fanquake@gmail.com> | 2019-12-09 15:02:50 -0500 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2019-12-09 15:14:20 -0500 |
commit | b6f9e3576a1ea18572e4803aeb3f39330f0cb759 (patch) | |
tree | a37a8044b58bd02b1609d7ef86b36bfbe5740980 /test/functional/test_framework | |
parent | 347dd76ec87ddbd1913dc7b57729793ac3bb1ab9 (diff) | |
download | bitcoin-b6f9e3576a1ea18572e4803aeb3f39330f0cb759.tar.xz |
test: re-enable CLI test support by using EncodeDecimal in json.dumps()
As mentioned in
https://github.com/bitcoin/bitcoin/pull/17675#issuecomment-563188648
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-x | test/functional/test_framework/test_node.py | 3 | ||||
-rw-r--r-- | test/functional/test_framework/util.py | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 1c9628264f..604c573940 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -30,6 +30,7 @@ from .util import ( rpc_url, wait_until, p2p_port, + EncodeDecimal, ) BITCOIND_PROC_WAIT_TIMEOUT = 60 @@ -480,7 +481,7 @@ def arg_to_cli(arg): if isinstance(arg, bool): return str(arg).lower() elif isinstance(arg, dict) or isinstance(arg, list): - return json.dumps(arg) + return json.dumps(arg, default=EncodeDecimal) else: return str(arg) diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 4d7967273a..5bb73aee7e 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -190,6 +190,11 @@ def check_json_precision(): if satoshis != 2000000000000003: raise RuntimeError("JSON encode/decode loses precision") +def EncodeDecimal(o): + if isinstance(o, Decimal): + return str(o) + raise TypeError(repr(o) + " is not JSON serializable") + def count_bytes(hex_string): return len(bytearray.fromhex(hex_string)) |