2 # Copyright (c) 2016-2017 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 """Test using named arguments for RPCs."""
7 from test_framework
.test_framework
import BitcoinTestFramework
8 from test_framework
.util
import (
10 assert_raises_rpc_error
,
13 class NamedArgumentTest(BitcoinTestFramework
):
14 def set_test_params(self
):
19 h
= node
.help(command
='getblockchaininfo')
20 assert(h
.startswith('getblockchaininfo\n'))
22 assert_raises_rpc_error(-8, 'Unknown named parameter', node
.help, random
='getblockchaininfo')
24 h
= node
.getblockhash(height
=0)
25 node
.getblock(blockhash
=h
)
27 assert_equal(node
.echo(), [])
28 assert_equal(node
.echo(arg0
=0,arg9
=9), [0] + [None]*8 + [9])
29 assert_equal(node
.echo(arg1
=1), [None, 1])
30 assert_equal(node
.echo(arg9
=None), [None]*10)
31 assert_equal(node
.echo(arg0
=0,arg3
=3,arg9
=9), [0] + [None]*2 + [3] + [None]*5 + [9])
33 if __name__
== '__main__':
34 NamedArgumentTest().main()