diff --git a/test/functional/test_framework/authproxy.py b/test/functional/test_framework/authproxy.py index 4bab36503c4..03042877b20 100644 --- a/test/functional/test_framework/authproxy.py +++ b/test/functional/test_framework/authproxy.py @@ -60,7 +60,7 @@ class JSONRPCException(Exception): self.http_status = http_status -def EncodeDecimal(o): +def serialization_fallback(o): if isinstance(o, decimal.Decimal): return str(o) if isinstance(o, pathlib.Path): @@ -111,7 +111,7 @@ class AuthServiceProxy(): log.debug("-{}-> {} {}".format( AuthServiceProxy.__id_count, self._service_name, - json.dumps(args or argsn, default=EncodeDecimal, ensure_ascii=self.ensure_ascii), + json.dumps(args or argsn, default=serialization_fallback, ensure_ascii=self.ensure_ascii), )) if args and argsn: params = dict(args=args, **argsn) @@ -123,7 +123,7 @@ class AuthServiceProxy(): 'id': AuthServiceProxy.__id_count} def __call__(self, *args, **argsn): - postdata = json.dumps(self.get_request(*args, **argsn), default=EncodeDecimal, ensure_ascii=self.ensure_ascii) + postdata = json.dumps(self.get_request(*args, **argsn), default=serialization_fallback, ensure_ascii=self.ensure_ascii) response, status = self._request('POST', self.__url.path, postdata.encode('utf-8')) if response['error'] is not None: raise JSONRPCException(response['error'], status) @@ -137,7 +137,7 @@ class AuthServiceProxy(): return response['result'] def batch(self, rpc_call_list): - postdata = json.dumps(list(rpc_call_list), default=EncodeDecimal, ensure_ascii=self.ensure_ascii) + postdata = json.dumps(list(rpc_call_list), default=serialization_fallback, ensure_ascii=self.ensure_ascii) log.debug("--> " + postdata) response, status = self._request('POST', self.__url.path, postdata.encode('utf-8')) if status != HTTPStatus.OK: @@ -170,7 +170,7 @@ class AuthServiceProxy(): response = json.loads(responsedata, parse_float=decimal.Decimal) elapsed = time.time() - req_start_time if "error" in response and response["error"] is None: - log.debug("<-%s- [%.6f] %s" % (response["id"], elapsed, json.dumps(response["result"], default=EncodeDecimal, ensure_ascii=self.ensure_ascii))) + log.debug("<-%s- [%.6f] %s" % (response["id"], elapsed, json.dumps(response["result"], default=serialization_fallback, ensure_ascii=self.ensure_ascii))) else: log.debug("<-- [%.6f] %s" % (elapsed, responsedata)) return response, http_response.status diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index a5995b9d37e..5111d88e15e 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -24,7 +24,7 @@ from pathlib import Path from .authproxy import ( JSONRPCException, - EncodeDecimal, + serialization_fallback, ) from .descriptors import descsum_create from .p2p import P2P_SUBVERSION @@ -714,7 +714,7 @@ def arg_to_cli(arg): elif arg is None: return 'null' elif isinstance(arg, dict) or isinstance(arg, list): - return json.dumps(arg, default=EncodeDecimal) + return json.dumps(arg, default=serialization_fallback) else: return str(arg)