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: count peer-push-


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: count peer-push-debit towards pending outgoing balance
Date: Thu, 28 Mar 2024 12:27:44 +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 4b9cbe580 wallet-core: count peer-push-debit towards pending outgoing 
balance
4b9cbe580 is described below

commit 4b9cbe58025bf7082d0c79ee596200628b5d8c47
Author: Florian Dold <florian@dold.me>
AuthorDate: Thu Mar 28 12:27:26 2024 +0100

    wallet-core: count peer-push-debit towards pending outgoing balance
    
    Also check balance in the integration test.
---
 .../src/integrationtests/test-peer-to-peer-push.ts | 14 +++++++++++++
 packages/taler-wallet-core/src/balance.ts          | 24 ++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git 
a/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts 
b/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
index 5a1959cc6..21e0d384a 100644
--- a/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
+++ b/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
@@ -76,6 +76,15 @@ export async function runPeerToPeerPushTest(t: 
GlobalTestState) {
     ),
   );
 
+  const checkResp0 = await w1.walletClient.call(
+    WalletApiOperation.CheckPeerPushDebit,
+    {
+      amount: "TESTKUDOS:5" as AmountString,
+    },
+  );
+
+  t.assertAmountEquals(checkResp0.amountEffective, "TESTKUDOS:5.49");
+
   {
     const resp = await w1.walletClient.call(
       WalletApiOperation.InitiatePeerPushDebit,
@@ -91,6 +100,11 @@ export async function runPeerToPeerPushTest(t: 
GlobalTestState) {
     console.log(resp);
   }
 
+  {
+    const bal = await w1.walletClient.call(WalletApiOperation.GetBalances, {});
+    t.assertAmountEquals(bal.balances[0].pendingOutgoing, "TESTKUDOS:5.49");
+  }
+
   await w1.walletClient.call(WalletApiOperation.TestingWaitRefreshesFinal, {});
 
   const resp = await w1.walletClient.call(
diff --git a/packages/taler-wallet-core/src/balance.ts 
b/packages/taler-wallet-core/src/balance.ts
index 50996b8de..67ce73d41 100644
--- a/packages/taler-wallet-core/src/balance.ts
+++ b/packages/taler-wallet-core/src/balance.ts
@@ -70,6 +70,7 @@ import {
   ExchangeEntryDbRecordStatus,
   OPERATION_STATUS_ACTIVE_FIRST,
   OPERATION_STATUS_ACTIVE_LAST,
+  PeerPushDebitStatus,
   RefreshGroupRecord,
   RefreshOperationStatus,
   WalletDbReadOnlyTransaction,
@@ -295,6 +296,7 @@ export async function getBalancesInsideTransaction(
       "withdrawalGroups",
       "globalCurrencyAuditors",
       "globalCurrencyExchanges",
+      "peerPushDebit",
     ]
   >,
 ): Promise<BalancesResponse> {
@@ -399,6 +401,27 @@ export async function getBalancesInsideTransaction(
       );
     });
 
+  await tx.peerPushDebit.indexes.byStatus
+    .iter(keyRangeActive)
+    .forEachAsync(async (ppdRecord) => {
+      switch (ppdRecord.status) {
+        case PeerPushDebitStatus.AbortingDeletePurse:
+        case PeerPushDebitStatus.SuspendedAbortingDeletePurse:
+        case PeerPushDebitStatus.SuspendedReady:
+        case PeerPushDebitStatus.SuspendedReady:
+        case PeerPushDebitStatus.PendingCreatePurse:
+        case PeerPushDebitStatus.SuspendedCreatePurse: {
+          const currency = Amounts.currencyOf(ppdRecord.amount);
+          await balanceStore.addPendingOutgoing(
+            currency,
+            ppdRecord.exchangeBaseUrl,
+            ppdRecord.totalCost,
+          );
+          break;
+        }
+      }
+    });
+
   await tx.depositGroups.indexes.byStatus
     .iter(keyRangeActive)
     .forEachAsync(async (dgRecord) => {
@@ -460,6 +483,7 @@ export async function getBalances(
       "purchases",
       "refreshGroups",
       "withdrawalGroups",
+      "peerPushDebit",
     ],
     async (tx) => {
       return getBalancesInsideTransaction(wex, tx);

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