aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_pruning.py
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-10-11 20:06:26 +0200
committerfanquake <fanquake@gmail.com>2023-10-11 20:06:36 +0200
commitd98d88c779bc28794e5936d5ad08fd2df3d992a4 (patch)
tree26db234b00fbde69a8562aae1de11a904319535d /test/functional/wallet_pruning.py
parent744157ef1a0b61ceb714cc27c9ae158907aecdc9 (diff)
parentbfa0bd632a7ce5d04005e20cba79abb32aec8da8 (diff)
Merge bitcoin/bitcoin#28392: test: Use pathlib over os path
bfa0bd632a7ce5d04005e20cba79abb32aec8da8 test: Use pathlib over os.path #28362 (ns-xvrn) Pull request description: In reference to issue #28362 refactoring of functional tests to use pathlib over os.path to reduce verbosity and increase the intuitiveness of managing file access. ACKs for top commit: maflcko: re-ACK bfa0bd632a7ce5d04005e20cba79abb32aec8da8 🐨 willcl-ark: ACK bfa0bd632a7ce5d04005e20cba79abb32aec8da8 Tree-SHA512: fb0833c4039d09758796514e47567a93ac831cb0776ff1a7ed8299792ad132e83282ef80bea098a88ae1551d906f2a56093d3e8de240412f9080735d00d496d9
Diffstat (limited to 'test/functional/wallet_pruning.py')
-rwxr-xr-xtest/functional/wallet_pruning.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/test/functional/wallet_pruning.py b/test/functional/wallet_pruning.py
index 06bd992da7..6e252b5406 100755
--- a/test/functional/wallet_pruning.py
+++ b/test/functional/wallet_pruning.py
@@ -4,7 +4,6 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test wallet import on pruned node."""
-import os
from test_framework.util import assert_equal, assert_raises_rpc_error
from test_framework.blocktools import (
@@ -74,7 +73,7 @@ class WalletPruningTest(BitcoinTestFramework):
# Import wallet into pruned node
self.nodes[1].createwallet(wallet_name="wallet_pruned", descriptors=False, load_on_startup=True)
- self.nodes[1].importwallet(os.path.join(self.nodes[0].datadir, wallet_file))
+ self.nodes[1].importwallet(self.nodes[0].datadir_path / wallet_file)
# Make sure that prune node's wallet correctly accounts for balances
assert_equal(self.nodes[1].getbalance(), self.nodes[0].getbalance())
@@ -93,12 +92,12 @@ class WalletPruningTest(BitcoinTestFramework):
# Make sure wallet cannot be imported because of missing blocks
# This will try to rescan blocks `TIMESTAMP_WINDOW` (2h) before the wallet birthheight.
# There are 6 blocks an hour, so 11 blocks (excluding birthheight).
- assert_raises_rpc_error(-4, f"Pruned blocks from height {wallet_birthheight - 11} required to import keys. Use RPC call getblockchaininfo to determine your pruned height.", self.nodes[1].importwallet, os.path.join(self.nodes[0].datadir, wallet_file))
+ assert_raises_rpc_error(-4, f"Pruned blocks from height {wallet_birthheight - 11} required to import keys. Use RPC call getblockchaininfo to determine your pruned height.", self.nodes[1].importwallet, self.nodes[0].datadir_path / wallet_file)
self.log.info("- Done")
def get_birthheight(self, wallet_file):
"""Gets birthheight of a wallet on node0"""
- with open(os.path.join(self.nodes[0].datadir, wallet_file), 'r', encoding="utf8") as f:
+ with open(self.nodes[0].datadir_path / wallet_file, 'r', encoding="utf8") as f:
for line in f:
if line.startswith('# * Best block at time of backup'):
wallet_birthheight = int(line.split(' ')[9])
@@ -106,12 +105,12 @@ class WalletPruningTest(BitcoinTestFramework):
def has_block(self, block_index):
"""Checks if the pruned node has the specific blk0000*.dat file"""
- return os.path.isfile(os.path.join(self.nodes[1].blocks_path, f"blk{block_index:05}.dat"))
+ return (self.nodes[1].blocks_path / f"blk{block_index:05}.dat").is_file()
def create_wallet(self, wallet_name, *, unload=False):
"""Creates and dumps a wallet on the non-pruned node0 to be later import by the pruned node"""
self.nodes[0].createwallet(wallet_name=wallet_name, descriptors=False, load_on_startup=True)
- self.nodes[0].dumpwallet(os.path.join(self.nodes[0].datadir, wallet_name + ".dat"))
+ self.nodes[0].dumpwallet(self.nodes[0].datadir_path / f"{wallet_name}.dat")
if (unload):
self.nodes[0].unloadwallet(wallet_name)