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

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

Pull request description:

  As mentioned in https://github.com/bitcoin/bitcoin/pull/17675#issuecomment-563188648.

ACKs for top commit:
  practicalswift:
    ACK b6f9e3576a assuming Travis is happy too -- diff looks correct :)
  MarcoFalke:
    > ACK b6f9e35 assuming Travis is happy too -- diff looks correct :)

Tree-SHA512: 79fa535cc1756c8ee610a3d6a316a1c4f036797d6990a5620e44985393a2e52f78450f8e0021d0a148c08705fd1ba765508464a365f9030ae0d2cacbd7a93e19
This commit is contained in:
fanquake 2019-12-11 20:10:59 -05:00
commit 3f1966ead6
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
@ -489,7 +490,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()