6
6
from test_framework .test_framework import BitcoinTestFramework
7
7
from test_framework .util import assert_equal , assert_raises_process_error , get_auth_cookie
8
8
9
+ # The block reward of coinbaseoutput.nValue (50) BTC/block matures after
10
+ # COINBASE_MATURITY (100) blocks. Therefore, after mining 101 blocks we expect
11
+ # node 0 to have a balance of (BLOCKS - COINBASE_MATURITY) * 50 BTC/block.
12
+ BLOCKS = 101
13
+ BALANCE = (BLOCKS - 100 ) * 50
14
+
9
15
class TestBitcoinCli (BitcoinTestFramework ):
10
16
11
17
def set_test_params (self ):
@@ -17,6 +23,7 @@ def skip_test_if_missing_module(self):
17
23
18
24
def run_test (self ):
19
25
"""Main test logic"""
26
+ self .nodes [0 ].generate (BLOCKS )
20
27
21
28
cli_response = self .nodes [0 ].cli ("-version" ).send_cli ()
22
29
assert "{} RPC client version" .format (self .config ['environment' ]['PACKAGE_NAME' ]) in cli_response
@@ -35,7 +42,7 @@ def run_test(self):
35
42
user , password = get_auth_cookie (self .nodes [0 ].datadir , self .chain )
36
43
37
44
self .log .info ("Test -stdinrpcpass option" )
38
- assert_equal (0 , self .nodes [0 ].cli ('-rpcuser=%s' % user , '-stdinrpcpass' , input = password ).getblockcount ())
45
+ assert_equal (BLOCKS , self .nodes [0 ].cli ('-rpcuser=%s' % user , '-stdinrpcpass' , input = password ).getblockcount ())
39
46
assert_raises_process_error (1 , "Incorrect rpcuser or rpcpassword" , self .nodes [0 ].cli ('-rpcuser=%s' % user , '-stdinrpcpass' , input = "foo" ).echo )
40
47
41
48
self .log .info ("Test -stdin and -stdinrpcpass" )
@@ -51,10 +58,8 @@ def run_test(self):
51
58
self .log .info ("Make sure that -getinfo with arguments fails" )
52
59
assert_raises_process_error (1 , "-getinfo takes no arguments" , self .nodes [0 ].cli ('-getinfo' ).help )
53
60
54
- self .log .info ("Compare responses from `bitcoin-cli - getinfo` and the RPCs data is retrieved from. " )
61
+ self .log .info ("Test that - getinfo returns the expected network and blockchain info " )
55
62
cli_get_info = self .nodes [0 ].cli ('-getinfo' ).send_cli ()
56
- if self .is_wallet_compiled ():
57
- wallet_info = self .nodes [0 ].getwalletinfo ()
58
63
network_info = self .nodes [0 ].getnetworkinfo ()
59
64
blockchain_info = self .nodes [0 ].getblockchaininfo ()
60
65
@@ -66,11 +71,15 @@ def run_test(self):
66
71
assert_equal (cli_get_info ['difficulty' ], blockchain_info ['difficulty' ])
67
72
assert_equal (cli_get_info ['chain' ], blockchain_info ['chain' ])
68
73
if self .is_wallet_compiled ():
69
- assert_equal (cli_get_info ['balance' ], wallet_info ['balance' ])
74
+ self .log .info ("Test that -getinfo returns the expected wallet info" )
75
+ assert_equal (cli_get_info ['balance' ], BALANCE )
76
+ wallet_info = self .nodes [0 ].getwalletinfo ()
70
77
assert_equal (cli_get_info ['keypoolsize' ], wallet_info ['keypoolsize' ])
71
78
assert_equal (cli_get_info ['paytxfee' ], wallet_info ['paytxfee' ])
72
79
assert_equal (cli_get_info ['relayfee' ], network_info ['relayfee' ])
73
80
# unlocked_until is not tested because the wallet is not encrypted
81
+ else :
82
+ self .log .info ("*** Wallet not compiled; -getinfo wallet tests skipped" )
74
83
75
84
76
85
if __name__ == '__main__' :
0 commit comments