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: fix getTransacti


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: fix getTransactionById for refreshes, test it
Date: Tue, 23 Jan 2024 23:51:00 +0100

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 aab96ecf6 wallet-core: fix getTransactionById for refreshes, test it
aab96ecf6 is described below

commit aab96ecf602d51fb682aa37d2182f9838cf27393
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Jan 23 23:50:36 2024 +0100

    wallet-core: fix getTransactionById for refreshes, test it
    
    Fixes bugs.taler.net/n/8234
---
 .../src/integrationtests/testrunner.ts             |  2 ++
 .../src/operations/transactions.ts                 | 38 +++++++++++++++-------
 2 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts 
b/packages/taler-harness/src/integrationtests/testrunner.ts
index 1b4bdc218..35b179d87 100644
--- a/packages/taler-harness/src/integrationtests/testrunner.ts
+++ b/packages/taler-harness/src/integrationtests/testrunner.ts
@@ -100,6 +100,7 @@ import { runPaymentDeletedTest } from 
"./test-payment-deleted.js";
 import { runWithdrawalNotifyBeforeTxTest } from 
"./test-withdrawal-notify-before-tx.js";
 import { runWalletDd48Test } from "./test-wallet-dd48.js";
 import { runMultiExchangeTest } from "./test-multiexchange.js";
+import { runWalletRefreshTest } from "./test-wallet-refresh.js";
 
 /**
  * Test runner.
@@ -189,6 +190,7 @@ const allTests: TestMainFunction[] = [
   runPaymentDeletedTest,
   runWalletDd48Test,
   runCurrencyScopeTest,
+  runWalletRefreshTest,
 ];
 
 export interface TestRunSpec {
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index 74bc20320..89f756ae9 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -280,8 +280,21 @@ export async function getTransactionById(
     }
 
     case TransactionType.Refresh: {
-      // FIXME: We should return info about the refresh here!
-      throw Error(`no tx for refresh`);
+      // FIXME: We should return info about the refresh here!;
+      const refreshGroupId = parsedTx.refreshGroupId;
+      return await ws.db.runReadOnlyTx(
+        ["refreshGroups", "operationRetries"],
+        async (tx) => {
+          const refreshGroupRec = await tx.refreshGroups.get(refreshGroupId);
+          if (!refreshGroupRec) {
+            throw Error("not found");
+          }
+          const retries = await tx.operationRetries.get(
+            TaskIdentifiers.forRefresh(refreshGroupRec),
+          );
+          return buildTransactionForRefresh(refreshGroupRec, retries);
+        },
+      );
     }
 
     case TransactionType.Reward: {
@@ -522,7 +535,7 @@ function buildTransactionForPeerPullCredit(
     const silentWithdrawalErrorForInvoice =
       wsrOrt?.lastError &&
       wsrOrt.lastError.code ===
-      TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE &&
+        TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE &&
       Object.values(wsrOrt.lastError.errorsPerCoin ?? {}).every((e) => {
         return (
           e.code === TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR &&
@@ -552,10 +565,10 @@ function buildTransactionForPeerPullCredit(
       kycUrl: pullCredit.kycUrl,
       ...(wsrOrt?.lastError
         ? {
-          error: silentWithdrawalErrorForInvoice
-            ? undefined
-            : wsrOrt.lastError,
-        }
+            error: silentWithdrawalErrorForInvoice
+              ? undefined
+              : wsrOrt.lastError,
+          }
         : {}),
     };
   }
@@ -770,7 +783,9 @@ function buildTransactionForRefresh(
     txState: computeRefreshTransactionState(refreshGroupRecord),
     txActions: computeRefreshTransactionActions(refreshGroupRecord),
     refreshReason: refreshGroupRecord.reason,
-    amountEffective: Amounts.stringify(Amounts.sub(outputAmount, 
inputAmount).amount),
+    amountEffective: Amounts.stringify(
+      Amounts.sub(outputAmount, inputAmount).amount,
+    ),
     amountRaw: Amounts.stringify(
       Amounts.zeroOfCurrency(refreshGroupRecord.currency),
     ),
@@ -960,9 +975,10 @@ export async function getWithdrawalTransactionByUri(
       x.operationRetries,
     ])
     .runReadWrite(async (tx) => {
-      const withdrawalGroupRecord = await 
tx.withdrawalGroups.indexes.byTalerWithdrawUri.get(
-        request.talerWithdrawUri,
-      );
+      const withdrawalGroupRecord =
+        await tx.withdrawalGroups.indexes.byTalerWithdrawUri.get(
+          request.talerWithdrawUri,
+        );
 
       if (!withdrawalGroupRecord) {
         return undefined;

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