Skip to content

Commit 3bf2b3a

Browse files
committed
test: Split tool_wallet.py test into subtests
as per Marco Falke review suggestion.
1 parent 1eb13f0 commit 3bf2b3a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

test/functional/tool_wallet.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def assert_tool_output(self, output, *args):
3737
assert_equal(stderr, '')
3838
assert_equal(stdout, output)
3939

40-
def run_test(self):
40+
def test_invalid_tool_commands_and_args(self):
4141
self.log.info('Testing that various invalid commands raise with specific error messages')
4242
self.assert_raises_tool_error('Invalid command: foo', 'foo')
4343
# `bitcoin-wallet help` raises an error. Use `bitcoin-wallet -help`.
@@ -47,6 +47,7 @@ def run_test(self):
4747
self.assert_raises_tool_error('Error loading wallet.dat. Is wallet being used by other process?', '-wallet=wallet.dat', 'info')
4848
self.assert_raises_tool_error('Error: no wallet file at nonexistent.dat', '-wallet=nonexistent.dat', 'info')
4949

50+
def test_tool_wallet_info(self):
5051
# Stop the node to close the wallet to call the info command.
5152
self.stop_node(0)
5253
self.log.info('Calling wallet tool info, testing output')
@@ -61,7 +62,11 @@ def run_test(self):
6162
''')
6263
self.assert_tool_output(out, '-wallet=wallet.dat', 'info')
6364

64-
# Mutate wallet to verify info command output changes accordingly.
65+
def test_tool_wallet_info_after_transaction(self):
66+
"""
67+
Mutate the wallet with a transaction to verify that the info command
68+
output changes accordingly.
69+
"""
6570
self.start_node(0)
6671
self.log.info('Generating transaction to mutate wallet')
6772
self.nodes[0].generate(1)
@@ -79,6 +84,7 @@ def run_test(self):
7984
''')
8085
self.assert_tool_output(out, '-wallet=wallet.dat', 'info')
8186

87+
def test_tool_wallet_create_on_existing_wallet(self):
8288
self.log.info('Calling wallet tool create on an existing wallet, testing output')
8389
out = textwrap.dedent('''\
8490
Topping up keypool...
@@ -92,6 +98,7 @@ def run_test(self):
9298
''')
9399
self.assert_tool_output(out, '-wallet=foo', 'create')
94100

101+
def test_getwalletinfo_on_different_wallet(self):
95102
self.log.info('Starting node with arg -wallet=foo')
96103
self.start_node(0, ['-wallet=foo'])
97104

@@ -104,5 +111,14 @@ def run_test(self):
104111
assert_equal(1000, out['keypoolsize_hd_internal'])
105112
assert_equal(True, 'hdseedid' in out)
106113

114+
def run_test(self):
115+
self.test_invalid_tool_commands_and_args()
116+
# Warning: The following tests are order-dependent.
117+
self.test_tool_wallet_info()
118+
self.test_tool_wallet_info_after_transaction()
119+
self.test_tool_wallet_create_on_existing_wallet()
120+
self.test_getwalletinfo_on_different_wallet()
121+
122+
107123
if __name__ == '__main__':
108124
ToolWalletTest().main()

0 commit comments

Comments
 (0)