aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-02-02 20:20:58 +0100
committerFlorian Dold <florian@dold.me>2023-02-02 20:21:04 +0100
commit96101238afb82d200cf9d5005ffc2fc0391f23e4 (patch)
treedcade21b174dcc7e2d479de61bf53b07b2e3a187 /packages/taler-util
parentab9a5e1e8ac60bbf55104e84490e581dfad5de02 (diff)
harness,wallet-cli: notification-based testing with RPC wallet
Diffstat (limited to 'packages/taler-util')
-rw-r--r--packages/taler-util/src/twrpc-impl.node.ts12
-rw-r--r--packages/taler-util/src/twrpc.ts2
2 files changed, 11 insertions, 3 deletions
diff --git a/packages/taler-util/src/twrpc-impl.node.ts b/packages/taler-util/src/twrpc-impl.node.ts
index 52ab65b73..b6333da51 100644
--- a/packages/taler-util/src/twrpc-impl.node.ts
+++ b/packages/taler-util/src/twrpc-impl.node.ts
@@ -54,6 +54,9 @@ export async function connectRpc<T>(args: RpcConnectArgs<T>): Promise<T> {
let sockFilename = args.socketFilename;
return new Promise((resolve, reject) => {
const client = net.createConnection(sockFilename);
+ client.on("error", (e) => {
+ reject(e);
+ });
client.on("connect", () => {
let parsingBody: string | undefined = undefined;
let bodyChunks: string[] = [];
@@ -102,7 +105,8 @@ export async function connectRpc<T>(args: RpcConnectArgs<T>): Promise<T> {
try {
reqJson = JSON.parse(req);
} catch (e) {
- logger.warn("JSON request was invalid");
+ logger.warn("JSON message from server was invalid");
+ logger.info(`message was: ${req}`);
}
if (reqJson !== undefined) {
logger.info(`request: ${req}`);
@@ -112,6 +116,7 @@ export async function connectRpc<T>(args: RpcConnectArgs<T>): Promise<T> {
client.end();
}
bodyChunks = [];
+ parsingBody = undefined;
} else {
bodyChunks.push(lineStr);
}
@@ -187,7 +192,7 @@ export async function runRpcServer(args: RpcServerArgs): Promise<void> {
try {
reqJson = JSON.parse(req);
} catch (e) {
- logger.warn("JSON request was invalid");
+ logger.warn("JSON request from client was invalid");
}
if (reqJson !== undefined) {
logger.info(`request: ${req}`);
@@ -197,6 +202,7 @@ export async function runRpcServer(args: RpcServerArgs): Promise<void> {
sock.end();
}
bodyChunks = [];
+ parsingBody = undefined;
} else {
bodyChunks.push(lineStr);
}
@@ -217,6 +223,6 @@ export async function runRpcServer(args: RpcServerArgs): Promise<void> {
handlers.onDisconnect();
});
});
- server.listen("wallet-core.sock");
+ server.listen(args.socketFilename);
});
}
diff --git a/packages/taler-util/src/twrpc.ts b/packages/taler-util/src/twrpc.ts
index 368e04e27..d221630d0 100644
--- a/packages/taler-util/src/twrpc.ts
+++ b/packages/taler-util/src/twrpc.ts
@@ -14,6 +14,8 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
+import { CoreApiResponse } from "./wallet-types.js";
+
/**
* Implementation for the wallet-core IPC protocol.
*