From 3bf2b3a37bbd550491d124b77fd7c1b2a7969f66 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Thu, 27 Jun 2019 15:22:17 +0200 Subject: test: Split tool_wallet.py test into subtests as per Marco Falke review suggestion. --- test/functional/tool_wallet.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'test/functional/tool_wallet.py') diff --git a/test/functional/tool_wallet.py b/test/functional/tool_wallet.py index 66d893f57f..e622c75236 100755 --- a/test/functional/tool_wallet.py +++ b/test/functional/tool_wallet.py @@ -37,7 +37,7 @@ class ToolWalletTest(BitcoinTestFramework): assert_equal(stderr, '') assert_equal(stdout, output) - def run_test(self): + def test_invalid_tool_commands_and_args(self): self.log.info('Testing that various invalid commands raise with specific error messages') self.assert_raises_tool_error('Invalid command: foo', 'foo') # `bitcoin-wallet help` raises an error. Use `bitcoin-wallet -help`. @@ -47,6 +47,7 @@ class ToolWalletTest(BitcoinTestFramework): self.assert_raises_tool_error('Error loading wallet.dat. Is wallet being used by other process?', '-wallet=wallet.dat', 'info') self.assert_raises_tool_error('Error: no wallet file at nonexistent.dat', '-wallet=nonexistent.dat', 'info') + def test_tool_wallet_info(self): # Stop the node to close the wallet to call the info command. self.stop_node(0) self.log.info('Calling wallet tool info, testing output') @@ -61,7 +62,11 @@ class ToolWalletTest(BitcoinTestFramework): ''') self.assert_tool_output(out, '-wallet=wallet.dat', 'info') - # Mutate wallet to verify info command output changes accordingly. + def test_tool_wallet_info_after_transaction(self): + """ + Mutate the wallet with a transaction to verify that the info command + output changes accordingly. + """ self.start_node(0) self.log.info('Generating transaction to mutate wallet') self.nodes[0].generate(1) @@ -79,6 +84,7 @@ class ToolWalletTest(BitcoinTestFramework): ''') self.assert_tool_output(out, '-wallet=wallet.dat', 'info') + def test_tool_wallet_create_on_existing_wallet(self): self.log.info('Calling wallet tool create on an existing wallet, testing output') out = textwrap.dedent('''\ Topping up keypool... @@ -92,6 +98,7 @@ class ToolWalletTest(BitcoinTestFramework): ''') self.assert_tool_output(out, '-wallet=foo', 'create') + def test_getwalletinfo_on_different_wallet(self): self.log.info('Starting node with arg -wallet=foo') self.start_node(0, ['-wallet=foo']) @@ -104,5 +111,14 @@ class ToolWalletTest(BitcoinTestFramework): assert_equal(1000, out['keypoolsize_hd_internal']) assert_equal(True, 'hdseedid' in out) + def run_test(self): + self.test_invalid_tool_commands_and_args() + # Warning: The following tests are order-dependent. + self.test_tool_wallet_info() + self.test_tool_wallet_info_after_transaction() + self.test_tool_wallet_create_on_existing_wallet() + self.test_getwalletinfo_on_different_wallet() + + if __name__ == '__main__': ToolWalletTest().main() -- cgit v1.2.3