Skip to content

Commit 1361f8b

Browse files
author
MarcoFalke
committed
Merge #14020: Add tests for RPC help
6af6d9b test: Add tests for RPC help (João Barbosa) Pull request description: At the moment the new test checks for: - invalid usages - expected output for unknown command - current RPC command titles (derived from command categories) — this prevents adding wrong RPC categories and new categories must be added to the test Tree-SHA512: f987535d001b1cd300656588602b1634099ea68a1dd2282180c30fa56caf7f990be9e2dc86c7431dfcf7fd686d0299a8d4935df178a2c9f0fb6fbebcba748eb5
2 parents b0eb8f7 + 6af6d9b commit 1361f8b

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

test/functional/rpc_help.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2018 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 RPC help output."""
6+
7+
from test_framework.test_framework import BitcoinTestFramework
8+
from test_framework.util import assert_equal, assert_raises_rpc_error
9+
10+
class HelpRpcTest(BitcoinTestFramework):
11+
def set_test_params(self):
12+
self.num_nodes = 1
13+
14+
def run_test(self):
15+
node = self.nodes[0]
16+
17+
# wrong argument count
18+
assert_raises_rpc_error(-1, 'help', node.help, 'foo', 'bar')
19+
20+
# invalid argument
21+
assert_raises_rpc_error(-1, 'JSON value is not a string as expected', node.help, 0)
22+
23+
# help of unknown command
24+
assert_equal(node.help('foo'), 'help: unknown command: foo')
25+
26+
# command titles
27+
titles = [line[3:-3] for line in node.help().splitlines() if line.startswith('==')]
28+
assert_equal(titles, ['Blockchain', 'Control', 'Generating', 'Mining', 'Network', 'Rawtransactions', 'Util', 'Wallet', 'Zmq'])
29+
30+
if __name__ == '__main__':
31+
HelpRpcTest().main()

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
'p2p_node_network_limited.py',
153153
'feature_blocksdir.py',
154154
'feature_config_args.py',
155+
'rpc_help.py',
155156
'feature_help.py',
156157
# Don't append tests at the end to avoid merge conflicts
157158
# Put them in a random line within the section that fits their approximate run-time

0 commit comments

Comments
 (0)