aboutsummaryrefslogtreecommitdiff
path: root/test/functional/tool_wallet.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/tool_wallet.py')
-rwxr-xr-xtest/functional/tool_wallet.py90
1 files changed, 54 insertions, 36 deletions
diff --git a/test/functional/tool_wallet.py b/test/functional/tool_wallet.py
index 3f25c58851..35576f00ea 100755
--- a/test/functional/tool_wallet.py
+++ b/test/functional/tool_wallet.py
@@ -28,8 +28,11 @@ class ToolWalletTest(BitcoinTestFramework):
def bitcoin_wallet_process(self, *args):
binary = self.config["environment"]["BUILDDIR"] + '/src/bitcoin-wallet' + self.config["environment"]["EXEEXT"]
- args = ['-datadir={}'.format(self.nodes[0].datadir), '-chain=%s' % self.chain] + list(args)
- return subprocess.Popen([binary] + args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+ default_args = ['-datadir={}'.format(self.nodes[0].datadir), '-chain=%s' % self.chain]
+ if self.options.descriptors:
+ default_args.append('-descriptors')
+
+ return subprocess.Popen([binary] + default_args + list(args), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
def assert_raises_tool_error(self, error, *args):
p = self.bitcoin_wallet_process(*args)
@@ -63,6 +66,36 @@ class ToolWalletTest(BitcoinTestFramework):
result = 'unchanged' if new == old else 'increased!'
self.log.debug('Wallet file timestamp {}'.format(result))
+ def get_expected_info_output(self, name="", transactions=0, keypool=2, address=0):
+ wallet_name = self.default_wallet_name if name == "" else name
+ output_types = 3 # p2pkh, p2sh, segwit
+ if self.options.descriptors:
+ return textwrap.dedent('''\
+ Wallet info
+ ===========
+ Name: %s
+ Format: sqlite
+ Descriptors: yes
+ Encrypted: no
+ HD (hd seed available): yes
+ Keypool Size: %d
+ Transactions: %d
+ Address Book: %d
+ ''' % (wallet_name, keypool * output_types, transactions, address))
+ else:
+ return textwrap.dedent('''\
+ Wallet info
+ ===========
+ Name: %s
+ Format: bdb
+ Descriptors: no
+ Encrypted: no
+ HD (hd seed available): yes
+ Keypool Size: %d
+ Transactions: %d
+ Address Book: %d
+ ''' % (wallet_name, keypool, transactions, address * output_types))
+
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')
@@ -71,8 +104,11 @@ class ToolWalletTest(BitcoinTestFramework):
self.assert_raises_tool_error('Error: two methods provided (info and create). Only one method should be provided.', 'info', 'create')
self.assert_raises_tool_error('Error parsing command line arguments: Invalid parameter -foo', '-foo')
locked_dir = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets")
+ error = 'Error initializing wallet database environment "{}"!'.format(locked_dir)
+ if self.options.descriptors:
+ error = "SQLiteDatabase: Unable to obtain an exclusive lock on the database, is it being used by another bitcoind?"
self.assert_raises_tool_error(
- 'Error initializing wallet database environment "{}"!'.format(locked_dir),
+ error,
'-wallet=' + self.default_wallet_name,
'info',
)
@@ -95,15 +131,7 @@ class ToolWalletTest(BitcoinTestFramework):
# shasum_before = self.wallet_shasum()
timestamp_before = self.wallet_timestamp()
self.log.debug('Wallet file timestamp before calling info: {}'.format(timestamp_before))
- out = textwrap.dedent('''\
- Wallet info
- ===========
- Encrypted: no
- HD (hd seed available): yes
- Keypool Size: 2
- Transactions: 0
- Address Book: 3
- ''')
+ out = self.get_expected_info_output(address=1)
self.assert_tool_output(out, '-wallet=' + self.default_wallet_name, 'info')
timestamp_after = self.wallet_timestamp()
self.log.debug('Wallet file timestamp after calling info: {}'.format(timestamp_after))
@@ -134,15 +162,7 @@ class ToolWalletTest(BitcoinTestFramework):
shasum_before = self.wallet_shasum()
timestamp_before = self.wallet_timestamp()
self.log.debug('Wallet file timestamp before calling info: {}'.format(timestamp_before))
- out = textwrap.dedent('''\
- Wallet info
- ===========
- Encrypted: no
- HD (hd seed available): yes
- Keypool Size: 2
- Transactions: 1
- Address Book: 3
- ''')
+ out = self.get_expected_info_output(transactions=1, address=1)
self.assert_tool_output(out, '-wallet=' + self.default_wallet_name, 'info')
shasum_after = self.wallet_shasum()
timestamp_after = self.wallet_timestamp()
@@ -160,16 +180,7 @@ class ToolWalletTest(BitcoinTestFramework):
shasum_before = self.wallet_shasum()
timestamp_before = self.wallet_timestamp()
self.log.debug('Wallet file timestamp before calling create: {}'.format(timestamp_before))
- out = textwrap.dedent('''\
- Topping up keypool...
- Wallet info
- ===========
- Encrypted: no
- HD (hd seed available): yes
- Keypool Size: 2000
- Transactions: 0
- Address Book: 0
- ''')
+ out = "Topping up keypool...\n" + self.get_expected_info_output(name="foo", keypool=2000)
self.assert_tool_output(out, '-wallet=foo', 'create')
shasum_after = self.wallet_shasum()
timestamp_after = self.wallet_timestamp()
@@ -195,9 +206,13 @@ class ToolWalletTest(BitcoinTestFramework):
self.log.debug('Wallet file timestamp after calling getwalletinfo: {}'.format(timestamp_after))
assert_equal(0, out['txcount'])
- assert_equal(1000, out['keypoolsize'])
- assert_equal(1000, out['keypoolsize_hd_internal'])
- assert_equal(True, 'hdseedid' in out)
+ if not self.options.descriptors:
+ assert_equal(1000, out['keypoolsize'])
+ assert_equal(1000, out['keypoolsize_hd_internal'])
+ assert_equal(True, 'hdseedid' in out)
+ else:
+ assert_equal(3000, out['keypoolsize'])
+ assert_equal(3000, out['keypoolsize_hd_internal'])
self.log_wallet_timestamp_comparison(timestamp_before, timestamp_after)
assert_equal(timestamp_before, timestamp_after)
@@ -207,7 +222,8 @@ class ToolWalletTest(BitcoinTestFramework):
def test_salvage(self):
# TODO: Check salvage actually salvages and doesn't break things. https://github.com/bitcoin/bitcoin/issues/7463
self.log.info('Check salvage')
- self.start_node(0, ['-wallet=salvage'])
+ self.start_node(0)
+ self.nodes[0].createwallet("salvage")
self.stop_node(0)
self.assert_tool_output('', '-wallet=salvage', 'salvage')
@@ -220,7 +236,9 @@ class ToolWalletTest(BitcoinTestFramework):
self.test_tool_wallet_info_after_transaction()
self.test_tool_wallet_create_on_existing_wallet()
self.test_getwalletinfo_on_different_wallet()
- self.test_salvage()
+ if not self.options.descriptors:
+ # Salvage is a legacy wallet only thing
+ self.test_salvage()
if __name__ == '__main__':
ToolWalletTest().main()