#!/usr/bin/env python3
# Copyright (c) 2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Tests some generic aspects of the RPC interface."""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal

class RPCInterfaceTest(BitcoinTestFramework):
    def set_test_params(self):
        self.num_nodes = 1
        self.setup_clean_chain = True

    def test_batch_request(self):
        self.log.info("Testing basic JSON-RPC batch request...")

        results = self.nodes[0].batch([
            # A basic request that will work fine.
            {"method": "getblockcount", "id": 1},
            # Request that will fail.  The whole batch request should still
            # work fine.
            {"method": "invalidmethod", "id": 2},
            # Another call that should succeed.
            {"method": "getbestblockhash", "id": 3},
        ])

        result_by_id = {}
        for res in results:
            result_by_id[res["id"]] = res

        assert_equal(result_by_id[1]['error'], None)
        assert_equal(result_by_id[1]['result'], 0)

        assert_equal(result_by_id[2]['error']['code'], -32601)
        assert_equal(result_by_id[2]['result'], None)

        assert_equal(result_by_id[3]['error'], None)
        assert result_by_id[3]['result'] is not None

    def run_test(self):
        self.test_batch_request()


if __name__ == '__main__':
    RPCInterfaceTest().main()

@@ -365,16 +365,46 @@
 rt_equal
+, assert_greater_than_or_equal
 %0A%0Aclass 
@@ -540,16 +540,353 @@
 = True%0A%0A
+    def test_getrpcinfo(self):%0A        self.log.info(%22Testing getrpcinfo...%22)%0A%0A        info = self.nodes%5B0%5D.getrpcinfo()%0A        assert_equal(len(info%5B'active_commands'%5D), 1)%0A%0A        command = info%5B'active_commands'%5D%5B0%5D%0A        assert_equal(command%5B'method'%5D, 'getrpcinfo')%0A        assert_greater_than_or_equal(command%5B'duration'%5D, 0)%0A%0A
     def 
@@ -1825,32 +1825,63 @@
 run_test(self):%0A
+        self.test_getrpcinfo()%0A
         self.tes

Add tests for getrpcinfo