aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_backup.py
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-06-20 11:22:03 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-06-21 08:48:34 +0200
commitfa41614a0abc05cbfbf76d6af3a186ab8d79c3f2 (patch)
tree04f5379df0c8d35554dbef5635c8a2d1b7ef9245 /test/functional/wallet_backup.py
parentfa493fadfb0ac73b7c0ee308f6623213702ae6f4 (diff)
downloadbitcoin-fa41614a0abc05cbfbf76d6af3a186ab8d79c3f2.tar.xz
scripted-diff: Use wallets_path and chain_path where possible
Instead of passing the datadir and chain name to os.path.join, just use the existing properties, which are the same. -BEGIN VERIFY SCRIPT- sed -i --regexp-extended 's|\.datadir, self\.chain, .wallets.|.wallets_path|g' $(git grep -l '\.datadir, self\.chain,') sed -i --regexp-extended 's|\.datadir, self\.chain,|.chain_path,|g' $(git grep -l '\.datadir, self\.chain,') -END VERIFY SCRIPT-
Diffstat (limited to 'test/functional/wallet_backup.py')
-rwxr-xr-xtest/functional/wallet_backup.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/test/functional/wallet_backup.py b/test/functional/wallet_backup.py
index daf4cf74cb..fa92ebd436 100755
--- a/test/functional/wallet_backup.py
+++ b/test/functional/wallet_backup.py
@@ -109,16 +109,16 @@ class WalletBackupTest(BitcoinTestFramework):
self.stop_node(2)
def erase_three(self):
- os.remove(os.path.join(self.nodes[0].datadir, self.chain, 'wallets', self.default_wallet_name, self.wallet_data_filename))
- os.remove(os.path.join(self.nodes[1].datadir, self.chain, 'wallets', self.default_wallet_name, self.wallet_data_filename))
- os.remove(os.path.join(self.nodes[2].datadir, self.chain, 'wallets', self.default_wallet_name, self.wallet_data_filename))
+ os.remove(os.path.join(self.nodes[0].wallets_path, self.default_wallet_name, self.wallet_data_filename))
+ os.remove(os.path.join(self.nodes[1].wallets_path, self.default_wallet_name, self.wallet_data_filename))
+ os.remove(os.path.join(self.nodes[2].wallets_path, self.default_wallet_name, self.wallet_data_filename))
def restore_invalid_wallet(self):
node = self.nodes[3]
invalid_wallet_file = os.path.join(self.nodes[0].datadir, 'invalid_wallet_file.bak')
open(invalid_wallet_file, 'a', encoding="utf8").write('invald wallet')
wallet_name = "res0"
- not_created_wallet_file = os.path.join(node.datadir, self.chain, 'wallets', wallet_name)
+ not_created_wallet_file = os.path.join(node.wallets_path, wallet_name)
error_message = "Wallet file verification failed. Failed to load database path '{}'. Data is not in recognized format.".format(not_created_wallet_file)
assert_raises_rpc_error(-18, error_message, node.restorewallet, wallet_name, invalid_wallet_file)
assert not os.path.exists(not_created_wallet_file)
@@ -128,14 +128,14 @@ class WalletBackupTest(BitcoinTestFramework):
nonexistent_wallet_file = os.path.join(self.nodes[0].datadir, 'nonexistent_wallet.bak')
wallet_name = "res0"
assert_raises_rpc_error(-8, "Backup file does not exist", node.restorewallet, wallet_name, nonexistent_wallet_file)
- not_created_wallet_file = os.path.join(node.datadir, self.chain, 'wallets', wallet_name)
+ not_created_wallet_file = os.path.join(node.wallets_path, wallet_name)
assert not os.path.exists(not_created_wallet_file)
def restore_wallet_existent_name(self):
node = self.nodes[3]
backup_file = os.path.join(self.nodes[0].datadir, 'wallet.bak')
wallet_name = "res0"
- wallet_file = os.path.join(node.datadir, self.chain, 'wallets', wallet_name)
+ wallet_file = os.path.join(node.wallets_path, wallet_name)
error_message = "Failed to create database path '{}'. Database already exists.".format(wallet_file)
assert_raises_rpc_error(-36, error_message, node.restorewallet, wallet_name, backup_file)
assert os.path.exists(wallet_file)
@@ -206,9 +206,9 @@ class WalletBackupTest(BitcoinTestFramework):
self.nodes[3].restorewallet("res1", backup_file_1)
self.nodes[3].restorewallet("res2", backup_file_2)
- assert os.path.exists(os.path.join(self.nodes[3].datadir, self.chain, 'wallets', "res0"))
- assert os.path.exists(os.path.join(self.nodes[3].datadir, self.chain, 'wallets', "res1"))
- assert os.path.exists(os.path.join(self.nodes[3].datadir, self.chain, 'wallets', "res2"))
+ assert os.path.exists(os.path.join(self.nodes[3].wallets_path, "res0"))
+ assert os.path.exists(os.path.join(self.nodes[3].wallets_path, "res1"))
+ assert os.path.exists(os.path.join(self.nodes[3].wallets_path, "res2"))
res0_rpc = self.nodes[3].get_wallet_rpc("res0")
res1_rpc = self.nodes[3].get_wallet_rpc("res1")
@@ -226,8 +226,8 @@ class WalletBackupTest(BitcoinTestFramework):
self.erase_three()
#start node2 with no chain
- shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'blocks'))
- shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'chainstate'))
+ shutil.rmtree(os.path.join(self.nodes[2].chain_path, 'blocks'))
+ shutil.rmtree(os.path.join(self.nodes[2].chain_path, 'chainstate'))
self.start_three(["-nowallet"])
self.init_three()
@@ -248,10 +248,10 @@ 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),
- os.path.join(self.nodes[0].datadir, self.chain, 'wallets')]
+ os.path.join(self.nodes[0].wallets_path, self.default_wallet_name, self.wallet_data_filename),
+ os.path.join(self.nodes[0].wallets_path, '.', self.default_wallet_name, self.wallet_data_filename),
+ os.path.join(self.nodes[0].wallets_path, self.default_wallet_name),
+ os.path.join(self.nodes[0].wallets_path)]
for sourcePath in sourcePaths:
assert_raises_rpc_error(-4, "backup failed", self.nodes[0].backupwallet, sourcePath)