aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-05-24 21:56:04 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-09-17 11:38:30 +0000
commite037ecb014858054670ef2b0992ba7a934c84e15 (patch)
tree6309fd812859884258ec82ef08703acea096ddc3 /tests
parentfunctional_tests: add get_transaction_pool_stats (diff)
downloadmonero-e037ecb014858054670ef2b0992ba7a934c84e15.tar.xz
functional_tests: check for RPC methods which aren't exposed
Diffstat (limited to 'tests')
-rw-r--r--tests/functional_tests/CMakeLists.txt4
-rw-r--r--tests/functional_tests/check_missing_rpc_methods.py50
2 files changed, 54 insertions, 0 deletions
diff --git a/tests/functional_tests/CMakeLists.txt b/tests/functional_tests/CMakeLists.txt
index fd49ba623..bc55da9e3 100644
--- a/tests/functional_tests/CMakeLists.txt
+++ b/tests/functional_tests/CMakeLists.txt
@@ -59,3 +59,7 @@ else()
message(WARNING "functional_tests_rpc skipped, needs the 'requests' python module")
set(CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} functional_tests_rpc)
endif()
+
+add_test(
+ NAME check_missing_rpc_methods
+ COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/check_missing_rpc_methods.py" "${CMAKE_SOURCE_DIR}")
diff --git a/tests/functional_tests/check_missing_rpc_methods.py b/tests/functional_tests/check_missing_rpc_methods.py
new file mode 100644
index 000000000..6fadebf9b
--- /dev/null
+++ b/tests/functional_tests/check_missing_rpc_methods.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+import sys
+import re
+
+USAGE = 'usage: check_untested_methods.py <rootdir>'
+try:
+ rootdir = sys.argv[1]
+except:
+ print(USAGE)
+ sys.exit(1)
+
+sys.path.insert(0, rootdir + '/utils/python-rpc')
+
+from framework import daemon
+from framework import wallet
+
+modules = [
+ {
+ 'name': 'daemon',
+ 'object': daemon.Daemon(),
+ 'path': rootdir + '/src/rpc/core_rpc_server.h',
+ 'ignore': []
+ },
+ {
+ 'name': 'wallet',
+ 'object': wallet.Wallet(),
+ 'path': rootdir + '/src/wallet/wallet_rpc_server.h',
+ 'ignore': []
+ }
+]
+
+error = False
+for module in modules:
+ for line in open(module['path']).readlines():
+ if 'MAP_URI_AUTO_JON2' in line or 'MAP_JON_RPC' in line:
+ match = re.search('.*\"(.*)\".*', line)
+ name = match.group(1)
+ if name in module['ignore'] or name.endswith('.bin'):
+ continue
+ if 'MAP_URI_AUTO_JON2' in line:
+ if not name.startswith('/'):
+ print('Error: %s does not start with /' % name)
+ error = True
+ name = name[1:]
+ if not hasattr(module['object'], name):
+ print('Error: %s API method %s does not have a matching function' % (module['name'], name))
+
+sys.exit(1 if error else 0)