Skip to content

Commit

Permalink
Merge bitcoin#17705: test: re-enable CLI test support by using Encode…
Browse files Browse the repository at this point in the history
…Decimal in json.dumps()

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

Pull request description:

  As mentioned in bitcoin#17675 (comment).

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

Tree-SHA512: 79fa535cc1756c8ee610a3d6a316a1c4f036797d6990a5620e44985393a2e52f78450f8e0021d0a148c08705fd1ba765508464a365f9030ae0d2cacbd7a93e19
  • Loading branch information
fanquake authored and knst committed Jun 6, 2022
1 parent 6ba86b1 commit 63d8c49
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion test/functional/mempool_package_onemore.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class MempoolPackagesTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.extra_args = [["-maxorphantxsize=100000"]]
self.supports_cli = False

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
Expand Down
1 change: 0 additions & 1 deletion test/functional/mempool_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class MempoolPackagesTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
self.extra_args = [["-maxorphantxsize=1000"], ["-maxorphantxsize=1000", "-limitancestorcount=5"]]
self.supports_cli = False

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
Expand Down
1 change: 0 additions & 1 deletion test/functional/rpc_fundrawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class RawTransactionsTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 4
self.setup_clean_chain = True
self.supports_cli = False
self.extra_args = [['-usehd=0']] * self.num_nodes

def skip_test_if_missing_module(self):
Expand Down
1 change: 0 additions & 1 deletion test/functional/rpc_txoutproof.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def set_test_params(self):
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()
Expand Down
5 changes: 3 additions & 2 deletions test/functional/test_framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
wait_until,
p2p_port,
get_chain_folder,
Options
Options,
EncodeDecimal,
)

BITCOIND_PROC_WAIT_TIMEOUT = 60
Expand Down Expand Up @@ -556,7 +557,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)

Expand Down
5 changes: 5 additions & 0 deletions test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,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))

Expand Down
1 change: 0 additions & 1 deletion test/functional/wallet_abandonconflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion test/functional/wallet_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def set_test_params(self):
['-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()
Expand Down
1 change: 0 additions & 1 deletion test/functional/wallet_reorgsrestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
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()
Expand Down

0 comments on commit 63d8c49

Please sign in to comment.