From 3cf2d4cba919203065f210f80f3f081948ad257a Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 9 Feb 2023 22:44:36 +0100 Subject: wallet-core: expose withdrawal progress, towards huge withdrawal test --- packages/taler-util/src/notifications.ts | 2 ++ packages/taler-util/src/twrpc-impl.node.ts | 24 ++++++------------------ 2 files changed, 8 insertions(+), 18 deletions(-) (limited to 'packages/taler-util') diff --git a/packages/taler-util/src/notifications.ts b/packages/taler-util/src/notifications.ts index c50cc72de..bc1c4b71f 100644 --- a/packages/taler-util/src/notifications.ts +++ b/packages/taler-util/src/notifications.ts @@ -83,6 +83,8 @@ export interface ReserveNotYetFoundNotification { export interface CoinWithdrawnNotification { type: NotificationType.CoinWithdrawn; + numWithdrawn: number; + numTotal: number; } export interface RefundStartedNotification { diff --git a/packages/taler-util/src/twrpc-impl.node.ts b/packages/taler-util/src/twrpc-impl.node.ts index b6333da51..30e362e5b 100644 --- a/packages/taler-util/src/twrpc-impl.node.ts +++ b/packages/taler-util/src/twrpc-impl.node.ts @@ -30,7 +30,6 @@ const logger = new Logger("twrpc-impl.node.ts"); function readStreamLinewise(args: ReadLinewiseArgs): void { let chunks: Uint8Array[] = []; args.sock.on("data", (buf: Uint8Array) => { - logger.info(`received ${buf.length} bytes`); // Process all newlines in the newly received buffer while (1) { const newlineIdx = buf.indexOf("\n".charCodeAt(0)); @@ -78,28 +77,23 @@ export async function connectRpc(args: RpcConnectArgs): Promise { sock: client, onLine(line) { const lineStr = bytesToString(line); - logger.info(`got line from server: ${lineStr}`); // Are we currently parsing the body of a request? if (!parsingBody) { const strippedLine = lineStr.trim(); if (strippedLine == "%message") { - logger.info("got message start"); parsingBody = "message"; } else if (strippedLine == "%hello-from-server") { - logger.info("got hello from server"); } else if (strippedLine.startsWith("%error:")) { - logger.info("got error from server, disconnecting"); client.end(); res.onDisconnect(); } else { - logger.info("got unknown request"); + logger.warn("got unknown request"); client.write("%error: invalid message\n"); client.end(); } } else if (parsingBody == "message") { const strippedLine = lineStr.trim(); if (strippedLine == "%end") { - logger.info("finished request"); let req = bodyChunks.join(""); let reqJson: any = undefined; try { @@ -109,7 +103,6 @@ export async function connectRpc(args: RpcConnectArgs): Promise { logger.info(`message was: ${req}`); } if (reqJson !== undefined) { - logger.info(`request: ${req}`); res.onMessage(reqJson); } else { client.write("%error: invalid JSON"); @@ -149,7 +142,6 @@ export async function runRpcServer(args: RpcServerArgs): Promise { let parsingBody: string | undefined = undefined; let bodyChunks: string[] = []; - logger.info("got new connection"); sock.write("%hello-from-server\n"); const handlers = args.onConnect({ sendResponse(message) { @@ -161,21 +153,19 @@ export async function runRpcServer(args: RpcServerArgs): Promise { }); sock.on("error", (err) => { - logger.info(`connection error: ${err}`); + logger.error(`connection error: ${err}`); }); function processLine(line: Uint8Array) { const lineStr = bytesToString(line); - logger.info(`got line: ${lineStr}`); if (!parsingBody) { const strippedLine = lineStr.trim(); if (strippedLine == "%request") { - logger.info("got request start"); parsingBody = "request"; } else if (strippedLine === "%hello-from-client") { - console.log("got hello from client"); + // Nothing to do, ignore hello } else if (strippedLine.startsWith("%error:")) { - console.log("got error from client"); + logger.warn("got error from client"); sock.end(); handlers.onDisconnect(); } else { @@ -186,7 +176,6 @@ export async function runRpcServer(args: RpcServerArgs): Promise { } else if (parsingBody == "request") { const strippedLine = lineStr.trim(); if (strippedLine == "%end") { - logger.info("finished request"); let req = bodyChunks.join(""); let reqJson: any = undefined; try { @@ -195,7 +184,6 @@ export async function runRpcServer(args: RpcServerArgs): Promise { logger.warn("JSON request from client was invalid"); } if (reqJson !== undefined) { - logger.info(`request: ${req}`); handlers.onMessage(reqJson); } else { sock.write("%error: invalid JSON"); @@ -207,7 +195,7 @@ export async function runRpcServer(args: RpcServerArgs): Promise { bodyChunks.push(lineStr); } } else { - logger.info("invalid parser state"); + logger.error("invalid parser state"); sock.write("%error: internal error\n"); sock.end(); } @@ -219,7 +207,7 @@ export async function runRpcServer(args: RpcServerArgs): Promise { }); sock.on("close", (hadError: boolean) => { - logger.info(`connection closed, hadError=${hadError}`); + logger.trace(`connection closed, hadError=${hadError}`); handlers.onDisconnect(); }); }); -- cgit v1.2.3