check error code
This commit is contained in:
parent
c5ec341368
commit
44dcfb3790
@ -32,6 +32,7 @@ import {
|
|||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
ExchangesListRespose,
|
ExchangesListRespose,
|
||||||
URL,
|
URL,
|
||||||
|
TalerErrorCode,
|
||||||
} from "taler-wallet-core";
|
} from "taler-wallet-core";
|
||||||
import {
|
import {
|
||||||
FaultInjectedExchangeService,
|
FaultInjectedExchangeService,
|
||||||
@ -165,12 +166,19 @@ runTest(async (t: GlobalTestState) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await t.assertThrowsOperationErrorAsync(async () => {
|
const err1 = await t.assertThrowsOperationErrorAsync(async () => {
|
||||||
await wallet.addExchange({
|
await wallet.addExchange({
|
||||||
exchangeBaseUrl: faultyExchange.baseUrl,
|
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();
|
exchangesList = await wallet.listExchanges();
|
||||||
t.assertTrue(exchangesList.exchanges.length === 0);
|
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({
|
await wallet.addExchange({
|
||||||
exchangeBaseUrl: faultyExchange.baseUrl,
|
exchangeBaseUrl: faultyExchange.baseUrl,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
t.assertTrue(
|
||||||
|
err2.operationError.talerErrorCode ===
|
||||||
|
TalerErrorCode.WALLET_EXCHANGE_PROTOCOL_VERSION_INCOMPATIBLE,
|
||||||
|
);
|
||||||
|
|
||||||
exchangesList = await wallet.listExchanges();
|
exchangesList = await wallet.listExchanges();
|
||||||
t.assertTrue(exchangesList.exchanges.length === 0);
|
t.assertTrue(exchangesList.exchanges.length === 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user