From f0aa8aeea5a183ea44a877255d12db7732f2e0a8 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Mon, 6 Jul 2020 05:39:40 +0200 Subject: [PATCH] test: add rpc_generate functional test --- test/functional/rpc_generate.py | 35 +++++++++++++++++++++++++++++++++ test/functional/test_runner.py | 1 + 2 files changed, 36 insertions(+) create mode 100755 test/functional/rpc_generate.py diff --git a/test/functional/rpc_generate.py b/test/functional/rpc_generate.py new file mode 100755 index 00000000000..9404f1e25ef --- /dev/null +++ b/test/functional/rpc_generate.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# Copyright (c) 2020 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +"""Test generate RPC.""" + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import ( + assert_equal, + assert_raises_rpc_error, +) + + +class RPCGenerateTest(BitcoinTestFramework): + def set_test_params(self): + self.num_nodes = 1 + + def run_test(self): + message = ( + "generate ( nblocks maxtries ) has been replaced by the -generate " + "cli option. Refer to -help for more information." + ) + + self.log.info("Test rpc generate raises with message to use cli option") + assert_raises_rpc_error(-32601, message, self.nodes[0].rpc.generate) + + self.log.info("Test rpc generate help prints message to use cli option") + assert_equal(message, self.nodes[0].help("generate")) + + self.log.info("Test rpc generate is a hidden command not discoverable in general help") + assert message not in self.nodes[0].help() + + +if __name__ == "__main__": + RPCGenerateTest().main() diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 86e9ab3fe2b..97c30b2b83f 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -193,6 +193,7 @@ BASE_SCRIPTS = [ 'p2p_eviction.py', 'rpc_signmessage.py', 'rpc_generateblock.py', + 'rpc_generate.py', 'wallet_balance.py', 'feature_nulldummy.py', 'mempool_accept.py',