-logging, skip defaults in test

This commit is contained in:
Florian Dold 2023-01-02 21:00:43 +01:00
parent 13d6810937
commit d48ea17c63
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
8 changed files with 38 additions and 7 deletions

@ -1 +1 @@
Subproject commit 355a3172699b96f1040edcb577c07a681802b3ae Subproject commit 23538677f6c6be2a62f38dc6137ecdd1c76b7b15

View File

@ -121,3 +121,19 @@ export function j2s(x: any): string {
export function notEmpty<T>(value: T | null | undefined): value is T { export function notEmpty<T>(value: T | null | undefined): value is T {
return value !== null && value !== undefined; 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}>`;
}

View File

@ -118,6 +118,10 @@ export interface Balance {
requiresUserInput: boolean; requiresUserInput: boolean;
} }
export interface InitRequest {
skipDefaults?: boolean;
}
export interface InitResponse { export interface InitResponse {
versionInfo: WalletCoreVersion; versionInfo: WalletCoreVersion;
} }

View File

@ -664,7 +664,8 @@ export const nativeCryptoR: TalerCryptoInterfaceR = {
const salt = new Uint8Array(saltArrBuf); const salt = new Uint8Array(saltArrBuf);
const saltDataView = new DataView(saltArrBuf); const saltDataView = new DataView(saltArrBuf);
saltDataView.setUint32(0, req.coinNumber); 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 coinPriv = out.slice(0, 32);
const bks = out.slice(32, 64); const bks = out.slice(32, 64);
const coinPrivEnc = encodeCrock(coinPriv); const coinPrivEnc = encodeCrock(coinPriv);

View File

@ -17,7 +17,7 @@
/** /**
* Imports. * Imports.
*/ */
import { Logger } from "@gnu-taler/taler-util"; import { j2s, Logger } from "@gnu-taler/taler-util";
import { import {
nativeCryptoR, nativeCryptoR,
TalerCryptoInterfaceR, TalerCryptoInterfaceR,
@ -84,6 +84,8 @@ export class SynchronousCryptoWorkerPlain implements CryptoWorker {
}; };
handleRequest().catch((e) => { handleRequest().catch((e) => {
logger.error("Error while handling crypto request:", e); logger.error("Error while handling crypto request:", e);
logger.error("Stack:", e.stack);
logger.error(`request was ${j2s(msg)}`);
}); });
} }

View File

@ -17,7 +17,12 @@
/** /**
* Imports. * 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 { getErrorDetailFromException, makeErrorDetail } from "../../errors.js";
import { TalerCryptoInterfaceR } from "../cryptoImplementation.js"; import { TalerCryptoInterfaceR } from "../cryptoImplementation.js";
import { import {
@ -88,7 +93,7 @@ export async function processRequestWithImpl(
const result = await (impl as any)[operation](impl, reqMsg.req); const result = await (impl as any)[operation](impl, reqMsg.req);
responseMsg = { type: "success", result, id }; responseMsg = { type: "success", result, id };
} catch (e: any) { } catch (e: any) {
logger.error(`error during operation: ${e.stack ?? e.toString()}`); logger.error(`error during operation: ${safeStringifyError(e)}`);
responseMsg = { responseMsg = {
type: "error", type: "error",
error: getErrorDetailFromException(e), error: getErrorDetailFromException(e),

View File

@ -106,6 +106,7 @@ import {
WithdrawTestBalanceRequest, WithdrawTestBalanceRequest,
WithdrawUriInfoResponse, WithdrawUriInfoResponse,
UserAttentionByIdRequest, UserAttentionByIdRequest,
InitRequest,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletContractData } from "./db.js"; import { WalletContractData } from "./db.js";
import { import {
@ -200,7 +201,7 @@ type EmptyObject = Record<string, never>;
*/ */
export type InitWalletOp = { export type InitWalletOp = {
op: WalletApiOperation.InitWallet; op: WalletApiOperation.InitWallet;
request: EmptyObject; request: InitRequest;
response: InitResponse; response: InitResponse;
}; };

View File

@ -424,7 +424,9 @@ export async function testWithGv() {
export async function testWithLocal() { export async function testWithLocal() {
const w = await getWallet(); 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, { await w.wallet.client.call(WalletApiOperation.RunIntegrationTest, {
amountToSpend: "TESTKUDOS:1", amountToSpend: "TESTKUDOS:1",
amountToWithdraw: "TESTKUDOS:3", amountToWithdraw: "TESTKUDOS:3",