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 exchange lis


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: fix exchange list filtering by scope, test it
Date: Wed, 04 Dec 2024 22:12:58 +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 c3893d9a8 wallet-core: fix exchange list filtering by scope, test it
c3893d9a8 is described below

commit c3893d9a80e201e4b64724794bd406e1999e2418
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Dec 4 22:12:52 2024 +0100

    wallet-core: fix exchange list filtering by scope, test it
---
 .../src/integrationtests/test-currency-scope.ts    | 27 +++++++++++++++++++++-
 packages/taler-wallet-core/src/exchanges.ts        | 16 +++++++++----
 2 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-currency-scope.ts 
b/packages/taler-harness/src/integrationtests/test-currency-scope.ts
index dd190817f..4f40a426e 100644
--- a/packages/taler-harness/src/integrationtests/test-currency-scope.ts
+++ b/packages/taler-harness/src/integrationtests/test-currency-scope.ts
@@ -17,7 +17,12 @@
 /**
  * Imports.
  */
-import { Duration, TalerCorebankApiClient, j2s } from "@gnu-taler/taler-util";
+import {
+  Duration,
+  ScopeType,
+  TalerCorebankApiClient,
+  j2s,
+} from "@gnu-taler/taler-util";
 import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
 import { defaultCoinConfig } from "../harness/denomStructures.js";
 import {
@@ -202,12 +207,32 @@ export async function runCurrencyScopeTest(t: 
GlobalTestState) {
     exchangeMasterPub: exchangeOne.masterPub,
   });
 
+  {
+    const exch1 = await walletClient.call(WalletApiOperation.ListExchanges, {
+      filterByScope: {
+        type: ScopeType.Global,
+        currency: "TESTKUDOS",
+      },
+    });
+    t.assertDeepEqual(exch1.exchanges.length, 1);
+  }
+
   await walletClient.call(WalletApiOperation.AddGlobalCurrencyExchange, {
     currency: "TESTKUDOS",
     exchangeBaseUrl: exchangeTwo.baseUrl,
     exchangeMasterPub: exchangeTwo.masterPub,
   });
 
+  {
+    const exch1 = await walletClient.call(WalletApiOperation.ListExchanges, {
+      filterByScope: {
+        type: ScopeType.Global,
+        currency: "TESTKUDOS",
+      },
+    });
+    t.assertDeepEqual(exch1.exchanges.length, 2);
+  }
+
   const ex = walletClient.call(
     WalletApiOperation.ListGlobalCurrencyExchanges,
     {},
diff --git a/packages/taler-wallet-core/src/exchanges.ts 
b/packages/taler-wallet-core/src/exchanges.ts
index a2073dbfa..bc47e1bc7 100644
--- a/packages/taler-wallet-core/src/exchanges.ts
+++ b/packages/taler-wallet-core/src/exchanges.ts
@@ -3612,6 +3612,9 @@ export async function checkExchangeInScopeTx(
   exchangeBaseUrl: string,
   scope: ScopeInfo,
 ): Promise<boolean> {
+  logger.trace(
+    `checking if exchange ${exchangeBaseUrl} is in scope ${j2s(scope)}`,
+  );
   switch (scope.type) {
     case ScopeType.Exchange: {
       return scope.url === exchangeBaseUrl;
@@ -3622,13 +3625,16 @@ export async function checkExchangeInScopeTx(
         exchangeBaseUrl,
       );
       if (!exchangeDetails) {
+        logger.trace(`no details for ${exchangeBaseUrl}`);
         return false;
       }
-      const gr = await tx.globalCurrencyExchanges.get([
-        exchangeDetails.currency,
-        exchangeBaseUrl,
-        exchangeDetails.masterPublicKey,
-      ]);
+      const gr =
+        await tx.globalCurrencyExchanges.indexes.byCurrencyAndUrlAndPub.get([
+          exchangeDetails.currency,
+          exchangeBaseUrl,
+          exchangeDetails.masterPublicKey,
+        ]);
+      logger.trace(`global currency record: ${j2s(gr)}`);
       return gr != null;
     }
     case ScopeType.Auditor:

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