@@ -110,6 +110,16 @@ def erase_three(self):
110
110
os .remove (os .path .join (self .nodes [1 ].datadir , self .chain , 'wallets' , self .default_wallet_name , self .wallet_data_filename ))
111
111
os .remove (os .path .join (self .nodes [2 ].datadir , self .chain , 'wallets' , self .default_wallet_name , self .wallet_data_filename ))
112
112
113
+ def restore_invalid_wallet (self ):
114
+ node = self .nodes [3 ]
115
+ invalid_wallet_file = os .path .join (self .nodes [0 ].datadir , 'invalid_wallet_file.bak' )
116
+ open (invalid_wallet_file , 'a' , encoding = "utf8" ).write ('invald wallet' )
117
+ wallet_name = "res0"
118
+ not_created_wallet_file = os .path .join (node .datadir , self .chain , 'wallets' , wallet_name )
119
+ error_message = "Wallet file verification failed. Failed to load database path '{}'. Data is not in recognized format." .format (not_created_wallet_file )
120
+ assert_raises_rpc_error (- 18 , error_message , node .restorewallet , wallet_name , invalid_wallet_file )
121
+ assert not os .path .exists (not_created_wallet_file )
122
+
113
123
def restore_nonexistent_wallet (self ):
114
124
node = self .nodes [3 ]
115
125
nonexistent_wallet_file = os .path .join (self .nodes [0 ].datadir , 'nonexistent_wallet.bak' )
@@ -125,6 +135,7 @@ def restore_wallet_existent_name(self):
125
135
wallet_file = os .path .join (node .datadir , self .chain , 'wallets' , wallet_name )
126
136
error_message = "Failed to create database path '{}'. Database already exists." .format (wallet_file )
127
137
assert_raises_rpc_error (- 36 , error_message , node .restorewallet , wallet_name , backup_file )
138
+ assert os .path .exists (wallet_file )
128
139
129
140
def init_three (self ):
130
141
self .init_wallet (node = 0 )
@@ -181,6 +192,7 @@ def run_test(self):
181
192
##
182
193
self .log .info ("Restoring wallets on node 3 using backup files" )
183
194
195
+ self .restore_invalid_wallet ()
184
196
self .restore_nonexistent_wallet ()
185
197
186
198
backup_file_0 = os .path .join (self .nodes [0 ].datadir , 'wallet.bak' )
@@ -191,6 +203,10 @@ def run_test(self):
191
203
self .nodes [3 ].restorewallet ("res1" , backup_file_1 )
192
204
self .nodes [3 ].restorewallet ("res2" , backup_file_2 )
193
205
206
+ assert os .path .exists (os .path .join (self .nodes [3 ].datadir , self .chain , 'wallets' , "res0" ))
207
+ assert os .path .exists (os .path .join (self .nodes [3 ].datadir , self .chain , 'wallets' , "res1" ))
208
+ assert os .path .exists (os .path .join (self .nodes [3 ].datadir , self .chain , 'wallets' , "res2" ))
209
+
194
210
res0_rpc = self .nodes [3 ].get_wallet_rpc ("res0" )
195
211
res1_rpc = self .nodes [3 ].get_wallet_rpc ("res1" )
196
212
res2_rpc = self .nodes [3 ].get_wallet_rpc ("res2" )
0 commit comments