File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
libindy/src/services/wallet Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -265,7 +265,11 @@ impl WalletService {
265265
266266 let mut descriptor_json = String :: new ( ) ;
267267 let descriptor: WalletDescriptor = WalletDescriptor :: from_json ( {
268- let mut file = File :: open ( _wallet_descriptor_path ( name) ) ?; // FIXME: Better error!
268+ let wallet_descriptor_path = _wallet_descriptor_path ( name) ;
269+ if !wallet_descriptor_path. exists ( ) {
270+ return Err ( WalletError :: NotFound ( "Wallet descriptor path does not exist." . to_string ( ) ) ) ;
271+ }
272+ let mut file = File :: open ( _wallet_descriptor_path ( name) ) ?;
269273 file. read_to_string ( & mut descriptor_json) ?;
270274 descriptor_json. as_str ( )
271275 } ) ?;
@@ -914,6 +918,15 @@ mod tests {
914918 wallet_service. open_wallet ( "test_wallet" , None , & _credentials ( ) ) . unwrap ( ) ;
915919 }
916920
921+ #[ test]
922+ fn wallet_service_open_unknown_wallet ( ) {
923+ _cleanup ( ) ;
924+
925+ let wallet_service = WalletService :: new ( ) ;
926+ let res = wallet_service. open_wallet ( "test_wallet_unknown" , None , & _credentials ( ) ) ;
927+ assert_match ! ( Err ( WalletError :: NotFound ( _) ) , res) ;
928+ }
929+
917930 #[ test]
918931 fn wallet_service_open_wallet_without_master_key_in_credentials_returns_error ( ) {
919932 _cleanup ( ) ;
You can’t perform that action at this time.
0 commit comments