Debian Codegraph @

tests/functional_tests/check_missing_rpc_methods.py

raw symbols SCIP
1 #!/usr/bin/env python
2
3 from __future__ import print_function
4 import sys
5 import re
6
7 USAGE = 'usage: check_untested_methods.py <rootdir>'
8 try:
9 rootdir = sys.argv[1]
10 except:
11 print(USAGE)
12 sys.exit(1)
13
14 sys.path.insert(0, rootdir + '/utils/python-rpc')
15
16 from framework import daemon
17 from framework import wallet
18
19 modules = [
20 {
21 'name': 'daemon',
22 'object': daemon.Daemon(),
23 'path': rootdir + '/src/rpc/core_rpc_server.h',
24 'ignore': []
25 },
26 {
27 'name': 'wallet',
28 'object': wallet.Wallet(),
29 'path': rootdir + '/src/wallet/wallet_rpc_server.h',
30 'ignore': []
31 }
32 ]
33
34 error = False
35 for module in modules:
36 for line in open(module['path']).readlines():
37 if 'MAP_URI_AUTO_JON2' in line or 'MAP_JON_RPC' in line:
38 match = re.search('.*\"(.*)\".*', line)
39 name = match.group(1)
40 if name in module['ignore'] or name.endswith('.bin'):
41 continue
42 if 'MAP_URI_AUTO_JON2' in line:
43 if not name.startswith('/'):
44 print('Error: %s does not start with /' % name)
45 error = True
46 name = name[1:]
47 if not hasattr(module['object'], name):
48 print('Error: %s API method %s does not have a matching function' % (module['name'], name))
49 error = True
50
51 sys.exit(1 if error else 0)