Changeset View
Changeset View
Standalone View
Standalone View
test/functional/interface_rpc.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2018-2019 The Bitcoin Core developers | # Copyright (c) 2018-2019 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Tests some generic aspects of the RPC interface.""" | """Tests some generic aspects of the RPC interface.""" | ||||
import os | |||||
from test_framework.authproxy import JSONRPCException | from test_framework.authproxy import JSONRPCException | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import assert_equal, assert_greater_than_or_equal | from test_framework.util import assert_equal, assert_greater_than_or_equal | ||||
def expect_http_status(expected_http_status, expected_rpc_code, | def expect_http_status(expected_http_status, expected_rpc_code, | ||||
fcn, *args): | fcn, *args): | ||||
try: | try: | ||||
Show All 14 Lines | def test_getrpcinfo(self): | ||||
self.log.info("Testing getrpcinfo...") | self.log.info("Testing getrpcinfo...") | ||||
info = self.nodes[0].getrpcinfo() | info = self.nodes[0].getrpcinfo() | ||||
assert_equal(len(info['active_commands']), 1) | assert_equal(len(info['active_commands']), 1) | ||||
command = info['active_commands'][0] | command = info['active_commands'][0] | ||||
assert_equal(command['method'], 'getrpcinfo') | assert_equal(command['method'], 'getrpcinfo') | ||||
assert_greater_than_or_equal(command['duration'], 0) | assert_greater_than_or_equal(command['duration'], 0) | ||||
assert_equal( | |||||
info['logpath'], | |||||
os.path.join( | |||||
self.nodes[0].datadir, | |||||
'regtest', | |||||
'debug.log')) | |||||
def test_batch_request(self): | def test_batch_request(self): | ||||
self.log.info("Testing basic JSON-RPC batch request...") | self.log.info("Testing basic JSON-RPC batch request...") | ||||
results = self.nodes[0].batch([ | results = self.nodes[0].batch([ | ||||
# A basic request that will work fine. | # A basic request that will work fine. | ||||
{"method": "getblockcount", "id": 1}, | {"method": "getblockcount", "id": 1}, | ||||
# Request that will fail. The whole batch request should still | # Request that will fail. The whole batch request should still | ||||
Show All 33 Lines |