mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 15:50:07 +01:00
test: Add functional tests for named argument parsing
This commit is contained in:
@@ -94,8 +94,30 @@ class TestBitcoinCli(BitcoinTestFramework):
|
||||
assert re.match(rf"^{re.escape(self.config['environment']['CLIENT_NAME'])} client.+services nwl2?$", det[0])
|
||||
assert not any(line.startswith("Local services:") for line in det)
|
||||
|
||||
def test_echojson_positional_equals(self):
|
||||
"""Test JSON parameter parsing containing '=' with -named echojson"""
|
||||
self.log.info("Test JSON parameter parsing containing '=' is handled correctly with -named")
|
||||
|
||||
# This should be treated as a positional JSON argument, not as a named
|
||||
result = self.nodes[0].cli("-named", "echojson", '["key=value"]').send_cli()
|
||||
assert_equal(result, [["key=value"]])
|
||||
|
||||
result = self.nodes[0].cli("-named", "echojson", '["key=value", "another=test"]').send_cli()
|
||||
assert_equal(result, [["key=value", "another=test"]])
|
||||
|
||||
result = self.nodes[0].cli("-named", "echojson", '["data=test"]', "42").send_cli()
|
||||
expected = [["data=test"], 42]
|
||||
assert_equal(result, expected)
|
||||
|
||||
# This should be treated as a named parameter, as arg0 and arg1 are valid parameter names
|
||||
result = self.nodes[0].cli("-named", "echojson", 'arg0=["data=test"]', 'arg1=42').send_cli()
|
||||
expected = [["data=test"], 42]
|
||||
assert_equal(result, expected)
|
||||
|
||||
def run_test(self):
|
||||
"""Main test logic"""
|
||||
self.test_echojson_positional_equals()
|
||||
|
||||
self.generate(self.nodes[0], BLOCKS)
|
||||
|
||||
self.log.info("Compare responses from getblockchaininfo RPC and `bitcoin-cli getblockchaininfo`")
|
||||
|
||||
Reference in New Issue
Block a user