aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-harness/src/integrationtests/test-kyc.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-06-20 16:07:15 +0200
committerFlorian Dold <florian@dold.me>2023-06-20 16:07:20 +0200
commite5a8ae7d60c9fc9d6740ef391ac34f2ac620b0f4 (patch)
tree472ddac0bbcf0b80a682672462870de613e8b3c8 /packages/taler-harness/src/integrationtests/test-kyc.ts
parenta86c948fc9e44e3503cd19776c3eb6410ea3d674 (diff)
downloadwallet-core-e5a8ae7d60c9fc9d6740ef391ac34f2ac620b0f4.tar.xz
wallet-core: remove redundant/unused notifications
Diffstat (limited to 'packages/taler-harness/src/integrationtests/test-kyc.ts')
-rw-r--r--packages/taler-harness/src/integrationtests/test-kyc.ts59
1 files changed, 44 insertions, 15 deletions
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());