mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
test: Add coverage for best block locator write in wallet_backup
This commit is contained in:
parent
31c0df0389
commit
037b101e80
1 changed files with 21 additions and 0 deletions
|
@ -140,6 +140,25 @@ class WalletBackupTest(BitcoinTestFramework):
|
||||||
assert_raises_rpc_error(-36, error_message, node.restorewallet, wallet_name, backup_file)
|
assert_raises_rpc_error(-36, error_message, node.restorewallet, wallet_name, backup_file)
|
||||||
assert wallet_file.exists()
|
assert wallet_file.exists()
|
||||||
|
|
||||||
|
def test_pruned_wallet_backup(self):
|
||||||
|
self.log.info("Test loading backup on a pruned node when the backup was created close to the prune height of the restoring node")
|
||||||
|
node = self.nodes[3]
|
||||||
|
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)
|
||||||
|
# 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')
|
||||||
|
# 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')
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.log.info("Generating initial blockchain")
|
self.log.info("Generating initial blockchain")
|
||||||
self.generate(self.nodes[0], 1)
|
self.generate(self.nodes[0], 1)
|
||||||
|
@ -242,6 +261,8 @@ class WalletBackupTest(BitcoinTestFramework):
|
||||||
for sourcePath in sourcePaths:
|
for sourcePath in sourcePaths:
|
||||||
assert_raises_rpc_error(-4, "backup failed", self.nodes[0].backupwallet, sourcePath)
|
assert_raises_rpc_error(-4, "backup failed", self.nodes[0].backupwallet, sourcePath)
|
||||||
|
|
||||||
|
self.test_pruned_wallet_backup()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
WalletBackupTest(__file__).main()
|
WalletBackupTest(__file__).main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue