diff options
Diffstat (limited to 'packages/taler-wallet-core/src/crypto')
3 files changed, 17 insertions, 19 deletions
diff --git a/packages/taler-wallet-core/src/crypto/workers/crypto-dispatcher.test.ts b/packages/taler-wallet-core/src/crypto/workers/crypto-dispatcher.test.ts index b63c9bf11..df2e645a7 100644 --- a/packages/taler-wallet-core/src/crypto/workers/crypto-dispatcher.test.ts +++ b/packages/taler-wallet-core/src/crypto/workers/crypto-dispatcher.test.ts @@ -16,11 +16,13 @@ import test from "ava"; import { CryptoDispatcher, CryptoWorkerFactory } from "./crypto-dispatcher.js"; -import { CryptoWorker, CryptoWorkerResponseMessage } from "./cryptoWorkerInterface.js"; +import { + CryptoWorker, + CryptoWorkerResponseMessage, +} from "./cryptoWorkerInterface.js"; import { SynchronousCryptoWorkerFactoryNode } from "./synchronousWorkerFactoryNode.js"; import { processRequestWithImpl } from "./worker-common.js"; - export class MyCryptoWorker implements CryptoWorker { /** * Function to be called when we receive a message from the worker thread. @@ -64,8 +66,8 @@ export class MyCryptoWorker implements CryptoWorker { type: "success", result: { testResult: 42, - } - } + }, + }; } else if (msg.operation === "testError") { responseMsg = { id: msg.id, @@ -73,8 +75,8 @@ export class MyCryptoWorker implements CryptoWorker { error: { code: 42, hint: "bla", - } - } + }, + }; } else if (msg.operation === "testTimeout") { // Don't respond return; @@ -98,8 +100,6 @@ export class MyCryptoWorker implements CryptoWorker { } } - - export class MyCryptoWorkerFactory implements CryptoWorkerFactory { startWorker(): CryptoWorker { return new MyCryptoWorker(); @@ -111,12 +111,10 @@ export class MyCryptoWorkerFactory implements CryptoWorkerFactory { } test("continues after error", async (t) => { - const cryptoDisp = new CryptoDispatcher( - new MyCryptoWorkerFactory(), - ); + const cryptoDisp = new CryptoDispatcher(new MyCryptoWorkerFactory()); const resp1 = await cryptoDisp.doRpc("testSuccess", 0, {}); t.assert((resp1 as any).testResult === 42); - const exc = await t.throwsAsync(async() => { + const exc = await t.throwsAsync(async () => { const resp2 = await cryptoDisp.doRpc("testError", 0, {}); }); diff --git a/packages/taler-wallet-core/src/crypto/workers/crypto-dispatcher.ts b/packages/taler-wallet-core/src/crypto/workers/crypto-dispatcher.ts index 940078ea6..f086691e5 100644 --- a/packages/taler-wallet-core/src/crypto/workers/crypto-dispatcher.ts +++ b/packages/taler-wallet-core/src/crypto/workers/crypto-dispatcher.ts @@ -308,11 +308,7 @@ export class CryptoDispatcher { } } - doRpc<T>( - operation: string, - priority: number, - req: unknown, - ): Promise<T> { + doRpc<T>(operation: string, priority: number, req: unknown): Promise<T> { if (this.stopped) { throw new CryptoApiStoppedError(); } @@ -364,7 +360,9 @@ export class CryptoDispatcher { const onTimeout = () => { // FIXME: Maybe destroy and re-init worker if request is in processing // state and really taking too long? - logger.warn(`crypto RPC call ('${operation}') has been queued for a long time`); + logger.warn( + `crypto RPC call ('${operation}') has been queued for a long time`, + ); timeoutHandle = timer.after(timeoutMs, onTimeout); }; myProm.promise diff --git a/packages/taler-wallet-core/src/crypto/workers/nodeThreadWorker.ts b/packages/taler-wallet-core/src/crypto/workers/nodeThreadWorker.ts index db8bb4737..d9b4399d6 100644 --- a/packages/taler-wallet-core/src/crypto/workers/nodeThreadWorker.ts +++ b/packages/taler-wallet-core/src/crypto/workers/nodeThreadWorker.ts @@ -27,7 +27,9 @@ import { processRequestWithImpl } from "./worker-common.js"; const logger = new Logger("nodeThreadWorker.ts"); -const f = import.meta.url ? url.fileURLToPath(import.meta.url) : '__not_available__'; +const f = import.meta.url + ? url.fileURLToPath(import.meta.url) + : "__not_available__"; const workerCode = ` // Try loading the glue library for embedded |