From e5a8ae7d60c9fc9d6740ef391ac34f2ac620b0f4 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 20 Jun 2023 16:07:15 +0200 Subject: wallet-core: remove redundant/unused notifications --- .../taler-harness/src/integrationtests/test-kyc.ts | 59 ++++++++++++++++------ 1 file changed, 44 insertions(+), 15 deletions(-) (limited to 'packages/taler-harness/src/integrationtests/test-kyc.ts') diff --git a/packages/taler-harness/src/integrationtests/test-kyc.ts b/packages/taler-harness/src/integrationtests/test-kyc.ts index ac53b0dce..660595845 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc.ts @@ -17,7 +17,14 @@ /** * Imports. */ -import { Duration, j2s, NotificationType } from "@gnu-taler/taler-util"; +import { + Duration, + j2s, + NotificationType, + TransactionMajorState, + TransactionMinorState, + TransactionType, +} from "@gnu-taler/taler-util"; import { BankAccessApi, BankApi, @@ -310,18 +317,7 @@ export async function runKycTest(t: GlobalTestState) { // Withdraw - const kycNotificationCond = walletClient.waitForNotificationCond((x) => { - if (x.type === NotificationType.KycRequested) { - return x; - } - return false; - }); - - const withdrawalDoneCond = walletClient.waitForNotificationCond( - (x) => x.type === NotificationType.WithdrawGroupFinished, - ); - - await walletClient.client.call( + const acceptResp = await walletClient.client.call( WalletApiOperation.AcceptBankIntegratedWithdrawal, { exchangeBaseUrl: exchange.baseUrl, @@ -329,14 +325,47 @@ export async function runKycTest(t: GlobalTestState) { }, ); + const withdrawalTxId = acceptResp.transactionId; + // Confirm it await BankApi.confirmWithdrawalOperation(bank, user, wop); + const kycNotificationCond = walletClient.waitForNotificationCond((x) => { + if ( + x.type === NotificationType.TransactionStateTransition && + x.transactionId === withdrawalTxId && + x.newTxState.major === TransactionMajorState.Pending && + x.newTxState.minor === TransactionMinorState.KycRequired + ) { + return x; + } + return false; + }); + + const withdrawalDoneCond = walletClient.waitForNotificationCond( + (x) => + x.type === NotificationType.TransactionStateTransition && + x.transactionId === withdrawalTxId && + x.newTxState.major === TransactionMajorState.Done, + ); + const kycNotif = await kycNotificationCond; console.log("got kyc notification:", j2s(kycNotif)); + const txState = await walletClient.client.call(WalletApiOperation.GetTransactionById, { + transactionId: withdrawalTxId + }); + + t.assertDeepEqual(txState.type, TransactionType.Withdrawal); + + const kycUrl = txState.kycUrl; + + t.assertTrue(!!kycUrl); + + console.log(`kyc URL is ${kycUrl}`); + // We now simulate the user interacting with the KYC service, // which would usually done in the browser. @@ -344,11 +373,11 @@ export async function runKycTest(t: GlobalTestState) { allowHttp: true, enableThrottling: false, }); - const kycServerResp = await httpLib.get(kycNotif.kycUrl); + const kycServerResp = await httpLib.fetch(kycUrl); const kycLoginResp = await kycServerResp.json(); console.log("kyc server resp:", j2s(kycLoginResp)); const kycProofUrl = kycLoginResp.redirect_uri; - const proofHttpResp = await httpLib.get(kycProofUrl); + const proofHttpResp = await httpLib.fetch(kycProofUrl); console.log("proof resp status", proofHttpResp.status); console.log("resp headers", proofHttpResp.headers.toJSON()); -- cgit v1.2.3