diff options
author | Florian Dold <florian@dold.me> | 2023-02-12 19:30:59 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-02-12 19:31:37 +0100 |
commit | 13f0442736479fb6ea8d1ecc7311cdac354a4de5 (patch) | |
tree | a39badc56b57a5039ec04267adb4df42b84cee7a /packages/taler-wallet-core/src/remote.ts | |
parent | 04ab9f37801f6a42b85581cc79667239d3fc79e5 (diff) | |
download | wallet-core-13f0442736479fb6ea8d1ecc7311cdac354a4de5.tar.xz |
harness: finish kyc test
We mock the KYC gateway now, use the new notification-based wallet API
and the test is not experimental anymore.
Diffstat (limited to 'packages/taler-wallet-core/src/remote.ts')
-rw-r--r-- | packages/taler-wallet-core/src/remote.ts | 30 |
1 files changed, 16 insertions, 14 deletions
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<void>; + waitForNotificationCond<T>( + cond: (n: WalletNotification) => T | false | undefined, + ): Promise<T>; +} + +interface NotificationCondEntry<T> { + condition: (n: WalletNotification) => T | false | undefined; + promiseCapability: OpenedPromise<T>; } /** @@ -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<void>; - } - > = new Map(); + const condMap: Map<number, NotificationCondEntry<any>> = 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<void>(); + function waitForNotificationCond<T>( + cond: (n: WalletNotification) => T | false | undefined, + ) { + const promCap = openPromise<T>(); condMap.set(nextCondIndex++, { condition: cond, promiseCapability: promCap, |