commit 2674e02b7110a3acf5e54e13dd2baa1cc863095c
parent 1677f18bb7182db617cf46210a1e46917aa60017
Author: Florian Dold <florian@dold.me>
Date: Fri, 25 Apr 2025 14:38:14 +0200
harness: fix denom-unoffered
The test is now more tolerant of different merchant error response codes
Diffstat:
1 file changed, 15 insertions(+), 28 deletions(-)
diff --git a/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts b/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts
@@ -23,7 +23,6 @@ import {
PreparePayResultType,
succeedOrThrow,
TalerErrorCode,
- TalerMerchantApi,
TalerMerchantInstanceHttpClient,
TransactionType,
} from "@gnu-taler/taler-util";
@@ -53,6 +52,10 @@ export async function runDenomUnofferedTest(t: GlobalTestState) {
await wres.withdrawalFinishedCond;
+ const merchantClient = new TalerMerchantInstanceHttpClient(
+ merchant.makeInstanceBaseUrl(),
+ );
+
// Make the exchange forget the denomination.
// Effectively we completely reset the exchange,
// but keep the exchange master public key.
@@ -68,19 +71,13 @@ export async function runDenomUnofferedTest(t: GlobalTestState) {
await merchant.start();
await merchant.pingUntilAvailable();
- const order: TalerMerchantApi.Order = {
- summary: "Buy me!",
- amount: "TESTKUDOS:5",
- fulfillment_url: "taler://fulfillment-success/thx",
- };
-
- const merchantClient = new TalerMerchantInstanceHttpClient(
- merchant.makeInstanceBaseUrl(),
- );
-
const orderResp = succeedOrThrow(
await merchantClient.createOrder(undefined, {
- order: order,
+ order: {
+ summary: "Buy me!",
+ amount: "TESTKUDOS:5",
+ fulfillment_url: "taler://fulfillment-success/thx",
+ },
}),
);
@@ -121,28 +118,18 @@ export async function runDenomUnofferedTest(t: GlobalTestState) {
const merchantErrorCode = (tx.error as any).requestError.errorResponse.code;
switch (merchantErrorCode) {
- case TalerErrorCode.MERCHANT_GENERIC_EXCHANGE_UNEXPECTED_STATUS:
case TalerErrorCode.MERCHANT_GENERIC_EXCHANGE_TIMEOUT:
+ // Merchant didn't receive/process the keys from the exchange yet,
+ // merchant's response indicates "timeout" from the exchange
+ // request, but in fact the merchant is throttling the request.
+ break;
+ case TalerErrorCode.MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_NOT_FOUND:
+ // Merchant already managed to re-contact the exchange.
break;
default:
t.fail(`unexpected error code: ${merchantErrorCode}`);
}
- const exchangeErrorCode = (tx.error as any).requestError.errorResponse
- .exchange_ec;
-
- t.assertDeepEqual(
- exchangeErrorCode,
- TalerErrorCode.EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN,
- );
-
- // Depending on whether the merchant has seen the new denominations or not,
- // the error code might be different here.
- // t.assertDeepEqual(
- // merchantErrorCode,
- // TalerErrorCode.MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_NOT_FOUND,
- // );
-
// Force updating the exchange entry so that the wallet knows about the new denominations.
await walletClient.call(WalletApiOperation.UpdateExchangeEntry, {
exchangeBaseUrl: exchange.baseUrl,