From 2c0464b49479d62b58968a5e28c890555456807b Mon Sep 17 00:00:00 2001 From: MS Date: Fri, 25 Sep 2020 16:50:26 +0200 Subject: [PATCH] Finalizing loop's cause reproduction. --- .../src/merchantApiTypes.ts | 5 +- .../src/test-claim-loop.ts | 50 +++++++++---------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/packages/taler-integrationtests/src/merchantApiTypes.ts b/packages/taler-integrationtests/src/merchantApiTypes.ts index e89e32642..1806ab706 100644 --- a/packages/taler-integrationtests/src/merchantApiTypes.ts +++ b/packages/taler-integrationtests/src/merchantApiTypes.ts @@ -82,6 +82,7 @@ export const codecForCheckPaymentPaidResponse = (): Codec< CheckPaymentPaidResponse > => buildCodecForObject() + .property("order_status_url", codecForConstString("paid")) .property("order_status", codecForConstString("paid")) .property("refunded", codecForBoolean()) .property("wired", codecForBoolean()) @@ -159,6 +160,8 @@ export interface CheckPaymentPaidResponse { // The refund details for this order. One entry per // refunded coin; empty array if there are no refunds. refund_details: RefundDetails[]; + + order_status_url: string; } export interface CheckPaymentUnpaidResponse { @@ -282,4 +285,4 @@ export interface TipCreateRequest { // URL that the user should be directed to after tipping, // will be included in the tip_token. next_url: string; -} \ No newline at end of file +} diff --git a/packages/taler-integrationtests/src/test-claim-loop.ts b/packages/taler-integrationtests/src/test-claim-loop.ts index ead0076d2..fdc87ba0d 100644 --- a/packages/taler-integrationtests/src/test-claim-loop.ts +++ b/packages/taler-integrationtests/src/test-claim-loop.ts @@ -25,6 +25,7 @@ import { } from "./harness"; import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; import { PreparePayResultType, TalerErrorCode } from "taler-wallet-core"; +import { URL } from "url" /** * Run test for basic, bank-integrated withdrawal. @@ -42,38 +43,37 @@ runTest(async (t: GlobalTestState) => { await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" }); // Set up order. - const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { order: { summary: "Buy me!", amount: "TESTKUDOS:5", fulfillment_url: "taler://fulfillment-success/thx", - }, - }); - - let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { - orderId: orderResp.order_id, - }); - - // orderStatus has a "order_status_url" value _with_ - // a 'token' URI parameter. - - t.assertTrue(orderStatus.order_status === "unpaid"); - - const talerPayUri = orderStatus.taler_pay_uri; - - // Make wallet claim the order. - - const preparePayResult = await wallet.preparePay({ - talerPayUri, - }); - - let orderStatusAgain = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { - orderId: orderResp.order_id, + } }); - // orderStatusAgain has a "order_status_url" value - // _without_ a 'token' URI parameter. + // Query private order status before claiming it. + let orderStatusBefore = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { + orderId: orderResp.order_id, + }); + let statusUrlBefore = new URL(orderStatusBefore.order_status_url); + + // Make wallet claim the unpaid order. + t.assertTrue(orderStatusBefore.order_status === "unpaid"); + const talerPayUri = orderStatusBefore.taler_pay_uri; + const y = await wallet.preparePay({ + talerPayUri + }); + + // Query private order status after claiming it. + let orderStatusAfter = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { + orderId: orderResp.order_id, + }); + let statusUrlAfter = new URL(orderStatusAfter.order_status_url) + + let tokenBefore = statusUrlBefore.searchParams.get("token") + let tokenAfter = statusUrlAfter.searchParams.get("token") + + t.assertTrue(tokenBefore === tokenAfter) await t.shutdown(); });