Skip to content

Commit

Permalink
test: add coverage for backup file from wallet migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelsadeeq committed Sep 24, 2024
1 parent 90a5786 commit 30372ca
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/functional/wallet_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,25 @@ def test_pruned_wallet_backup(self):
self.restart_node(3, ["-prune=1", "-fastprune=1"])
# Ensure the chain tip is at height 214, because this test assume it is.
assert_equal(node.getchaintips()[0]["height"], 214)
node.createwallet("legacy-wallet", descriptors=False)
# Ensure the chain tip is at height 214, because this test assume it is.
assert_equal(node.getchaintips()[0]["height"], 214)
# We need a few more blocks so we can actually get above an realistic
# minimal prune height
self.generate(node, 50, sync_fun=self.no_op)
# Backup created at block height 264
node.backupwallet(node.datadir_path / 'wallet_pruned.bak')
# Backups created at block height 264
default_wallet = node.get_wallet_rpc(self.default_wallet_name)
default_wallet.backupwallet(node.datadir_path / 'wallet_pruned.bak')
legacy_wallet = node.get_wallet_rpc("legacy-wallet")
legacy_backup_path = legacy_wallet.migratewallet()["backup_path"]
# Generate more blocks so we can actually prune the older blocks
self.generate(node, 300, sync_fun=self.no_op)
# This gives us an actual prune height roughly in the range of 220 - 240
node.pruneblockchain(250)
# The backup should be updated with the latest height (locator) for
# the backup to load successfully this close to the prune height
node.restorewallet(f'pruned', node.datadir_path / 'wallet_pruned.bak')
node.restorewallet('legacy', legacy_backup_path)

def run_test(self):
self.log.info("Generating initial blockchain")
Expand Down

0 comments on commit 30372ca

Please sign in to comment.