Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1#!/usr/bin/env python32# Copyright (c) 2016-present The Bitcoin Core developers3# Distributed under the MIT software license, see the accompanying4# file COPYING or http://www.opensource.org/licenses/mit-license.php.5"""Test using named arguments for RPCs."""7from test_framework.test_framework import BitcoinTestFramework8from test_framework.util import (9assert_equal,10assert_raises_rpc_error,11)14class NamedArgumentTest(BitcoinTestFramework):15def set_test_params(self):16self.num_nodes = 118def run_test(self):19node = self.nodes[0]20h = node.help(command='getblockchaininfo')21assert h.startswith('getblockchaininfo\n')23assert_raises_rpc_error(-8, 'Unknown named parameter', node.help, random='getblockchaininfo')25h = node.getblockhash(height=0)26node.getblock(blockhash=h)28assert_equal(node.echojson(), [])29assert_equal(node.echojson(arg0=0, arg9=9), [0] + [None] * 8 + [9])30assert_equal(node.echojson(arg1=1), [None, 1])31assert_equal(node.echojson(arg9=None), [] if self.options.usecli else [None] * 10)32assert_equal(node.echojson(arg0=0, arg3=3, arg9=9), [0] + [None] * 2 + [3] + [None] * 5 + [9])33assert_equal(node.echojson(0, 1, arg3=3, arg5=5), [0, 1, None, 3, None, 5])34assert_raises_rpc_error(-8, "Parameter arg1 specified twice both as positional and named argument", node.echojson, 0, 1, arg1=1)35assert_raises_rpc_error(-8, "Parameter arg1 specified twice both as positional and named argument", node.echojson, 0, None, 2, arg1=1)37if __name__ == '__main__':38NamedArgumentTest(__file__).main()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.