aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRyan Ofsky <ryan@ofsky.org>2023-06-20 15:41:17 -0400
committerRyan Ofsky <ryan@ofsky.org>2023-06-20 16:10:44 -0400
commitee22ca59a2b29d767ffec0d45483177669b0deea (patch)
treed3d8045e976343e40da2461f605401bea1e20392 /test
parente4bbfb2d495291010914767321beb07ff5194b61 (diff)
parenta1e653828bc59351b2a0dd5a70f519e6b61199bc (diff)
Merge bitcoin/bitcoin#26740: wallet: Migrate wallets that are not in a wallet dir
a1e653828bc59351b2a0dd5a70f519e6b61199bc test: Add test for migrating default wallet and plain file wallet (Andrew Chow) bdbe3fd76b4b9186503dc1926a2fa3f8178d00a5 wallet: Generated migrated wallet's path from walletdir and name (Andrew Chow) Pull request description: This PR fixes an assertion error that is hit during the setup of the new database during migration of a wallet that was not contained in a wallet dir. Also added a test for this case as well as one for migrating the default wallet. ACKs for top commit: ryanofsky: Code review ACK a1e653828bc59351b2a0dd5a70f519e6b61199bc furszy: ACK a1e65382 Tree-SHA512: 96b218c0de8567d8650ec96e1bf58b0f8ca4c4726f5efc6362453979b56b9d569baea0bb09befb3a5aed8d16d29bf75ed5cd8ffc432bbd4cbcad3ac5574bc479
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/wallet_migration.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/functional/wallet_migration.py b/test/functional/wallet_migration.py
index c6c2af10b1..320f5dd9df 100755
--- a/test/functional/wallet_migration.py
+++ b/test/functional/wallet_migration.py
@@ -6,6 +6,7 @@
import os
import random
+import shutil
from test_framework.descriptors import descsum_create
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
@@ -470,6 +471,40 @@ class WalletMigrationTest(BitcoinTestFramework):
assert_equal(bals, wallet.getbalances())
+ def test_default_wallet(self):
+ self.log.info("Test migration of the wallet named as the empty string")
+ wallet = self.create_legacy_wallet("")
+
+ wallet.migratewallet()
+ info = wallet.getwalletinfo()
+ assert_equal(info["descriptors"], True)
+ assert_equal(info["format"], "sqlite")
+
+ def test_direct_file(self):
+ self.log.info("Test migration of a wallet that is not in a wallet directory")
+ wallet = self.create_legacy_wallet("plainfile")
+ wallet.unloadwallet()
+
+ wallets_dir = os.path.join(self.nodes[0].datadir, "regtest", "wallets")
+ wallet_path = os.path.join(wallets_dir, "plainfile")
+ wallet_dat_path = os.path.join(wallet_path, "wallet.dat")
+ shutil.copyfile(wallet_dat_path, os.path.join(wallets_dir, "plainfile.bak"))
+ shutil.rmtree(wallet_path)
+ shutil.move(os.path.join(wallets_dir, "plainfile.bak"), wallet_path)
+
+ self.nodes[0].loadwallet("plainfile")
+ info = wallet.getwalletinfo()
+ assert_equal(info["descriptors"], False)
+ assert_equal(info["format"], "bdb")
+
+ wallet.migratewallet()
+ info = wallet.getwalletinfo()
+ assert_equal(info["descriptors"], True)
+ assert_equal(info["format"], "sqlite")
+
+ assert os.path.isdir(wallet_path)
+ assert os.path.isfile(wallet_dat_path)
+
def run_test(self):
self.generate(self.nodes[0], 101)
@@ -482,6 +517,8 @@ class WalletMigrationTest(BitcoinTestFramework):
self.test_encrypted()
self.test_unloaded()
self.test_unloaded_by_path()
+ self.test_default_wallet()
+ self.test_direct_file()
if __name__ == '__main__':
WalletMigrationTest().main()