test: re-enable CLI test support by using EncodeDecimal in json.dumps()

As mentioned in
https://github.com/bitcoin/bitcoin/pull/17675#issuecomment-563188648
This commit is contained in:
fanquake 2019-12-09 15:02:50 -05:00
parent 347dd76ec8
commit b6f9e3576a
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
14 changed files with 7 additions and 13 deletions

View file

@ -72,7 +72,6 @@ class SegWitTest(BitcoinTestFramework):
"-addresstype=legacy",
],
]
self.supports_cli = False
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

View file

@ -19,7 +19,6 @@ class MempoolPackagesTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.extra_args = [["-maxorphantx=1000"]]
self.supports_cli = False
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

View file

@ -27,7 +27,6 @@ class MempoolPackagesTest(BitcoinTestFramework):
["-maxorphantx=1000"],
["-maxorphantx=1000", "-limitancestorcount={}".format(MAX_ANCESTORS_CUSTOM)],
]
self.supports_cli = False
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

View file

@ -31,7 +31,6 @@ class RawTransactionsTest(BitcoinTestFramework):
# This test isn't testing tx relay. Set whitelist on the peers for
# instant tx relay.
self.extra_args = [['-whitelist=127.0.0.1']] * self.num_nodes
self.supports_cli = False
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

View file

@ -15,7 +15,6 @@ class SignRawTransactionsTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 2
self.supports_cli = False
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

View file

@ -14,7 +14,6 @@ class MerkleBlockTest(BitcoinTestFramework):
self.setup_clean_chain = True
# Nodes 0/1 are "wallet" nodes, Nodes 2/3 are used for testing
self.extra_args = [[], [], [], ["-txindex"]]
self.supports_cli = False
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

View file

@ -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)

View file

@ -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))

View file

@ -26,7 +26,6 @@ class AbandonConflictTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
self.extra_args = [["-minrelaytxfee=0.00001"], []]
self.supports_cli = False
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

View file

@ -54,7 +54,6 @@ class WalletTest(BitcoinTestFramework):
['-limitdescendantcount=3'], # Limit mempool descendants as a hack to have wallet txs rejected from the mempool
[],
]
self.supports_cli = False
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

View file

@ -40,7 +40,6 @@ class BumpFeeTest(BitcoinTestFramework):
"-deprecatedrpc=totalFee",
"-addresstype=bech32",
] for i in range(self.num_nodes)]
self.supports_cli = False
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

View file

@ -16,7 +16,6 @@ class BumpFeeWithTotalFeeArgumentDeprecationTest(BitcoinTestFramework):
"-walletrbf={}".format(i),
"-mintxfee=0.00002",
] for i in range(self.num_nodes)]
self.supports_cli = False
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

View file

@ -19,7 +19,6 @@ class ListSinceBlockTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 4
self.setup_clean_chain = True
self.supports_cli = False
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

View file

@ -27,7 +27,6 @@ from test_framework.util import (
class ReorgsRestoreTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 3
self.supports_cli = False
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()