test: Split tool_wallet.py test into subtests
as per Marco Falke review suggestion.
This commit is contained in:
parent
1eb13f09a9
commit
3bf2b3a37b
1 changed files with 18 additions and 2 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue