Skip to content

Commit 9389fa4

Browse files
authored
Merge pull request #1 from Artemkaaas/feature/fix-wallet-tests
Fixed tests related to Not Found Wallet
2 parents b4f51fb + 11674ee commit 9389fa4

File tree

7 files changed

+16
-12
lines changed

7 files changed

+16
-12
lines changed

libindy/src/services/wallet/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,11 @@ impl WalletService {
233233

234234
let mut descriptor_json = String::new();
235235
let descriptor: WalletDescriptor = WalletDescriptor::from_json({
236-
let mut file = File::open(_wallet_descriptor_path(name))?; // FIXME: Better error!
236+
let wallet_descriptor_path = _wallet_descriptor_path(name);
237+
if !wallet_descriptor_path.exists() {
238+
return Err(WalletError::NotFound("Wallet descriptor path does not exist.".to_string()));
239+
}
240+
let mut file = File::open(wallet_descriptor_path)?;
237241
file.read_to_string(&mut descriptor_json)?;
238242
descriptor_json.as_str()
239243
})?;

libindy/tests/wallet.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ mod medium_cases {
386386
TestUtils::cleanup_storage();
387387

388388
let res = WalletUtils::delete_wallet(WALLET);
389-
assert_eq!(res.unwrap_err(), ErrorCode::CommonIOError);
389+
assert_eq!(res.unwrap_err(), ErrorCode::WalletNotFoundError);
390390

391391
TestUtils::cleanup_storage();
392392
}
@@ -398,7 +398,7 @@ mod medium_cases {
398398
WalletUtils::create_wallet(POOL, WALLET, None, None, None).unwrap();
399399
WalletUtils::delete_wallet(WALLET).unwrap();
400400
let res = WalletUtils::delete_wallet(WALLET);
401-
assert_eq!(res.unwrap_err(), ErrorCode::CommonIOError);
401+
assert_eq!(res.unwrap_err(), ErrorCode::WalletNotFoundError);
402402

403403
TestUtils::cleanup_storage();
404404
}
@@ -412,7 +412,7 @@ mod medium_cases {
412412
TestUtils::cleanup_storage();
413413

414414
let res = WalletUtils::open_wallet(WALLET, None, None);
415-
assert_eq!(res.unwrap_err(), ErrorCode::CommonIOError);
415+
assert_eq!(res.unwrap_err(), ErrorCode::WalletNotFoundError);
416416

417417
TestUtils::cleanup_storage();
418418
}

wrappers/ios/libindy-pod/Indy-demoTests/Case Tests/Wallet/WalletHighCases.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ - (void)testDeleteWalletWorksForClosed {
148148

149149
- (void)testDeleteWalletWorksForUnknown {
150150
NSError *ret = [[WalletUtils sharedInstance] deleteWalletWithName:@"testDeleteWalletWorksForUnknown"];
151-
XCTAssertEqual(ret.code, CommonIOError, @"WalletUtils:deleteWalletWithName() returned wrong error");
151+
XCTAssertEqual(ret.code, WalletNotFoundError, @"WalletUtils:deleteWalletWithName() returned wrong error");
152152
}
153153

154154
// MARK: - Open wallet
@@ -200,7 +200,7 @@ - (void)testOpenWalletWorksForNotCreatedWallet {
200200
NSError *ret = [[WalletUtils sharedInstance] openWalletWithName:[TestUtils wallet]
201201
config:nil
202202
outHandle:nil];
203-
XCTAssertEqual(ret.code, CommonIOError, @"WalletUtils:openWalletWithName() failed");
203+
XCTAssertEqual(ret.code, WalletNotFoundError, @"WalletUtils:openWalletWithName() failed");
204204
}
205205

206206
// MARK: - Close wallet

wrappers/java/src/test/java/org/hyperledger/indy/sdk/wallet/DeleteWalletTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void testDeleteWalletWorksForOpened() throws Exception {
5151
@Test
5252
public void testDeleteWalletWorksForTwice() throws Exception {
5353
thrown.expect(ExecutionException.class);
54-
thrown.expectCause(isA(IOException.class));
54+
thrown.expectCause(isA(WalletNotFoundException.class));
5555

5656
Wallet.createWallet(POOL, WALLET, null, null, CREDENTIALS).get();
5757

@@ -74,7 +74,7 @@ public void testDeleteWalletWorksForPlugged() throws Exception {
7474
@Test
7575
public void testDeleteWalletWorksForNotCreated() throws Exception {
7676
thrown.expect(ExecutionException.class);
77-
thrown.expectCause(isA(IOException.class));
77+
thrown.expectCause(isA(WalletNotFoundException.class));
7878

7979
Wallet.deleteWallet(WALLET, CREDENTIALS).get();
8080
}

wrappers/java/src/test/java/org/hyperledger/indy/sdk/wallet/OpenWalletTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void testOpenWalletWorksForPlugged() throws Exception {
6666
@Test
6767
public void testOpenWalletWorksForNotCreatedWallet() throws Exception {
6868
thrown.expect(ExecutionException.class);
69-
thrown.expectCause(isA(IOException.class));
69+
thrown.expectCause(isA(WalletNotFoundException.class));
7070

7171
Wallet.openWallet("openWalletWorksForNotCreatedWallet", null, CREDENTIALS).get();
7272
}

wrappers/python/tests/wallet/test_delete_wallet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async def test_delete_wallet_works_for_twice(wallet_name, xwallet, credentials):
3737
with pytest.raises(IndyError) as e:
3838
await wallet.delete_wallet(wallet_name, credentials)
3939

40-
assert ErrorCode.CommonIOError == e.value.error_code
40+
assert ErrorCode.WalletNotFoundError == e.value.error_code
4141

4242

4343
# noinspection PyUnusedLocal
@@ -46,4 +46,4 @@ async def test_delete_wallet_works_for_not_created(wallet_name, path_home, crede
4646
with pytest.raises(IndyError) as e:
4747
await wallet.delete_wallet(wallet_name, credentials)
4848

49-
assert ErrorCode.CommonIOError == e.value.error_code
49+
assert ErrorCode.WalletNotFoundError == e.value.error_code

wrappers/python/tests/wallet/test_open_wallet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async def test_open_wallet_works(wallet_config, wallet_handle):
1515
async def test_open_wallet_works_for_not_created_wallet(credentials):
1616
with pytest.raises(IndyError) as e:
1717
await wallet.open_wallet('wallet_not_created', None, credentials)
18-
assert ErrorCode.CommonIOError == e.value.error_code
18+
assert ErrorCode.WalletNotFoundError == e.value.error_code
1919

2020

2121
@pytest.mark.asyncio

0 commit comments

Comments
 (0)