@@ -25,15 +25,6 @@ def run_test(self):
25
25
"""Main test logic"""
26
26
self .nodes [0 ].generate (BLOCKS )
27
27
28
- cli_response = self .nodes [0 ].cli ("-version" ).send_cli ()
29
- assert "{} RPC client version" .format (self .config ['environment' ]['PACKAGE_NAME' ]) in cli_response
30
-
31
- self .log .info ("Compare responses from getwalletinfo RPC and `bitcoin-cli getwalletinfo`" )
32
- if self .is_wallet_compiled ():
33
- cli_response = self .nodes [0 ].cli .getwalletinfo ()
34
- rpc_response = self .nodes [0 ].getwalletinfo ()
35
- assert_equal (cli_response , rpc_response )
36
-
37
28
self .log .info ("Compare responses from getblockchaininfo RPC and `bitcoin-cli getblockchaininfo`" )
38
29
cli_response = self .nodes [0 ].cli .getblockchaininfo ()
39
30
rpc_response = self .nodes [0 ].getblockchaininfo ()
@@ -55,31 +46,50 @@ def run_test(self):
55
46
self .log .info ("Test connecting with non-existing RPC cookie file" )
56
47
assert_raises_process_error (1 , "Could not locate RPC credentials" , self .nodes [0 ].cli ('-rpccookiefile=does-not-exist' , '-rpcpassword=' ).echo )
57
48
58
- self .log .info ("Make sure that -getinfo with arguments fails" )
49
+ self .log .info ("Test -getinfo with arguments fails" )
59
50
assert_raises_process_error (1 , "-getinfo takes no arguments" , self .nodes [0 ].cli ('-getinfo' ).help )
60
51
61
- self .log .info ("Test that -getinfo returns the expected network and blockchain info" )
52
+ self .log .info ("Test -getinfo returns expected network and blockchain info" )
53
+ if self .is_wallet_compiled ():
54
+ self .nodes [0 ].encryptwallet (password )
62
55
cli_get_info = self .nodes [0 ].cli ('-getinfo' ).send_cli ()
63
56
network_info = self .nodes [0 ].getnetworkinfo ()
64
57
blockchain_info = self .nodes [0 ].getblockchaininfo ()
65
-
66
58
assert_equal (cli_get_info ['version' ], network_info ['version' ])
67
59
assert_equal (cli_get_info ['blocks' ], blockchain_info ['blocks' ])
60
+ assert_equal (cli_get_info ['headers' ], blockchain_info ['headers' ])
68
61
assert_equal (cli_get_info ['timeoffset' ], network_info ['timeoffset' ])
69
62
assert_equal (cli_get_info ['connections' ], network_info ['connections' ])
70
63
assert_equal (cli_get_info ['proxy' ], network_info ['networks' ][0 ]['proxy' ])
71
64
assert_equal (cli_get_info ['difficulty' ], blockchain_info ['difficulty' ])
72
65
assert_equal (cli_get_info ['chain' ], blockchain_info ['chain' ])
66
+
73
67
if self .is_wallet_compiled ():
74
- self .log .info ("Test that -getinfo returns the expected wallet info" )
68
+ self .log .info ("Test -getinfo and bitcoin-cli getwalletinfo return expected wallet info" )
75
69
assert_equal (cli_get_info ['balance' ], BALANCE )
76
70
wallet_info = self .nodes [0 ].getwalletinfo ()
77
71
assert_equal (cli_get_info ['keypoolsize' ], wallet_info ['keypoolsize' ])
72
+ assert_equal (cli_get_info ['unlocked_until' ], wallet_info ['unlocked_until' ])
78
73
assert_equal (cli_get_info ['paytxfee' ], wallet_info ['paytxfee' ])
79
74
assert_equal (cli_get_info ['relayfee' ], network_info ['relayfee' ])
80
- # unlocked_until is not tested because the wallet is not encrypted
75
+ assert_equal ( self . nodes [ 0 ]. cli . getwalletinfo (), wallet_info )
81
76
else :
82
- self .log .info ("*** Wallet not compiled; -getinfo wallet tests skipped" )
77
+ self .log .info ("*** Wallet not compiled; cli getwalletinfo and -getinfo wallet tests skipped" )
78
+
79
+ self .stop_node (0 )
80
+
81
+ self .log .info ("Test -version with node stopped" )
82
+ cli_response = self .nodes [0 ].cli ("-version" ).send_cli ()
83
+ assert "{} RPC client version" .format (self .config ['environment' ]['PACKAGE_NAME' ]) in cli_response
84
+
85
+ self .log .info ("Test -rpcwait option waits for RPC connection instead of failing" )
86
+ # Start node without RPC connection.
87
+ self .nodes [0 ].start ()
88
+ # Verify failure without -rpcwait.
89
+ assert_raises_process_error (1 , "Could not connect to the server" , self .nodes [0 ].cli ('getblockcount' ).echo )
90
+ # Verify success using -rpcwait.
91
+ assert_equal (BLOCKS , self .nodes [0 ].cli ('-rpcwait' , 'getblockcount' ).send_cli ())
92
+ self .nodes [0 ].wait_for_rpc_connection ()
83
93
84
94
85
95
if __name__ == '__main__' :
0 commit comments