mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 03:59:33 +00:00
functional_tests: check for RPC methods which aren't exposed
This commit is contained in:
parent
d53a55204f
commit
e037ecb014
4 changed files with 196 additions and 0 deletions
|
@ -59,3 +59,7 @@ else()
|
||||||
message(WARNING "functional_tests_rpc skipped, needs the 'requests' python module")
|
message(WARNING "functional_tests_rpc skipped, needs the 'requests' python module")
|
||||||
set(CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} functional_tests_rpc)
|
set(CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} functional_tests_rpc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_test(
|
||||||
|
NAME check_missing_rpc_methods
|
||||||
|
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/check_missing_rpc_methods.py" "${CMAKE_SOURCE_DIR}")
|
||||||
|
|
50
tests/functional_tests/check_missing_rpc_methods.py
Normal file
50
tests/functional_tests/check_missing_rpc_methods.py
Normal file
|
@ -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)
|
|
@ -49,6 +49,7 @@ class Daemon(object):
|
||||||
'id': '0'
|
'id': '0'
|
||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(getblocktemplate)
|
return self.rpc.send_json_rpc_request(getblocktemplate)
|
||||||
|
get_block_template = getblocktemplate
|
||||||
|
|
||||||
def send_raw_transaction(self, tx_as_hex, do_not_relay = False, do_sanity_checks = True):
|
def send_raw_transaction(self, tx_as_hex, do_not_relay = False, do_sanity_checks = True):
|
||||||
send_raw_transaction = {
|
send_raw_transaction = {
|
||||||
|
@ -57,6 +58,7 @@ class Daemon(object):
|
||||||
'do_sanity_checks': do_sanity_checks,
|
'do_sanity_checks': do_sanity_checks,
|
||||||
}
|
}
|
||||||
return self.rpc.send_request("/send_raw_transaction", send_raw_transaction)
|
return self.rpc.send_request("/send_raw_transaction", send_raw_transaction)
|
||||||
|
sendrawtransaction = send_raw_transaction
|
||||||
|
|
||||||
def submitblock(self, block):
|
def submitblock(self, block):
|
||||||
submitblock = {
|
submitblock = {
|
||||||
|
@ -66,6 +68,7 @@ class Daemon(object):
|
||||||
'id': '0'
|
'id': '0'
|
||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(submitblock)
|
return self.rpc.send_json_rpc_request(submitblock)
|
||||||
|
submit_block = submitblock
|
||||||
|
|
||||||
def getblock(self, hash = '', height = 0, fill_pow_hash = False):
|
def getblock(self, hash = '', height = 0, fill_pow_hash = False):
|
||||||
getblock = {
|
getblock = {
|
||||||
|
@ -79,6 +82,7 @@ class Daemon(object):
|
||||||
'id': '0'
|
'id': '0'
|
||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(getblock)
|
return self.rpc.send_json_rpc_request(getblock)
|
||||||
|
get_block = getblock
|
||||||
|
|
||||||
def getlastblockheader(self):
|
def getlastblockheader(self):
|
||||||
getlastblockheader = {
|
getlastblockheader = {
|
||||||
|
@ -89,6 +93,7 @@ class Daemon(object):
|
||||||
'id': '0'
|
'id': '0'
|
||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(getlastblockheader)
|
return self.rpc.send_json_rpc_request(getlastblockheader)
|
||||||
|
get_last_block_header = getlastblockheader
|
||||||
|
|
||||||
def getblockheaderbyhash(self, hash = "", hashes = []):
|
def getblockheaderbyhash(self, hash = "", hashes = []):
|
||||||
getblockheaderbyhash = {
|
getblockheaderbyhash = {
|
||||||
|
@ -101,6 +106,7 @@ class Daemon(object):
|
||||||
'id': '0'
|
'id': '0'
|
||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(getblockheaderbyhash)
|
return self.rpc.send_json_rpc_request(getblockheaderbyhash)
|
||||||
|
get_block_header_by_hash = getblockheaderbyhash
|
||||||
|
|
||||||
def getblockheaderbyheight(self, height):
|
def getblockheaderbyheight(self, height):
|
||||||
getblockheaderbyheight = {
|
getblockheaderbyheight = {
|
||||||
|
@ -112,6 +118,7 @@ class Daemon(object):
|
||||||
'id': '0'
|
'id': '0'
|
||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(getblockheaderbyheight)
|
return self.rpc.send_json_rpc_request(getblockheaderbyheight)
|
||||||
|
get_block_header_by_height = getblockheaderbyheight
|
||||||
|
|
||||||
def getblockheadersrange(self, start_height, end_height, fill_pow_hash = False):
|
def getblockheadersrange(self, start_height, end_height, fill_pow_hash = False):
|
||||||
getblockheadersrange = {
|
getblockheadersrange = {
|
||||||
|
@ -125,6 +132,7 @@ class Daemon(object):
|
||||||
'id': '0'
|
'id': '0'
|
||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(getblockheadersrange)
|
return self.rpc.send_json_rpc_request(getblockheadersrange)
|
||||||
|
get_block_headers_range = getblockheadersrange
|
||||||
|
|
||||||
def get_connections(self):
|
def get_connections(self):
|
||||||
get_connections = {
|
get_connections = {
|
||||||
|
@ -141,6 +149,7 @@ class Daemon(object):
|
||||||
'id': '0'
|
'id': '0'
|
||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(get_info)
|
return self.rpc.send_json_rpc_request(get_info)
|
||||||
|
getinfo = get_info
|
||||||
|
|
||||||
def hard_fork_info(self):
|
def hard_fork_info(self):
|
||||||
hard_fork_info = {
|
hard_fork_info = {
|
||||||
|
@ -172,6 +181,7 @@ class Daemon(object):
|
||||||
'id': '0'
|
'id': '0'
|
||||||
}
|
}
|
||||||
return self.rpc.send_request("/get_height", get_height)
|
return self.rpc.send_request("/get_height", get_height)
|
||||||
|
getheight = get_height
|
||||||
|
|
||||||
def pop_blocks(self, nblocks = 1):
|
def pop_blocks(self, nblocks = 1):
|
||||||
pop_blocks = {
|
pop_blocks = {
|
||||||
|
@ -261,6 +271,7 @@ class Daemon(object):
|
||||||
'split': split,
|
'split': split,
|
||||||
}
|
}
|
||||||
return self.rpc.send_request('/get_transactions', get_transactions)
|
return self.rpc.send_request('/get_transactions', get_transactions)
|
||||||
|
gettransactions = get_transactions
|
||||||
|
|
||||||
def get_outs(self, outputs = [], get_txid = False):
|
def get_outs(self, outputs = [], get_txid = False):
|
||||||
get_outs = {
|
get_outs = {
|
||||||
|
@ -360,3 +371,130 @@ class Daemon(object):
|
||||||
save_bc = {
|
save_bc = {
|
||||||
}
|
}
|
||||||
return self.rpc.send_request('/save_bc', save_bc)
|
return self.rpc.send_request('/save_bc', save_bc)
|
||||||
|
|
||||||
|
def get_peer_list(self):
|
||||||
|
get_peer_list = {
|
||||||
|
}
|
||||||
|
return self.rpc.send_request('/get_peer_list', get_peer_list)
|
||||||
|
|
||||||
|
def set_log_hash_rate(self, visible):
|
||||||
|
set_log_hash_rate = {
|
||||||
|
'visible': visible,
|
||||||
|
}
|
||||||
|
return self.rpc.send_request('/set_log_hash_rate', set_log_hash_rate)
|
||||||
|
|
||||||
|
def stop_daemon(self):
|
||||||
|
stop_daemon = {
|
||||||
|
}
|
||||||
|
return self.rpc.send_request('/stop_daemon', stop_daemon)
|
||||||
|
|
||||||
|
def get_net_stats(self):
|
||||||
|
get_net_stats = {
|
||||||
|
}
|
||||||
|
return self.rpc.send_request('/get_net_stats', get_net_stats)
|
||||||
|
|
||||||
|
def get_limit(self):
|
||||||
|
get_limit = {
|
||||||
|
}
|
||||||
|
return self.rpc.send_request('/get_limit', get_limit)
|
||||||
|
|
||||||
|
def set_limit(self, limit_down, limit_up):
|
||||||
|
set_limit = {
|
||||||
|
'limit_down': limit_down,
|
||||||
|
'limit_up': limit_up,
|
||||||
|
}
|
||||||
|
return self.rpc.send_request('/set_limit', set_limit)
|
||||||
|
|
||||||
|
def out_peers(self, out_peers):
|
||||||
|
out_peers = {
|
||||||
|
'out_peers': out_peers,
|
||||||
|
}
|
||||||
|
return self.rpc.send_request('/out_peers', out_peers)
|
||||||
|
|
||||||
|
def in_peers(self, in_peers):
|
||||||
|
in_peers = {
|
||||||
|
'in_peers': in_peers,
|
||||||
|
}
|
||||||
|
return self.rpc.send_request('/in_peers', in_peers)
|
||||||
|
|
||||||
|
def update(self, command, path = None):
|
||||||
|
update = {
|
||||||
|
'command': command,
|
||||||
|
'path': path,
|
||||||
|
}
|
||||||
|
return self.rpc.send_request('/update', update)
|
||||||
|
|
||||||
|
def get_block_count(self):
|
||||||
|
get_block_count = {
|
||||||
|
'method': 'get_block_count',
|
||||||
|
'params': {
|
||||||
|
},
|
||||||
|
'jsonrpc': '2.0',
|
||||||
|
'id': '0'
|
||||||
|
}
|
||||||
|
return self.rpc.send_json_rpc_request(get_block_count)
|
||||||
|
getblockcount = get_block_count
|
||||||
|
|
||||||
|
def get_block_hash(self, height):
|
||||||
|
get_block_hash = {
|
||||||
|
'method': 'get_block_hash',
|
||||||
|
'params': [height],
|
||||||
|
'jsonrpc': '2.0',
|
||||||
|
'id': '0'
|
||||||
|
}
|
||||||
|
return self.rpc.send_json_rpc_request(get_block_hash)
|
||||||
|
on_get_block_hash = get_block_hash
|
||||||
|
on_getblockhash = get_block_hash
|
||||||
|
|
||||||
|
def relay_tx(self, txids = []):
|
||||||
|
relay_tx = {
|
||||||
|
'method': 'relay_tx',
|
||||||
|
'params': {
|
||||||
|
'txids': txids,
|
||||||
|
},
|
||||||
|
'jsonrpc': '2.0',
|
||||||
|
'id': '0'
|
||||||
|
}
|
||||||
|
return self.rpc.send_json_rpc_request(relay_tx)
|
||||||
|
|
||||||
|
def sync_info(self):
|
||||||
|
sync_info = {
|
||||||
|
'method': 'sync_info',
|
||||||
|
'params': {
|
||||||
|
},
|
||||||
|
'jsonrpc': '2.0',
|
||||||
|
'id': '0'
|
||||||
|
}
|
||||||
|
return self.rpc.send_json_rpc_request(sync_info)
|
||||||
|
|
||||||
|
def get_txpool_backlog(self):
|
||||||
|
get_txpool_backlog = {
|
||||||
|
'method': 'get_txpool_backlog',
|
||||||
|
'params': {
|
||||||
|
},
|
||||||
|
'jsonrpc': '2.0',
|
||||||
|
'id': '0'
|
||||||
|
}
|
||||||
|
return self.rpc.send_json_rpc_request(get_txpool_backlog)
|
||||||
|
|
||||||
|
def prune_blockchain(self, check = False):
|
||||||
|
prune_blockchain = {
|
||||||
|
'method': 'prune_blockchain',
|
||||||
|
'params': {
|
||||||
|
'check': check,
|
||||||
|
},
|
||||||
|
'jsonrpc': '2.0',
|
||||||
|
'id': '0'
|
||||||
|
}
|
||||||
|
return self.rpc.send_json_rpc_request(prune_blockchain)
|
||||||
|
|
||||||
|
def get_block_rate(self, seconds = [3600]):
|
||||||
|
get_block_rate = {
|
||||||
|
'method': 'get_block_rate',
|
||||||
|
'params': {
|
||||||
|
'seconds': seconds,
|
||||||
|
},
|
||||||
|
'jsonrpc': '2.0',
|
||||||
|
'id': '0'
|
||||||
|
}
|
||||||
|
return self.rpc.send_json_rpc_request(get_block_rate)
|
||||||
|
|
|
@ -152,6 +152,7 @@ class Wallet(object):
|
||||||
'id': '0'
|
'id': '0'
|
||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(get_balance)
|
return self.rpc.send_json_rpc_request(get_balance)
|
||||||
|
getbalance = get_balance
|
||||||
|
|
||||||
def sweep_dust(self, get_tx_keys = True, do_not_relay = False, get_tx_hex = False, get_tx_metadata = False):
|
def sweep_dust(self, get_tx_keys = True, do_not_relay = False, get_tx_hex = False, get_tx_metadata = False):
|
||||||
sweep_dust = {
|
sweep_dust = {
|
||||||
|
@ -166,6 +167,7 @@ class Wallet(object):
|
||||||
'id': '0'
|
'id': '0'
|
||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(sweep_dust)
|
return self.rpc.send_json_rpc_request(sweep_dust)
|
||||||
|
sweep_unmixable = sweep_dust
|
||||||
|
|
||||||
def sweep_all(self, address = '', account_index = 0, subaddr_indices = [], priority = 0, ring_size = 0, outputs = 1, unlock_time = 0, payment_id = '', get_tx_keys = False, below_amount = 0, do_not_relay = False, get_tx_hex = False, get_tx_metadata = False):
|
def sweep_all(self, address = '', account_index = 0, subaddr_indices = [], priority = 0, ring_size = 0, outputs = 1, unlock_time = 0, payment_id = '', get_tx_keys = False, below_amount = 0, do_not_relay = False, get_tx_hex = False, get_tx_metadata = False):
|
||||||
sweep_all = {
|
sweep_all = {
|
||||||
|
@ -222,6 +224,7 @@ class Wallet(object):
|
||||||
'id': '0'
|
'id': '0'
|
||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(get_address)
|
return self.rpc.send_json_rpc_request(get_address)
|
||||||
|
getaddress = get_address
|
||||||
|
|
||||||
def create_account(self, label = ""):
|
def create_account(self, label = ""):
|
||||||
create_account = {
|
create_account = {
|
||||||
|
@ -733,6 +736,7 @@ class Wallet(object):
|
||||||
'id': '0'
|
'id': '0'
|
||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(get_height)
|
return self.rpc.send_json_rpc_request(get_height)
|
||||||
|
getheight = get_height
|
||||||
|
|
||||||
def relay_tx(self, hex_):
|
def relay_tx(self, hex_):
|
||||||
relay_tx = {
|
relay_tx = {
|
||||||
|
|
Loading…
Reference in a new issue