gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated (a8c5a9696 -> 1a3040d87)


From: gnunet
Subject: [taler-wallet-core] branch master updated (a8c5a9696 -> 1a3040d87)
Date: Fri, 10 Feb 2023 00:07:55 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a change to branch master
in repository wallet-core.

    from a8c5a9696 impl accout management and refactor
     new 3cf2d4cba wallet-core: expose withdrawal progress, towards huge 
withdrawal test
     new ebb3e7e33 build system: convenience target to install CLIs
     new 1a3040d87 harness: allow running tests without timeout

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Makefile                                           |  6 +++
 packages/taler-harness/Makefile                    | 10 ++--
 packages/taler-harness/src/harness/harness.ts      |  1 -
 packages/taler-harness/src/index.ts                |  4 ++
 ...-withdrawal-high.ts => test-withdrawal-huge.ts} | 26 ++++++----
 .../src/integrationtests/testrunner.ts             | 13 +++--
 packages/taler-util/src/notifications.ts           |  2 +
 packages/taler-util/src/twrpc-impl.node.ts         | 24 +++------
 packages/taler-wallet-cli/Makefile                 | 10 ++--
 .../taler-wallet-core/src/operations/withdraw.ts   | 59 ++++++++++++++++++----
 packages/taler-wallet-core/src/remote.ts           |  1 -
 11 files changed, 106 insertions(+), 50 deletions(-)
 rename packages/taler-harness/src/integrationtests/{test-withdrawal-high.ts => 
test-withdrawal-huge.ts} (78%)

diff --git a/Makefile b/Makefile
index 92e60843e..035c385e9 100644
--- a/Makefile
+++ b/Makefile
@@ -105,3 +105,9 @@ lint:
 
 install: compile
        @echo Please run \'make install\' from one of the directories in 
packages/\'
+
+# Install taler-wallet-cli and taler-harness
+install-tools:
+       pnpm install --frozen-lockfile --filter @gnu-taler/taler-wallet-cli... 
--filter @gnu-taler/taler-harness...
+       make -C packages/taler-wallet-cli install-nodeps
+       make -C packages/taler-harness install-nodeps
diff --git a/packages/taler-harness/Makefile b/packages/taler-harness/Makefile
index 8bbca5831..7ccfab205 100644
--- a/packages/taler-harness/Makefile
+++ b/packages/taler-harness/Makefile
@@ -15,9 +15,8 @@ warn-noprefix:
 install: warn-noprefix
 else
 install_target = $(prefix)/lib/taler-harness
-.PHONY: install install-nodeps
-install:
-       pnpm install --frozen-lockfile --filter @gnu-taler/taler-harness...
+.PHONY: install deps install-nodeps
+install-nodeps:
        ./build.mjs
        install -d $(prefix)/bin
        install -d $(install_target)/bin
@@ -28,4 +27,9 @@ install:
        install ./dist/taler-harness-bundled.cjs.map 
$(install_target)/node_modules/taler-harness/dist/
        install ./bin/taler-harness.mjs 
$(install_target)/node_modules/taler-harness/bin/
        ln -sf 
$(install_target)/node_modules/taler-harness/bin/taler-harness.mjs 
$(prefix)/bin/taler-harness
+deps:
+       pnpm install --frozen-lockfile --filter @gnu-taler/taler-harness...
+install:
+       $(MAKE) deps
+       $(MAKE) install-nodeps
 endif
diff --git a/packages/taler-harness/src/harness/harness.ts 
b/packages/taler-harness/src/harness/harness.ts
index e95dea0c6..b2c73c9ab 100644
--- a/packages/taler-harness/src/harness/harness.ts
+++ b/packages/taler-harness/src/harness/harness.ts
@@ -1981,7 +1981,6 @@ export class WalletClient {
           walletClient.args.onNotification(n);
         }
         waiter.notify(n);
-        console.log("got notification from wallet-core in WalletClient");
       },
     });
     this.remoteWallet = w;
diff --git a/packages/taler-harness/src/index.ts 
b/packages/taler-harness/src/index.ts
index a6decc4ab..e4ee25dae 100644
--- a/packages/taler-harness/src/index.ts
+++ b/packages/taler-harness/src/index.ts
@@ -271,6 +271,9 @@ testingCli
   .flag("quiet", ["--quiet"], {
     help: "Produce less output.",
   })
+  .flag("noTimeout", ["--no-timeout"], {
+    help: "Do not time out tests."
+  })
   .action(async (args) => {
     await runTests({
       includePattern: args.runIntegrationtests.pattern,
@@ -278,6 +281,7 @@ testingCli
       dryRun: args.runIntegrationtests.dryRun,
       verbosity: args.runIntegrationtests.quiet ? 0 : 1,
       includeExperimental: args.runIntegrationtests.experimental ?? false,
+      noTimeout: args.runIntegrationtests.noTimeout,
     });
   });
 
diff --git 
a/packages/taler-harness/src/integrationtests/test-withdrawal-high.ts 
b/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts
similarity index 78%
rename from packages/taler-harness/src/integrationtests/test-withdrawal-high.ts
rename to packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts
index deb0e6dde..248931d71 100644
--- a/packages/taler-harness/src/integrationtests/test-withdrawal-high.ts
+++ b/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts
@@ -19,20 +19,21 @@
  */
 import {
   GlobalTestState,
-  WalletCli,
   setupDb,
   ExchangeService,
   FakebankService,
+  WalletService,
+  WalletClient,
 } from "../harness/harness.js";
 import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
 import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
-import { URL } from "@gnu-taler/taler-util";
+import { NotificationType, URL } from "@gnu-taler/taler-util";
 
 /**
  * Withdraw a high amount.  Mostly intended
  * as a perf test.
  */
