Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_help.py
Show All 12 Lines | |||||
class HelpRpcTest(BitcoinTestFramework): | class HelpRpcTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.supports_cli = False | self.supports_cli = False | ||||
def run_test(self): | def run_test(self): | ||||
self.test_categories() | self.test_categories() | ||||
self.dump_help() | self.dump_help() | ||||
if self.is_wallet_compiled(): | |||||
self.wallet_help() | |||||
def test_categories(self): | def test_categories(self): | ||||
node = self.nodes[0] | node = self.nodes[0] | ||||
# wrong argument count | # wrong argument count | ||||
assert_raises_rpc_error(-1, 'help', node.help, 'foo', 'bar') | assert_raises_rpc_error(-1, 'help', node.help, 'foo', 'bar') | ||||
# invalid argument | # invalid argument | ||||
Show All 23 Lines | def dump_help(self): | ||||
calls = [line.split(' ', 1)[0] for line in self.nodes[0].help( | calls = [line.split(' ', 1)[0] for line in self.nodes[0].help( | ||||
).splitlines() if line and not line.startswith('==')] | ).splitlines() if line and not line.startswith('==')] | ||||
for call in calls: | for call in calls: | ||||
with open(os.path.join(dump_dir, call), 'w', encoding='utf-8') as f: | with open(os.path.join(dump_dir, call), 'w', encoding='utf-8') as f: | ||||
# Make sure the node can generate the help at runtime without | # Make sure the node can generate the help at runtime without | ||||
# crashing | # crashing | ||||
f.write(self.nodes[0].help(call)) | f.write(self.nodes[0].help(call)) | ||||
def wallet_help(self): | |||||
assert ('getnewaddress ( "label" "address_type" )' in | |||||
self.nodes[0].help('getnewaddress')) | |||||
self.restart_node(0, extra_args=['-nowallet=1']) | |||||
assert ('getnewaddress ( "label" "address_type" )' in | |||||
self.nodes[0].help('getnewaddress')) | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
HelpRpcTest().main() | HelpRpcTest().main() |