aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/authproxy.py
diff options
context:
space:
mode:
authorRyan Ofsky <ryan@ofsky.org>2020-08-18 11:43:42 -0400
committerRyan Ofsky <ryan@ofsky.org>2022-11-05 05:32:39 -0400
commitd8b12a75dbfdc1d3e62352f0fa815bbbdc685caf (patch)
treebb0ff4c040506be8802d35c8e53e3777e9b4a649 /test/functional/test_framework/authproxy.py
parent50422b770a40f5fa964201d1e99fd6b5dc1653ca (diff)
rpc: Allow named and positional arguments to be used together
It's nice to be able to use named options and positional arguments together. Most shell tools accept both, and python functions combine options and arguments allowing them to be passed with even more flexibility. This change adds support for python's approach so as a motivating example: bitcoin-cli -named createwallet wallet_name=mywallet load_on_startup=1 Can be shortened to: bitcoin-cli -named createwallet mywallet load_on_startup=1 JSON-RPC standard doesn't have a convention for passing named and positional parameters together, so this implementation makes one up and interprets any unused "args" named parameter as a positional parameter array.
Diffstat (limited to 'test/functional/test_framework/authproxy.py')
-rw-r--r--test/functional/test_framework/authproxy.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/test/functional/test_framework/authproxy.py b/test/functional/test_framework/authproxy.py
index c4ffd1fbf6..dd20b28550 100644
--- a/test/functional/test_framework/authproxy.py
+++ b/test/functional/test_framework/authproxy.py
@@ -131,10 +131,12 @@ class AuthServiceProxy():
json.dumps(args or argsn, default=EncodeDecimal, ensure_ascii=self.ensure_ascii),
))
if args and argsn:
- raise ValueError('Cannot handle both named and positional arguments')
+ params = dict(args=args, **argsn)
+ else:
+ params = args or argsn
return {'version': '1.1',
'method': self._service_name,
- 'params': args or argsn,
+ 'params': params,
'id': AuthServiceProxy.__id_count}
def __call__(self, *args, **argsn):