Skip to content

Commit 6251949

Browse files
committed
Merge bitcoin/bitcoin#32290: test: allow all functional tests to be run or skipped with --usecli
666016e ci: use --usecli in one of the CI jobs (Martin Zumsande) 7ea248a test: Disable several (sub)tests with cli (Martin Zumsande) f420b63 test: skip subtests that check for wrong types with cli (Martin Zumsande) 6530d00 test: add function to convert to json for height_or_hash params (Martin Zumsande) 54d2872 test: Don't send empty named args with cli (Martin Zumsande) cca4220 test: convert tuple to json for cli (Martin Zumsande) af34e98 test: make rpc_psbt.py usable with --usecli (Martin Zumsande) 8f8ce9e test: rename .rpc to ._rpc and remove unnecessary uses (Martin Zumsande) 5b08885 test: enable functional tests with large rpc args for cli (Martin Zumsande) 7d5352a test: use -stdin for large rpc commands (Martin Zumsande) 6c364e0 test: Enable various tests for usage with cli (Martin Zumsande) Pull request description: Fixes #32264 I looked into all current failures listed in the issue, as well all tests that are already disabled for the cli with `self.supports_cli = False`. There are several reasons why existing tests fail with `--usecli` on many systems, the most important ones are: - Most common reason is that the test executes a RPC call with a large arg that exceeds `MAX_ARG_STRLEN` of the OS, which is usually 128kb on linux: This is fixed by using `-stdin` for these large calls (idea by 0xB10C) - they test specifically the rpc interface - nothing to do there except disabling. - Some functional test submit wrong types to params on purpose to test the error message (which is different when using the cli) - deactivated these specific subtests locally for the cli when there is just one or two of them, deactivated the entire tests when there are more spots - When python sets `None` for an arg, the cli converts this to 'null' in `arg_to_cli`. This is fine e.g. for boolean args, but doesn't work for strings where it's interpreted as the string 'null'. Bypass this for named args by not including args in case the value is `None` for the cli is used (it's effectively the same as leaving the optional arg out). - the `height_or_hash` param used in some RPC needs to be converted to a JSON (effectively adding full quotes). - Some tests were marked with `self.supports_cli = False` in the past but run fine on master today - enabled those. In total, this PR fixes all tests that fail on master and reduces the number of tests that are deactivated (`self.supports_cli = False`) from 40 to 21. It also adds `--usecli` to one CI job (multiprocess, i686, DEBUG) to detect regressions. ACKs for top commit: maflcko: re-ACK 666016e 🔀 pinheadmz: re-ACK 666016e Tree-SHA512: 7a1efd212649ca100b236a1239294d40ecd36e2720e3b173a230b14545bb40b135111db7fed8a0d1448120f5387da146a03f1912e2028c8d03a0b6a3ca8761b0
2 parents 49d5f1f + 666016e commit 6251949

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+110
-98
lines changed

ci/test/00_setup_env_i686_multiprocess.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export CI_IMAGE_PLATFORM="linux/amd64"
1313
export PACKAGES="llvm clang g++-multilib"
1414
export DEP_OPTS="DEBUG=1 MULTIPROCESS=1"
1515
export GOAL="install"
16-
export TEST_RUNNER_EXTRA="--v2transport"
16+
export TEST_RUNNER_EXTRA="--v2transport --usecli"
1717
export BITCOIN_CONFIG="\
1818
-DCMAKE_BUILD_TYPE=Debug \
1919
-DCMAKE_C_COMPILER='clang;-m32' \

test/functional/feature_assumeutxo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ def check_dump_output(output):
481481

482482
# Use a hash instead of a height
483483
prev_snap_hash = n0.getblockhash(prev_snap_height)
484-
dump_output5 = n0.dumptxoutset('utxos5.dat', rollback=prev_snap_hash)
484+
dump_output5 = n0.dumptxoutset('utxos5.dat', rollback=self.convert_to_json_for_cli(prev_snap_hash))
485485
assert_equal(sha256sum_file(dump_output4['path']), sha256sum_file(dump_output5['path']))
486486

487487
# Ensure n0 is back at the tip

