6
6
7
7
import os
8
8
import random
9
+ import shutil
9
10
from test_framework .descriptors import descsum_create
10
11
from test_framework .test_framework import BitcoinTestFramework
11
12
from test_framework .util import (
@@ -470,6 +471,40 @@ def test_unloaded_by_path(self):
470
471
471
472
assert_equal (bals , wallet .getbalances ())
472
473
474
+ def test_default_wallet (self ):
475
+ self .log .info ("Test migration of the wallet named as the empty string" )
476
+ wallet = self .create_legacy_wallet ("" )
477
+
478
+ wallet .migratewallet ()
479
+ info = wallet .getwalletinfo ()
480
+ assert_equal (info ["descriptors" ], True )
481
+ assert_equal (info ["format" ], "sqlite" )
482
+
483
+ def test_direct_file (self ):
484
+ self .log .info ("Test migration of a wallet that is not in a wallet directory" )
485
+ wallet = self .create_legacy_wallet ("plainfile" )
486
+ wallet .unloadwallet ()
487
+
488
+ wallets_dir = os .path .join (self .nodes [0 ].datadir , "regtest" , "wallets" )
489
+ wallet_path = os .path .join (wallets_dir , "plainfile" )
490
+ wallet_dat_path = os .path .join (wallet_path , "wallet.dat" )
491
+ shutil .copyfile (wallet_dat_path , os .path .join (wallets_dir , "plainfile.bak" ))
492
+ shutil .rmtree (wallet_path )
493
+ shutil .move (os .path .join (wallets_dir , "plainfile.bak" ), wallet_path )
494
+
495
+ self .nodes [0 ].loadwallet ("plainfile" )
496
+ info = wallet .getwalletinfo ()
497
+ assert_equal (info ["descriptors" ], False )
498
+ assert_equal (info ["format" ], "bdb" )
499
+
500
+ wallet .migratewallet ()
501
+ info = wallet .getwalletinfo ()
502
+ assert_equal (info ["descriptors" ], True )
503
+ assert_equal (info ["format" ], "sqlite" )
504
+
505
+ assert os .path .isdir (wallet_path )
506
+ assert os .path .isfile (wallet_dat_path )
507
+
473
508
def run_test (self ):
474
509
self .generate (self .nodes [0 ], 101 )
475
510
@@ -482,6 +517,8 @@ def run_test(self):
482
517
self .test_encrypted ()
483
518
self .test_unloaded ()
484
519
self .test_unloaded_by_path ()
520
+ self .test_default_wallet ()
521
+ self .test_direct_file ()
485
522
486
523
if __name__ == '__main__' :
487
524
WalletMigrationTest ().main ()
0 commit comments