You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rpcnamedargs.py 1.1KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python3
  2. # Copyright (c) 2016 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."""
  6. from test_framework.test_framework import BitcoinTestFramework
  7. from test_framework.util import (
  8. assert_equal,
  9. assert_raises_rpc_error,
  10. )
  11. class NamedArgumentTest(BitcoinTestFramework):
  12. def set_test_params(self):
  13. self.num_nodes = 1
  14. def run_test(self):
  15. node = self.nodes[0]
  16. h = node.help(command='getinfo')
  17. assert(h.startswith('getinfo\n'))
  18. assert_raises_rpc_error(-8, 'Unknown named parameter', node.help, random='getinfo')
  19. h = node.getblockhash(height=0)
  20. node.getblock(blockhash=h)
  21. assert_equal(node.echo(), [])
  22. assert_equal(node.echo(arg0=0,arg9=9), [0] + [None]*8 + [9])
  23. assert_equal(node.echo(arg1=1), [None, 1])
  24. assert_equal(node.echo(arg9=None), [None]*10)
  25. assert_equal(node.echo(arg0=0,arg3=3,arg9=9), [0] + [None]*2 + [3] + [None]*5 + [9])
  26. if __name__ == '__main__':
  27. NamedArgumentTest().main()