-export async function runWithdrawalHighTest(t: GlobalTestState) {
+export async function runWithdrawalHugeTest(t: GlobalTestState) {
   // Set up test environment
 
   const db = await setupDb(t);
@@ -71,7 +72,16 @@ export async function runWithdrawalHighTest(t: 
GlobalTestState) {
 
   console.log("setup done!");
 
-  const wallet = new WalletCli(t);
+  const walletService = new WalletService(t, { name: "w1" });
+  await walletService.start();
+  await walletService.pingUntilAvailable();
+
+  const wallet = new WalletClient({
+    unixPath: walletService.socketPath,
+  });
+  await wallet.connect();
+
+  const withdrawalFinishedCond = wallet.waitForNotificationCond((wn) => 
wn.type === NotificationType.WithdrawGroupFinished);
 
   await wallet.client.call(WalletApiOperation.AddExchange, {
     exchangeBaseUrl: exchange.baseUrl,
@@ -85,15 +95,13 @@ export async function runWithdrawalHighTest(t: 
GlobalTestState) {
 
   await exchange.runWirewatchOnce();
 
-  await wallet.runUntilDone();
+  await withdrawalFinishedCond;
 
   // Check balance
 
   const balResp = await wallet.client.call(WalletApiOperation.GetBalances, {});
   console.log(balResp);
-
-  await t.shutdown();
 }
 
-runWithdrawalHighTest.suites = ["wallet-perf"];
-runWithdrawalHighTest.excludeByDefault = true;
+runWithdrawalHugeTest.suites = ["wallet-perf"];
+runWithdrawalHugeTest.excludeByDefault = true;
diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts 
b/packages/taler-harness/src/integrationtests/testrunner.ts
index 3d70e6860..4bad3dac2 100644
--- a/packages/taler-harness/src/integrationtests/testrunner.ts
+++ b/packages/taler-harness/src/integrationtests/testrunner.ts
@@ -95,7 +95,7 @@ import { runAgeRestrictionsPeerTest } from 
"./test-age-restrictions-peer.js";
 import { runWalletNotificationsTest } from "./test-wallet-notifications.js";
 import { runAgeRestrictionsMixedMerchantTest } from 
"./test-age-restrictions-mixed-merchant.js";
 import { runWalletCryptoWorkerTest } from "./test-wallet-cryptoworker.js";
-import { runWithdrawalHighTest } from "./test-withdrawal-high.js";
+import { runWithdrawalHugeTest } from "./test-withdrawal-huge.js";
 import { runKycTest } from "./test-kyc.js";
 import { runPaymentAbortTest } from "./test-payment-abort.js";
 import { runWithdrawalFeesTest } from "./test-withdrawal-fees.js";
@@ -190,7 +190,7 @@ const allTests: TestMainFunction[] = [
   runWithdrawalBankIntegratedTest,
   runWithdrawalFakebankTest,
   runWithdrawalFeesTest,
-  runWithdrawalHighTest,
+  runWithdrawalHugeTest,
 ];
 
 export interface TestRunSpec {
@@ -198,6 +198,7 @@ export interface TestRunSpec {
   suiteSpec?: string;
   dryRun?: boolean;
   includeExperimental: boolean;
+  noTimeout: boolean;
   verbosity: number;
 }
 
@@ -331,9 +332,13 @@ export async function runTests(spec: TestRunSpec) {
     const defaultTimeout = 60000;
     const testTimeoutMs = testCase.timeoutMs ?? defaultTimeout;
 
-    console.log(`running ${testName} with timeout ${testTimeoutMs}ms`);
+    if (spec.noTimeout) {
+      console.log(`running ${testName}, no timeout`);
+    } else {
+      console.log(`running ${testName} with timeout ${testTimeoutMs}ms`);
+    }
 
-    const { token } = CancellationToken.timeout(testTimeoutMs);
+    const token = spec.noTimeout ? CancellationToken.CONTINUE : 
CancellationToken.timeout(testTimeoutMs).token;
 
     const resultPromise: Promise<TestRunResult> = new Promise(
       (resolve, reject) => {
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<T>(args: 
RpcConnectArgs<T>): Promise<T> {
         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<T>(args: 
RpcConnectArgs<T>): Promise<T> {
                 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<void> {
       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<void> {
       });
 
       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<void> {
         } 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<void> {
               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<void> {
             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<void> {
       });
 
       sock.on("close", (hadError: boolean) => {
-        logger.info(`connection closed, hadError=${hadError}`);
+        logger.trace(`connection closed, hadError=${hadError}`);
         handlers.onDisconnect();
       });
     });
diff --git a/packages/taler-wallet-cli/Makefile 
b/packages/taler-wallet-cli/Makefile
index 4cd9aeb90..98116bbbd 100644
--- a/packages/taler-wallet-cli/Makefile
+++ b/packages/taler-wallet-cli/Makefile
@@ -15,9 +15,8 @@ warn-noprefix:
 install: warn-noprefix
 else
 install_target = $(prefix)/lib/taler-wallet-cli
-.PHONY: install install-nodeps
-install:
-       pnpm install --frozen-lockfile --filter @gnu-taler/taler-wallet-cli...
+.PHONY: install install-nodeps deps
+install-nodeps:
        install -d $(prefix)/bin
        install -d $(install_target)/bin
        install -d $(install_target)/node_modules/taler-wallet-cli
@@ -27,4 +26,9 @@ install:
        install ./dist/taler-wallet-cli.mjs.map 
$(install_target)/node_modules/taler-wallet-cli/dist/
        install ./bin/taler-wallet-cli.mjs 
$(install_target)/node_modules/taler-wallet-cli/bin/
        ln -sf 
$(install_target)/node_modules/taler-wallet-cli/bin/taler-wallet-cli.mjs 
$(prefix)/bin/taler-wallet-cli
+deps:
+       pnpm install --frozen-lockfile --filter @gnu-taler/taler-wallet-cli...
+install:
+       $(MAKE) deps
+       $(MAKE) install-nodeps
 endif
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index 667b97361..caa280fe5 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -462,9 +462,10 @@ async function processPlanchetGenerate(
  */
 async function processPlanchetExchangeRequest(
   ws: InternalWalletState,
-  withdrawalGroup: WithdrawalGroupRecord,
+  wgContext: WithdrawalGroupContext,
   coinIdx: number,
 ): Promise<WithdrawResponse | undefined> {
+  const withdrawalGroup: WithdrawalGroupRecord = wgContext.wgRecord;
   logger.info(
     `processing planchet exchange request 
${withdrawalGroup.withdrawalGroupId}/${coinIdx}`,
   );
@@ -593,8 +594,9 @@ async function processPlanchetExchangeRequest(
  */
 async function processPlanchetExchangeBatchRequest(
   ws: InternalWalletState,
-  withdrawalGroup: WithdrawalGroupRecord,
+  wgContext: WithdrawalGroupContext,
 ): Promise<WithdrawBatchResponse | undefined> {
+  const withdrawalGroup: WithdrawalGroupRecord = wgContext.wgRecord;
   logger.info(
     `processing planchet exchange batch request 
${withdrawalGroup.withdrawalGroupId}`,
   );
@@ -671,10 +673,11 @@ async function processPlanchetExchangeBatchRequest(
 
 async function processPlanchetVerifyAndStoreCoin(
   ws: InternalWalletState,
-  withdrawalGroup: WithdrawalGroupRecord,
+  wgContext: WithdrawalGroupContext,
   coinIdx: number,
   resp: WithdrawResponse,
 ): Promise<void> {
+  const withdrawalGroup = wgContext.wgRecord;
   const d = await ws.db
     .mktx((x) => [x.withdrawalGroups, x.planchets, x.denominations])
     .runReadOnly(async (tx) => {
@@ -786,6 +789,8 @@ async function processPlanchetVerifyAndStoreCoin(
 
   const planchetCoinPub = planchet.coinPub;
 
+  wgContext.planchetsFinished.add(planchet.coinPub);
+
   // Check if this is the first time that the whole
   // withdrawal succeeded.  If so, mark the withdrawal
   // group as finished.
@@ -811,6 +816,8 @@ async function processPlanchetVerifyAndStoreCoin(
   if (firstSuccess) {
     ws.notify({
       type: NotificationType.CoinWithdrawn,
+      numTotal: wgContext.numPlanchets,
+      numWithdrawn: wgContext.planchetsFinished.size,
     });
   }
 }
@@ -983,6 +990,21 @@ enum BankStatusResultCode {
   Aborted = "aborted",
 }
 
+/**
+ * Withdrawal context that is kept in-memory.
+ *
+ * Used to store some cached info during a withdrawal operation.
+ */
+export interface WithdrawalGroupContext {
+  numPlanchets: number;
+  planchetsFinished: Set<string>;
+
+  /**
+   * Cached withdrawal group record from the database.
+   */
+  wgRecord: WithdrawalGroupRecord;
+}
+
 export async function processWithdrawalGroup(
   ws: InternalWalletState,
   withdrawalGroupId: string,
@@ -1122,8 +1144,27 @@ export async function processWithdrawalGroup(
     .map((x) => x.count)
     .reduce((a, b) => a + b);
 
+  const wgContext: WithdrawalGroupContext = {
+    numPlanchets: numTotalCoins,
+    planchetsFinished: new Set<string>(),
+    wgRecord: withdrawalGroup,
+  };
+
   let work: Promise<void>[] = [];
 
+  await ws.db
+    .mktx((x) => [x.planchets])
+    .runReadOnly(async (tx) => {
+      const planchets = await tx.planchets.indexes.byGroup.getAll(
+        withdrawalGroupId,
+      );
+      for (const p of planchets) {
+        if (p.planchetStatus === PlanchetStatus.WithdrawalDone) {
+          wgContext.planchetsFinished.add(p.coinPub);
+        }
+      }
+    });
+
   for (let i = 0; i < numTotalCoins; i++) {
     work.push(processPlanchetGenerate(ws, withdrawalGroup, i));
   }
@@ -1134,7 +1175,7 @@ export async function processWithdrawalGroup(
   work = [];
 
   if (ws.batchWithdrawal) {
-    const resp = await processPlanchetExchangeBatchRequest(ws, 
withdrawalGroup);
+    const resp = await processPlanchetExchangeBatchRequest(ws, wgContext);
     if (!resp) {
       throw Error("unable to do batch withdrawal");
     }
@@ -1142,7 +1183,7 @@ export async function processWithdrawalGroup(
       work.push(
         processPlanchetVerifyAndStoreCoin(
           ws,
-          withdrawalGroup,
+          wgContext,
           coinIdx,
           resp.ev_sigs[coinIdx],
         ),
@@ -1150,16 +1191,12 @@ export async function processWithdrawalGroup(
     }
   } else {
     for (let coinIdx = 0; coinIdx < numTotalCoins; coinIdx++) {
-      const resp = await processPlanchetExchangeRequest(
-        ws,
-        withdrawalGroup,
-        coinIdx,
-      );
+      const resp = await processPlanchetExchangeRequest(ws, wgContext, 
coinIdx);
       if (!resp) {
         continue;
       }
       work.push(
-        processPlanchetVerifyAndStoreCoin(ws, withdrawalGroup, coinIdx, resp),
+        processPlanchetVerifyAndStoreCoin(ws, wgContext, coinIdx, resp),
       );
     }
   }
diff --git a/packages/taler-wallet-core/src/remote.ts 
b/packages/taler-wallet-core/src/remote.ts
index a240d4606..2628fea07 100644
--- a/packages/taler-wallet-core/src/remote.ts
+++ b/packages/taler-wallet-core/src/remote.ts
@@ -110,7 +110,6 @@ export async function createRemoteWallet(
             }
             h.promiseCapability.resolve(m as any);
           } else if (type === "notification") {
-            logger.info("got notification");
             if (args.notificationHandler) {
               args.notificationHandler((m as any).payload);
             }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]