1
1
#!/usr/bin/env python3
2
- # Copyright (c) 2018 The Bitcoin Core developers
2
+ # Copyright (c) 2018-2019 The Bitcoin Core developers
3
3
# Distributed under the MIT software license, see the accompanying
4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
"""Test bitcoin-wallet."""
6
+
6
7
import subprocess
7
8
import textwrap
8
9
@@ -37,18 +38,18 @@ def assert_tool_output(self, output, *args):
37
38
assert_equal (stdout , output )
38
39
39
40
def run_test (self ):
40
-
41
+ self . log . info ( 'Testing that various invalid commands raise with specific error messages' )
41
42
self .assert_raises_tool_error ('Invalid command: foo' , 'foo' )
42
- # `bitcoin-wallet help` is an error. Use `bitcoin-wallet -help`
43
+ # `bitcoin-wallet help` raises an error. Use `bitcoin-wallet -help`.
43
44
self .assert_raises_tool_error ('Invalid command: help' , 'help' )
44
45
self .assert_raises_tool_error ('Error: two methods provided (info and create). Only one method should be provided.' , 'info' , 'create' )
45
46
self .assert_raises_tool_error ('Error parsing command line arguments: Invalid parameter -foo' , '-foo' )
46
47
self .assert_raises_tool_error ('Error loading wallet.dat. Is wallet being used by other process?' , '-wallet=wallet.dat' , 'info' )
47
48
self .assert_raises_tool_error ('Error: no wallet file at nonexistent.dat' , '-wallet=nonexistent.dat' , 'info' )
48
49
49
- # stop the node to close the wallet to call info command
50
+ # Stop the node to close the wallet to call the info command.
50
51
self .stop_node (0 )
51
-
52
+ self . log . info ( 'Calling wallet tool info, testing output' )
52
53
out = textwrap .dedent ('''\
53
54
Wallet info
54
55
===========
@@ -60,11 +61,13 @@ def run_test(self):
60
61
''' )
61
62
self .assert_tool_output (out , '-wallet=wallet.dat' , 'info' )
62
63
63
- # mutate the wallet to check the info command output changes accordingly
64
+ # Mutate wallet to verify info command output changes accordingly.
64
65
self .start_node (0 )
66
+ self .log .info ('Generating transaction to mutate wallet' )
65
67
self .nodes [0 ].generate (1 )
66
68
self .stop_node (0 )
67
69
70
+ self .log .info ('Calling wallet tool info after generating a transaction, testing output' )
68
71
out = textwrap .dedent ('''\
69
72
Wallet info
70
73
===========
@@ -76,6 +79,7 @@ def run_test(self):
76
79
''' )
77
80
self .assert_tool_output (out , '-wallet=wallet.dat' , 'info' )
78
81
82
+ self .log .info ('Calling wallet tool create on an existing wallet, testing output' )
79
83
out = textwrap .dedent ('''\
80
84
Topping up keypool...
81
85
Wallet info
@@ -88,7 +92,10 @@ def run_test(self):
88
92
''' )
89
93
self .assert_tool_output (out , '-wallet=foo' , 'create' )
90
94
95
+ self .log .info ('Starting node with arg -wallet=foo' )
91
96
self .start_node (0 , ['-wallet=foo' ])
97
+
98
+ self .log .info ('Calling getwalletinfo on a different wallet ("foo"), testing output' )
92
99
out = self .nodes [0 ].getwalletinfo ()
93
100
self .stop_node (0 )
94
101
0 commit comments