check error code

This commit is contained in:
Florian Dold 2020-08-12 19:52:51 +05:30
parent c5ec341368
commit 44dcfb3790
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -32,6 +32,7 @@ import {
PreparePayResultType,
ExchangesListRespose,
URL,
TalerErrorCode,
} from "taler-wallet-core";
import {
FaultInjectedExchangeService,
@ -165,12 +166,19 @@ runTest(async (t: GlobalTestState) => {
},
});
await t.assertThrowsOperationErrorAsync(async () => {
const err1 = await t.assertThrowsOperationErrorAsync(async () => {
await wallet.addExchange({
exchangeBaseUrl: faultyExchange.baseUrl,
});
});
// Response is malformed, since it didn't even contain a version code
// in a format the wallet can understand.
t.assertTrue(
err1.operationError.talerErrorCode ===
TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE,
);
exchangesList = await wallet.listExchanges();
t.assertTrue(exchangesList.exchanges.length === 0);
@ -197,12 +205,17 @@ runTest(async (t: GlobalTestState) => {
},
});
await t.assertThrowsOperationErrorAsync(async () => {
const err2 = await t.assertThrowsOperationErrorAsync(async () => {
await wallet.addExchange({
exchangeBaseUrl: faultyExchange.baseUrl,
});
});
t.assertTrue(
err2.operationError.talerErrorCode ===
TalerErrorCode.WALLET_EXCHANGE_PROTOCOL_VERSION_INCOMPATIBLE,
);
exchangesList = await wallet.listExchanges();
t.assertTrue(exchangesList.exchanges.length === 0);