-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added rpc help test Tests the ability to generate help at runtime * Added check for compiled wallet and zmq * Setup clean chain to try avoid timeout on travis * Streamline test to only check invalid help calls and help categories * Added back removed functionality * Updated init
- Loading branch information
1 parent
1990d92
commit 6707a98
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env python3 | ||
# Tests RPC help output at runtime | ||
|
||
from test_framework.test_framework import NavCoinTestFramework | ||
from test_framework.util import * | ||
|
||
import os | ||
|
||
|
||
class HelpRpcTest(NavCoinTestFramework): | ||
def __init__(self): | ||
super().__init__() | ||
self.setup_clean_chain = True | ||
self.num_nodes = 1 | ||
|
||
def setup_network(self, split=False): | ||
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir) | ||
self.is_network_split = False | ||
|
||
def run_test(self): | ||
self.test_categories() | ||
self.dump_help() | ||
|
||
def test_categories(self): | ||
node = self.nodes[0] | ||
|
||
# wrong argument count | ||
assert_raises_rpc_error(-1, 'help ( "command" )', node.help, 'foo', 'bar') | ||
|
||
# invalid argument | ||
assert_raises_rpc_error(-1, 'JSON value is not a string as expected', node.help, 0) | ||
|
||
# help of unknown command | ||
assert_equal(node.help('foo'), 'help: unknown command: foo') | ||
|
||
# command titles | ||
titles = [line[3:-3] for line in node.help().splitlines() if line.startswith('==')] | ||
|
||
components = ['Addressindex', 'Blockchain', 'Communityfund', 'Control', 'Generating', 'Hacking', 'Mining', 'Network', 'Rawtransactions', 'Util'] | ||
|
||
# titles and components will differ depending on whether wallet and/or zmq are compiled | ||
if 'Wallet' in titles: | ||
components.append('Wallet') | ||
|
||
if 'Zmq' in titles: | ||
components.append('Zmq') | ||
|
||
assert_equal(titles, components) | ||
|
||
def dump_help(self): | ||
dump_dir = os.path.join(self.options.tmpdir, 'rpc_help_dump') | ||
os.mkdir(dump_dir) | ||
calls = [line.split(' ', 1)[0] for line in self.nodes[0].help().splitlines() if line and not line.startswith('==')] | ||
for call in calls: | ||
with open(os.path.join(dump_dir, call), 'w', encoding='utf-8') as f: | ||
# Make sure node can generate the help at runtime without crashing | ||
f.write(self.nodes[0].help(call)) | ||
|
||
|
||
if __name__ == '__main__': | ||
HelpRpcTest().main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters