Skip to content

Commit fa493fa

Browse files
author
MarcoFalke
committed
test: Use wallet_dir lambda in wallet_multiwallet test where possible
Seems odd to hardcode all parent directory names in the path for no good reason. Also, add wallet_path property to TestNode. Also, rework wallet_backup.py test for scripted-diff in the next commit.
1 parent d1ae967 commit fa493fa

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

test/functional/test_framework/test_node.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ def chain_path(self) -> Path:
413413
def debug_log_path(self) -> Path:
414414
return self.chain_path / 'debug.log'
415415

416+
@property
417+
def wallets_path(self) -> Path:
418+
return self.chain_path / "wallets"
419+
416420
def debug_log_bytes(self) -> int:
417421
with open(self.debug_log_path, encoding='utf-8') as dl:
418422
dl.seek(0, 2)

test/functional/wallet_backup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def run_test(self):
249249
# Backup to source wallet file must fail
250250
sourcePaths = [
251251
os.path.join(self.nodes[0].datadir, self.chain, 'wallets', self.default_wallet_name, self.wallet_data_filename),
252-
os.path.join(self.nodes[0].datadir, self.chain, '.', 'wallets', self.default_wallet_name, self.wallet_data_filename),
252+
os.path.join(self.nodes[0].datadir, self.chain, 'wallets', '.', self.default_wallet_name, self.wallet_data_filename),
253253
os.path.join(self.nodes[0].datadir, self.chain, 'wallets', self.default_wallet_name),
254254
os.path.join(self.nodes[0].datadir, self.chain, 'wallets')]
255255

test/functional/wallet_multiwallet.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,15 @@ def wallet_file(name):
299299
assert_equal(set(self.nodes[0].listwallets()), set(wallet_names))
300300

301301
# Fail to load if wallet doesn't exist
302-
path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "wallets")
302+
path = wallet_dir("wallets")
303303
assert_raises_rpc_error(-18, "Wallet file verification failed. Failed to load database path '{}'. Path does not exist.".format(path), self.nodes[0].loadwallet, 'wallets')
304304

305305
# Fail to load duplicate wallets
306306
assert_raises_rpc_error(-35, "Wallet \"w1\" is already loaded.", self.nodes[0].loadwallet, wallet_names[0])
307307
if not self.options.descriptors:
308308
# This tests the default wallet that BDB makes, so SQLite wallet doesn't need to test this
309309
# Fail to load duplicate wallets by different ways (directory and filepath)
310-
path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "wallet.dat")
310+
path = wallet_dir("wallet.dat")
311311
assert_raises_rpc_error(-35, "Wallet file verification failed. Refusing to load database. Data file '{}' is already loaded.".format(path), self.nodes[0].loadwallet, 'wallet.dat')
312312

313313
# Only BDB doesn't open duplicate wallet files. SQLite does not have this limitation. While this may be desired in the future, it is not necessary
@@ -322,13 +322,13 @@ def wallet_file(name):
322322

323323
# Fail to load if a directory is specified that doesn't contain a wallet
324324
os.mkdir(wallet_dir('empty_wallet_dir'))
325-
path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "empty_wallet_dir")
325+
path = wallet_dir("empty_wallet_dir")
326326
assert_raises_rpc_error(-18, "Wallet file verification failed. Failed to load database path '{}'. Data is not in recognized format.".format(path), self.nodes[0].loadwallet, 'empty_wallet_dir')
327327

328328
self.log.info("Test dynamic wallet creation.")
329329

330330
# Fail to create a wallet if it already exists.
331-
path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "w2")
331+
path = wallet_dir("w2")
332332
assert_raises_rpc_error(-4, "Failed to create database path '{}'. Database already exists.".format(path), self.nodes[0].createwallet, 'w2')
333333

334334
# Successfully create a wallet with a new name

0 commit comments

Comments
 (0)