@@ -128,7 +128,8 @@ def migrate_and_get_rpc(self, wallet_name, **kwargs):
128
128
if w ["name" ] == wallet_name :
129
129
assert_equal (w ["warnings" ], ["This wallet is a legacy wallet and will need to be migrated with migratewallet before it can be loaded" ])
130
130
131
- # Mock time so that we can check the backup filename.
131
+ # migratewallet uses current time in naming the backup file, set a mock time
132
+ # to check that this works correctly.
132
133
mocked_time = int (time .time ())
133
134
self .master_node .setmocktime (mocked_time )
134
135
# Migrate, checking that rescan does not occur
@@ -148,8 +149,10 @@ def migrate_and_get_rpc(self, wallet_name, **kwargs):
148
149
else :
149
150
backup_prefix = os .path .basename (os .path .realpath (self .old_node .wallets_path / wallet_name ))
150
151
151
- expected_backup_path = self .master_node .wallets_path / f"{ backup_prefix } _{ mocked_time } .legacy.bak"
152
+ backup_filename = f"{ backup_prefix } _{ mocked_time } .legacy.bak"
153
+ expected_backup_path = self .master_node .wallets_path / backup_filename
152
154
assert_equal (str (expected_backup_path ), migrate_info ['backup_path' ])
155
+ assert {"name" : backup_filename } not in self .master_node .listwalletdir ()["wallets" ]
153
156
154
157
return migrate_info , wallet
155
158
@@ -593,12 +596,7 @@ def test_wallet_with_relative_path(self):
593
596
self .generate (self .master_node , 1 )
594
597
bals = wallet .getbalances ()
595
598
596
- # migratewallet uses current time in naming the backup file, set a mock time
597
- # to check that this works correctly.
598
- curr_time = int (time .time ())
599
- self .master_node .setmocktime (curr_time )
600
599
migrate_res , wallet = self .migrate_and_get_rpc (relative_name )
601
- self .master_node .setmocktime (0 )
602
600
603
601
# Check that the wallet was migrated, knows the right txid, and has the right balance.
604
602
assert wallet .gettransaction (txid )
@@ -665,27 +663,17 @@ def test_default_wallet(self):
665
663
self .log .info ("Test migration of the wallet named as the empty string" )
666
664
wallet = self .create_legacy_wallet ("" )
667
665
668
- # Set time to verify backup existence later
669
- curr_time = int (time .time ())
670
- self .master_node .setmocktime (curr_time )
671
-
672
666
res , wallet = self .migrate_and_get_rpc ("" )
673
- self .master_node .setmocktime (0 )
674
667
info = wallet .getwalletinfo ()
675
668
assert_equal (info ["descriptors" ], True )
676
669
assert_equal (info ["format" ], "sqlite" )
677
670
678
671
walletdir_list = wallet .listwalletdir ()
679
672
assert {"name" : info ["walletname" ]} in [{"name" : w ["name" ]} for w in walletdir_list ["wallets" ]]
680
673
681
- # Check backup existence and its non-empty wallet filename
682
- backup_filename = f"default_wallet_{ curr_time } .legacy.bak"
683
- backup_path = self .master_node .wallets_path / backup_filename
684
- assert backup_path .exists ()
685
- assert_equal (str (backup_path ), res ['backup_path' ])
686
- assert {"name" : backup_filename } not in walletdir_list ["wallets" ]
687
-
688
- self .master_node .setmocktime (0 )
674
+ # Make sure the backup uses a non-empty filename
675
+ # migrate_and_get_rpc already checks for backup file existence
676
+ assert os .path .basename (res ["backup_path" ]).startswith ("default_wallet" )
689
677
690
678
def test_direct_file (self ):
691
679
self .log .info ("Test migration of a wallet that is not in a wallet directory" )
0 commit comments