diff options
author | Florian Dold <florian@dold.me> | 2023-01-02 21:00:43 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-01-02 21:00:43 +0100 |
commit | d48ea17c6345abaa732deb5fab6141449d463e41 (patch) | |
tree | 8983639bb6441965fd5d77b742409c87b9497797 /packages | |
parent | 13d6810937255a136dcd098d142037cfb143a34e (diff) |
-logging, skip defaults in test
Diffstat (limited to 'packages')
7 files changed, 37 insertions, 6 deletions
diff --git a/packages/taler-util/src/helpers.ts b/packages/taler-util/src/helpers.ts index 7d84d434e..95c6bf286 100644 --- a/packages/taler-util/src/helpers.ts +++ b/packages/taler-util/src/helpers.ts @@ -121,3 +121,19 @@ export function j2s(x: any): string { export function notEmpty<T>(value: T | null | undefined): value is T { return value !== null && value !== undefined; } + +/** + * Safe function to stringify errors. + */ +export function stringifyError(x: any): string { + if (typeof x === "undefined") { + return "<thrown undefined>"; + } + if (x === null) { + return `<thrown null>`; + } + if (typeof x === "object") { + return x.toString(); + } + return `<thrown ${typeof x}>`; +}
\ No newline at end of file diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 61f2f3b73..402a9ed95 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -118,6 +118,10 @@ export interface Balance { requiresUserInput: boolean; } +export interface InitRequest { + skipDefaults?: boolean; +} + export interface InitResponse { versionInfo: WalletCoreVersion; } diff --git a/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts index 5d2820fdb..624ddf1d3 100644 --- a/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts +++ b/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts @@ -664,7 +664,8 @@ export const nativeCryptoR: TalerCryptoInterfaceR = { const salt = new Uint8Array(saltArrBuf); const saltDataView = new DataView(saltArrBuf); saltDataView.setUint32(0, req.coinNumber); - const out = kdf(64, decodeCrock(req.secretSeed), salt, info); + const secretSeedDec = decodeCrock(req.secretSeed); + const out = kdf(64, secretSeedDec, salt, info); const coinPriv = out.slice(0, 32); const bks = out.slice(32, 64); const coinPrivEnc = encodeCrock(coinPriv); diff --git a/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerPlain.ts b/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerPlain.ts index 058896828..c80f2f58f 100644 --- a/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerPlain.ts +++ b/packages/taler-wallet-core/src/crypto/workers/synchronousWorkerPlain.ts @@ -17,7 +17,7 @@ /** * Imports. */ -import { Logger } from "@gnu-taler/taler-util"; +import { j2s, Logger } from "@gnu-taler/taler-util"; import { nativeCryptoR, TalerCryptoInterfaceR, @@ -84,6 +84,8 @@ export class SynchronousCryptoWorkerPlain implements CryptoWorker { }; handleRequest().catch((e) => { logger.error("Error while handling crypto request:", e); + logger.error("Stack:", e.stack); + logger.error(`request was ${j2s(msg)}`); }); } diff --git a/packages/taler-wallet-core/src/crypto/workers/worker-common.ts b/packages/taler-wallet-core/src/crypto/workers/worker-common.ts index 459033526..8a74a5231 100644 --- a/packages/taler-wallet-core/src/crypto/workers/worker-common.ts +++ b/packages/taler-wallet-core/src/crypto/workers/worker-common.ts @@ -17,7 +17,12 @@ /** * Imports. */ -import { j2s, Logger, TalerErrorCode } from "@gnu-taler/taler-util"; +import { + j2s, + Logger, + stringifyError as safeStringifyError, + TalerErrorCode, +} from "@gnu-taler/taler-util"; import { getErrorDetailFromException, makeErrorDetail } from "../../errors.js"; import { TalerCryptoInterfaceR } from "../cryptoImplementation.js"; import { @@ -88,7 +93,7 @@ export async function processRequestWithImpl( const result = await (impl as any)[operation](impl, reqMsg.req); responseMsg = { type: "success", result, id }; } catch (e: any) { - logger.error(`error during operation: ${e.stack ?? e.toString()}`); + logger.error(`error during operation: ${safeStringifyError(e)}`); responseMsg = { type: "error", error: getErrorDetailFromException(e), diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index f4fb16e80..1ea57a27d 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -106,6 +106,7 @@ import { WithdrawTestBalanceRequest, WithdrawUriInfoResponse, UserAttentionByIdRequest, + InitRequest, } from "@gnu-taler/taler-util"; import { WalletContractData } from "./db.js"; import { @@ -200,7 +201,7 @@ type EmptyObject = Record<string, never>; */ export type InitWalletOp = { op: WalletApiOperation.InitWallet; - request: EmptyObject; + request: InitRequest; response: InitResponse; }; diff --git a/packages/taler-wallet-embedded/src/wallet-qjs.ts b/packages/taler-wallet-embedded/src/wallet-qjs.ts index cdd5400cf..a9c314c6d 100644 --- a/packages/taler-wallet-embedded/src/wallet-qjs.ts +++ b/packages/taler-wallet-embedded/src/wallet-qjs.ts @@ -424,7 +424,9 @@ export async function testWithGv() { export async function testWithLocal() { const w = await getWallet(); - await w.wallet.client.call(WalletApiOperation.InitWallet, {}); + await w.wallet.client.call(WalletApiOperation.InitWallet, { + skipDefaults: true, + }); await w.wallet.client.call(WalletApiOperation.RunIntegrationTest, { amountToSpend: "TESTKUDOS:1", amountToWithdraw: "TESTKUDOS:3", |