From 13f0442736479fb6ea8d1ecc7311cdac354a4de5 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 12 Feb 2023 19:30:59 +0100 Subject: harness: finish kyc test We mock the KYC gateway now, use the new notification-based wallet API and the test is not experimental anymore. --- packages/taler-wallet-core/src/remote.ts | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'packages/taler-wallet-core/src/remote.ts') diff --git a/packages/taler-wallet-core/src/remote.ts b/packages/taler-wallet-core/src/remote.ts index 2628fea07..bc0be9d30 100644 --- a/packages/taler-wallet-core/src/remote.ts +++ b/packages/taler-wallet-core/src/remote.ts @@ -145,9 +145,14 @@ export function getClientFromRemoteWallet( export interface WalletNotificationWaiter { notify(wn: WalletNotification): void; - waitForNotificationCond( - cond: (n: WalletNotification) => boolean, - ): Promise; + waitForNotificationCond( + cond: (n: WalletNotification) => T | false | undefined, + ): Promise; +} + +interface NotificationCondEntry { + condition: (n: WalletNotification) => T | false | undefined; + promiseCapability: OpenedPromise; } /** @@ -157,22 +162,19 @@ export interface WalletNotificationWaiter { export function makeNotificationWaiter(): WalletNotificationWaiter { // Bookkeeping for waiting on notification conditions let nextCondIndex = 1; - const condMap: Map< - number, - { - condition: (n: WalletNotification) => boolean; - promiseCapability: OpenedPromise; - } - > = new Map(); + const condMap: Map> = new Map(); function onNotification(n: WalletNotification) { condMap.forEach((cond, condKey) => { - if (cond.condition(n)) { - cond.promiseCapability.resolve(); + const res = cond.condition(n); + if (res) { + cond.promiseCapability.resolve(res); } }); } - function waitForNotificationCond(cond: (n: WalletNotification) => boolean) { - const promCap = openPromise(); + function waitForNotificationCond( + cond: (n: WalletNotification) => T | false | undefined, + ) { + const promCap = openPromise(); condMap.set(nextCondIndex++, { condition: cond, promiseCapability: promCap, -- cgit v1.2.3