Skip to content

Commit f0aa8ae

Browse files
committed
test: add rpc_generate functional test
1 parent 92d94ff commit f0aa8ae

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

test/functional/rpc_generate.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2020 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Test generate RPC."""
6+
7+
from test_framework.test_framework import BitcoinTestFramework
8+
from test_framework.util import (
9+
assert_equal,
10+
assert_raises_rpc_error,
11+
)
12+
13+
14+
class RPCGenerateTest(BitcoinTestFramework):
15+
def set_test_params(self):
16+
self.num_nodes = 1
17+
18+
def run_test(self):
19+
message = (
20+
"generate ( nblocks maxtries ) has been replaced by the -generate "
21+
"cli option. Refer to -help for more information."
22+
)
23+
24+
self.log.info("Test rpc generate raises with message to use cli option")
25+
assert_raises_rpc_error(-32601, message, self.nodes[0].rpc.generate)
26+
27+
self.log.info("Test rpc generate help prints message to use cli option")
28+
assert_equal(message, self.nodes[0].help("generate"))
29+
30+
self.log.info("Test rpc generate is a hidden command not discoverable in general help")
31+
assert message not in self.nodes[0].help()
32+
33+
34+
if __name__ == "__main__":
35+
RPCGenerateTest().main()

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@
193193
'p2p_eviction.py',
194194
'rpc_signmessage.py',
195195
'rpc_generateblock.py',
196+
'rpc_generate.py',
196197
'wallet_balance.py',
197198
'feature_nulldummy.py',
198199
'mempool_accept.py',

0 commit comments

Comments
 (0)