test/functional/feature_coinstatsindex.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class CoinStatsIndexTest(BitcoinTestFramework):
4141
def set_test_params(self):
4242
self.setup_clean_chain = True
4343
self.num_nodes = 2
44-
self.supports_cli = False
4544
self.extra_args = [
4645
[],
4746
["-coinstatsindex"]
@@ -104,7 +103,7 @@ def _test_coin_stats_index(self):
104103
assert_equal(res0, res2)
105104

106105
# Fetch old stats by hash
107-
res3 = index_node.gettxoutsetinfo(hash_option, res0['bestblock'])
106+
res3 = index_node.gettxoutsetinfo(hash_option, self.convert_to_json_for_cli(res0['bestblock']))
108107
del res3['block_info'], res3['total_unspendable_amount']
109108
res3.pop('muhash', None)
110109
assert_equal(res0, res3)
@@ -243,7 +242,7 @@ def _test_coin_stats_index(self):
243242
assert_equal(res12, res10)
244243

245244
self.log.info("Test obtaining info for a non-existent block hash")
246-
assert_raises_rpc_error(-5, "Block not found", index_node.gettxoutsetinfo, hash_type="none", hash_or_height="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", use_index=True)
245+
assert_raises_rpc_error(-5, "Block not found", index_node.gettxoutsetinfo, hash_type="none", hash_or_height=self.convert_to_json_for_cli("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), use_index=True)
247246

248247
def _test_use_index_option(self):
249248
self.log.info("Test use_index option for nodes running the index")
@@ -278,7 +277,7 @@ def _test_reorg_index(self):
278277
assert_not_equal(res["muhash"], res_invalid["muhash"])
279278

280279
# Test that requesting reorged out block by hash is still returning correct results
281-
res_invalid2 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=reorg_block)
280+
res_invalid2 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=self.convert_to_json_for_cli(reorg_block))
282281
assert_equal(res_invalid2["muhash"], res_invalid["muhash"])
283282
assert_not_equal(res["muhash"], res_invalid2["muhash"])
284283

test/functional/feature_csv_activation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ def set_test_params(self):
100100
self.extra_args = [[
101101
f'-testactivationheight=csv@{CSV_ACTIVATION_HEIGHT}',
102102
]]
103-
self.supports_cli = False
104103

105104
def create_self_transfer_from_utxo(self, input_tx):
106105
utxo = self.miniwallet.get_utxo(txid=input_tx.txid_hex, mark_as_spent=False)

test/functional/feature_index_prune.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def run_test(self):
6767
for node in filter_nodes:
6868
assert_greater_than(len(node.getblockfilter(tip)['filter']), 0)
6969
for node in stats_nodes:
70-
assert node.gettxoutsetinfo(hash_type="muhash", hash_or_height=tip)['muhash']
70+
assert node.gettxoutsetinfo(hash_type="muhash", hash_or_height=self.convert_to_json_for_cli(tip))['muhash']
7171

7272
self.generate(self.nodes[0], 500)
7373
self.sync_index(height=700)
@@ -85,14 +85,14 @@ def run_test(self):
8585
for node in filter_nodes:
8686
assert_greater_than(len(node.getblockfilter(tip)['filter']), 0)
8787
for node in stats_nodes:
88-
assert node.gettxoutsetinfo(hash_type="muhash", hash_or_height=tip)['muhash']
88+
assert node.gettxoutsetinfo(hash_type="muhash", hash_or_height=self.convert_to_json_for_cli(tip))['muhash']
8989

9090
self.log.info("check if we can access the blockfilter and coinstats of a pruned block")
9191
height_hash = self.nodes[0].getblockhash(2)
9292
for node in filter_nodes:
9393
assert_greater_than(len(node.getblockfilter(height_hash)['filter']), 0)
9494
for node in stats_nodes:
95-
assert node.gettxoutsetinfo(hash_type="muhash", hash_or_height=height_hash)['muhash']
95+
assert node.gettxoutsetinfo(hash_type="muhash", hash_or_height=self.convert_to_json_for_cli(height_hash))['muhash']
9696

9797
# mine and sync index up to a height that will later be the pruneheight
9898
self.generate(self.nodes[0], 51)
@@ -106,7 +106,7 @@ def run_test(self):
106106
assert_raises_rpc_error(-1, msg, node.getblockfilter, height_hash)
107107
for node in stats_nodes:
108108
msg = "Querying specific block heights requires coinstatsindex"
109-
assert_raises_rpc_error(-8, msg, node.gettxoutsetinfo, "muhash", height_hash)
109+
assert_raises_rpc_error(-8, msg, node.gettxoutsetinfo, "muhash", self.convert_to_json_for_cli(height_hash))
110110

111111
self.generate(self.nodes[0], 749)
112112

test/functional/feature_maxuploadtarget.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def set_test_params(self):
5252
self.extra_args = [[
5353
f"-maxuploadtarget={UPLOAD_TARGET_MB}M",
5454
]]
55-
self.supports_cli = False
5655

5756
def assert_uploadtarget_state(self, *, target_reached, serve_historical_blocks):
5857
"""Verify the node's current upload target state via the `getnettotals` RPC call."""

test/functional/feature_pruning.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class PruneTest(BitcoinTestFramework):
6969
def set_test_params(self):
7070
self.setup_clean_chain = True
7171
self.num_nodes = 6
72-
self.supports_cli = False
7372
self.uses_wallet = None
7473

7574
# Create nodes 0 and 1 to mine.

test/functional/feature_rbf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def set_test_params(self):
3333
[
3434
],
3535
]
36-
self.supports_cli = False
3736
self.uses_wallet = None
3837

3938
def run_test(self):

test/functional/mempool_limit.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def set_test_params(self):
3131
self.extra_args = [[
3232
"-maxmempool=5",
3333
]]
34-
self.supports_cli = False
3534

3635
def test_rbf_carveout_disallowed(self):
3736
node = self.nodes[0]

test/functional/mining_basic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def set_test_params(self):
6565
["-fastprune", "-prune=1"]
6666
]
6767
self.setup_clean_chain = True
68-
self.supports_cli = False
6968

7069
def mine_chain(self):
7170
self.log.info('Create some old blocks')

0 commit comments

Comments
 (0)