gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: wallet-core: properly adjust


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: properly adjust visibleCoinCount in availability record when refreshing a fresh coin
Date: Wed, 05 Jun 2024 19:37:52 +0200

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

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

The following commit(s) were added to refs/heads/master by this push:
     new 93623571b wallet-core: properly adjust visibleCoinCount in 
availability record when refreshing a fresh coin
93623571b is described below

commit 93623571b0146c9a67085455bc3721e106a207cb
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Jun 5 19:37:49 2024 +0200

    wallet-core: properly adjust visibleCoinCount in availability record when 
refreshing a fresh coin
---
 packages/taler-harness/src/harness/harness.ts       |  4 ++++
 .../integrationtests/test-timetravel-autorefresh.ts | 21 ++++++---------------
 packages/taler-wallet-core/src/refresh.ts           |  7 +++++++
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/packages/taler-harness/src/harness/harness.ts 
b/packages/taler-harness/src/harness/harness.ts
index 136ec3d15..4fc462ddf 100644
--- a/packages/taler-harness/src/harness/harness.ts
+++ b/packages/taler-harness/src/harness/harness.ts
@@ -274,6 +274,7 @@ export class GlobalTestState {
   procs: ProcessWrapper[];
   servers: http.Server[];
   inShutdown: boolean = false;
+  stepSet: Set<string> = new Set();
   constructor(params: GlobalTestParams) {
     this.testDir = params.testDir;
     this.procs = [];
@@ -423,6 +424,9 @@ export class GlobalTestState {
     // Now we just log, later we may report the steps that were done
     // to easily see where the test hangs.
     console.info(`STEP: ${stepName}`);
+    if (this.stepSet.has(stepName)) {
+      throw Error(`duplicate step (${stepName})`);
+    }
   }
 }
 
diff --git 
a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts 
b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts
index 8b8b45c40..f3e3802e5 100644
--- a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts
+++ b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts
@@ -18,14 +18,12 @@
  * Imports.
  */
 import {
-  Amounts,
   ConfirmPayResultType,
   Duration,
   MerchantApiClient,
   NotificationType,
   PreparePayResultType,
   TalerCorebankApiClient,
-  j2s,
 } from "@gnu-taler/taler-util";
 import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
 import { makeNoFeeCoinConfig } from "../harness/denomStructures.js";
@@ -134,6 +132,7 @@ export async function runTimetravelAutorefreshTest(t: 
GlobalTestState) {
 
   const { walletClient } = await createWalletDaemonWithClient(t, {
     name: "w1",
+    persistent: true,
   });
 
   const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
@@ -160,9 +159,7 @@ export async function runTimetravelAutorefreshTest(t: 
GlobalTestState) {
   await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
   {
     const balance = await walletClient.call(WalletApiOperation.GetBalances, 
{});
-    t.assertTrue(
-      Amounts.cmp(balance.balances[0].available, "TESTKUDOS:15") === 0,
-    );
+    t.assertAmountEquals(balance.balances[0].available, "TESTKUDOS:15");
   }
 
   // Travel into the future, the deposit expiration is two years
@@ -180,13 +177,11 @@ export async function runTimetravelAutorefreshTest(t: 
GlobalTestState) {
   // The time travel should cause exchanges to update.
   t.logStep("The time travel should cause exchanges to update");
   await exchangeUpdated1Cond;
-  t.logStep("exchange updated, wahting tx");
+  t.logStep("exchange updated, waiting for tx");
   await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
   {
     const balance = await walletClient.call(WalletApiOperation.GetBalances, 
{});
-    t.assertTrue(
-      Amounts.cmp(balance.balances[0].available, "TESTKUDOS:15") === 0,
-    );
+    t.assertAmountEquals(balance.balances[0].available, "TESTKUDOS:15");
   }
 
   t.logStep("withdrawing second time");
@@ -203,9 +198,7 @@ export async function runTimetravelAutorefreshTest(t: 
GlobalTestState) {
 
   {
     const balance = await walletClient.call(WalletApiOperation.GetBalances, 
{});
-    t.assertTrue(
-      Amounts.cmp(balance.balances[0].available, "TESTKUDOS:35") === 0,
-    );
+    t.assertAmountEquals(balance.balances[0].available, "TESTKUDOS:35");
   }
 
   const exchangeUpdated2Cond = walletClient.waitForNotificationCond(
@@ -232,9 +225,7 @@ export async function runTimetravelAutorefreshTest(t: 
GlobalTestState) {
   await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
   {
     const balance = await walletClient.call(WalletApiOperation.GetBalances, 
{});
-    t.assertTrue(
-      Amounts.cmp(balance.balances[0].available, "TESTKUDOS:35") === 0,
-    );
+    t.assertAmountEquals(balance.balances[0].available, "TESTKUDOS:35");
   }
 
   // At this point, the original coins should've been refreshed.
diff --git a/packages/taler-wallet-core/src/refresh.ts 
b/packages/taler-wallet-core/src/refresh.ts
index 7dcb755be..a8f1cc61d 100644
--- a/packages/taler-wallet-core/src/refresh.ts
+++ b/packages/taler-wallet-core/src/refresh.ts
@@ -1584,6 +1584,13 @@ async function applyRefreshToOldCoins(
           `no fresh coins for ${coin.denomPubHash}`,
         );
         coinAv.freshCoinCount--;
+        if (coin.visible) {
+          if (!coinAv.visibleCoinCount) {
+            logger.error("coin availability inconsistent");
+          } else {
+            coinAv.visibleCoinCount--;
+          }
+        }
         await tx.coinAvailability.put(coinAv);
         break;
       }

-- 
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]