mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
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.
This commit is contained in:
parent
d1ae96755a
commit
fa493fadfb
3 changed files with 9 additions and 5 deletions
|
@ -413,6 +413,10 @@ class TestNode():
|
|||
def debug_log_path(self) -> Path:
|
||||
return self.chain_path / 'debug.log'
|
||||
|
||||
@property
|
||||
def wallets_path(self) -> Path:
|
||||
return self.chain_path / "wallets"
|
||||
|
||||
def debug_log_bytes(self) -> int:
|
||||
with open(self.debug_log_path, encoding='utf-8') as dl:
|
||||
dl.seek(0, 2)
|
||||
|
|
|
@ -249,7 +249,7 @@ class WalletBackupTest(BitcoinTestFramework):
|
|||
# Backup to source wallet file must fail
|
||||
sourcePaths = [
|
||||
os.path.join(self.nodes[0].datadir, self.chain, 'wallets', self.default_wallet_name, self.wallet_data_filename),
|
||||
os.path.join(self.nodes[0].datadir, self.chain, '.', 'wallets', self.default_wallet_name, self.wallet_data_filename),
|
||||
os.path.join(self.nodes[0].datadir, self.chain, 'wallets', '.', self.default_wallet_name, self.wallet_data_filename),
|
||||
os.path.join(self.nodes[0].datadir, self.chain, 'wallets', self.default_wallet_name),
|
||||
os.path.join(self.nodes[0].datadir, self.chain, 'wallets')]
|
||||
|
||||
|
|
|
@ -299,7 +299,7 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||
assert_equal(set(self.nodes[0].listwallets()), set(wallet_names))
|
||||
|
||||
# Fail to load if wallet doesn't exist
|
||||
path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "wallets")
|
||||
path = wallet_dir("wallets")
|
||||
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')
|
||||
|
||||
# Fail to load duplicate wallets
|
||||
|
@ -307,7 +307,7 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||
if not self.options.descriptors:
|
||||
# This tests the default wallet that BDB makes, so SQLite wallet doesn't need to test this
|
||||
# Fail to load duplicate wallets by different ways (directory and filepath)
|
||||
path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "wallet.dat")
|
||||
path = wallet_dir("wallet.dat")
|
||||
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')
|
||||
|
||||
# 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 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||
|
||||
# Fail to load if a directory is specified that doesn't contain a wallet
|
||||
os.mkdir(wallet_dir('empty_wallet_dir'))
|
||||
path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "empty_wallet_dir")
|
||||
path = wallet_dir("empty_wallet_dir")
|
||||
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')
|
||||
|
||||
self.log.info("Test dynamic wallet creation.")
|
||||
|
||||
# Fail to create a wallet if it already exists.
|
||||
path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "w2")
|
||||
path = wallet_dir("w2")
|
||||
assert_raises_rpc_error(-4, "Failed to create database path '{}'. Database already exists.".format(path), self.nodes[0].createwallet, 'w2')
|
||||
|
||||
# Successfully create a wallet with a new name
|
||||
|
|
Loading…
Reference in a new issue