gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: fix idb bug, p2p integration


From: gnunet
Subject: [taler-wallet-core] branch master updated: fix idb bug, p2p integration test
Date: Wed, 24 Aug 2022 21:07:24 +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 bf516a77 fix idb bug, p2p integration test
bf516a77 is described below

commit bf516a77e8d38e81ee9816d6ee0ab29bcb878e84
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Aug 24 21:07:09 2022 +0200

    fix idb bug, p2p integration test
---
 packages/idb-bridge/src/util/extractKey.ts         |  2 +-
 packages/idb-bridge/src/util/getIndexKeys.test.ts  |  4 +---
 packages/idb-bridge/src/util/getIndexKeys.ts       |  3 +++
 .../src/integrationtests/test-peer-to-peer-push.ts | 26 ++++++++++++++--------
 .../src/operations/peer-to-peer.ts                 |  6 +++++
 5 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/packages/idb-bridge/src/util/extractKey.ts 
b/packages/idb-bridge/src/util/extractKey.ts
index b768ed92..6a3d468e 100644
--- a/packages/idb-bridge/src/util/extractKey.ts
+++ b/packages/idb-bridge/src/util/extractKey.ts
@@ -59,7 +59,7 @@ export const extractKey = (keyPath: IDBKeyPath | 
IDBKeyPath[], value: any) => {
       remainingKeyPath = null;
     }
 
-    if (!object.hasOwnProperty(identifier)) {
+    if (object == null || !object.hasOwnProperty(identifier)) {
       return;
     }
 
diff --git a/packages/idb-bridge/src/util/getIndexKeys.test.ts 
b/packages/idb-bridge/src/util/getIndexKeys.test.ts
index d3bbd519..1d477de1 100644
--- a/packages/idb-bridge/src/util/getIndexKeys.test.ts
+++ b/packages/idb-bridge/src/util/getIndexKeys.test.ts
@@ -26,9 +26,7 @@ test("basics", (t) => {
 
   t.deepEqual(getIndexKeys([1, 2, 3], "", false), [[1, 2, 3]]);
 
-  t.throws(() => {
-    getIndexKeys({ foo: 42 }, "foo.bar", false);
-  });
+  t.deepEqual(getIndexKeys({ foo: 42 }, "foo.bar", false), []);
 
   t.deepEqual(getIndexKeys({ foo: 42 }, "foo", true), [42]);
   t.deepEqual(
diff --git a/packages/idb-bridge/src/util/getIndexKeys.ts 
b/packages/idb-bridge/src/util/getIndexKeys.ts
index 17e77e63..c2421f26 100644
--- a/packages/idb-bridge/src/util/getIndexKeys.ts
+++ b/packages/idb-bridge/src/util/getIndexKeys.ts
@@ -38,6 +38,9 @@ export function getIndexKeys(
     return keys;
   } else if (typeof keyPath === "string" || Array.isArray(keyPath)) {
     let key = extractKey(keyPath, value);
+    if (key == null) {
+      return [];
+    }
     return [valueToKey(key)];
   } else {
     throw Error(`unsupported key path: ${typeof keyPath}`);
diff --git 
a/packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer-push.ts 
b/packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer-push.ts
index 11360f6e..bf65731d 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer-push.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer-push.ts
@@ -18,7 +18,7 @@
  * Imports.
  */
 import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { GlobalTestState } from "../harness/harness.js";
+import { GlobalTestState, WalletCli } from "../harness/harness.js";
 import {
   createSimpleTestkudosEnvironment,
   withdrawViaBank,
@@ -30,16 +30,23 @@ import {
 export async function runPeerToPeerPushTest(t: GlobalTestState) {
   // Set up test environment
 
-  const { wallet, bank, exchange, merchant } =
-    await createSimpleTestkudosEnvironment(t);
+  const { bank, exchange } = await createSimpleTestkudosEnvironment(t);
+
+  const wallet1 = new WalletCli(t, "w1");
+  const wallet2 = new WalletCli(t, "w2");
 
   // Withdraw digital cash into the wallet.
 
-  await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" });
+  await withdrawViaBank(t, {
+    wallet: wallet1,
+    bank,
+    exchange,
+    amount: "TESTKUDOS:20",
+  });
 
-  await wallet.runUntilDone();
+  await wallet1.runUntilDone();
 
-  const resp = await wallet.client.call(
+  const resp = await wallet1.client.call(
     WalletApiOperation.InitiatePeerPushPayment,
     {
       amount: "TESTKUDOS:5",
@@ -51,7 +58,7 @@ export async function runPeerToPeerPushTest(t: 
GlobalTestState) {
 
   console.log(resp);
 
-  const checkResp = await wallet.client.call(
+  const checkResp = await wallet2.client.call(
     WalletApiOperation.CheckPeerPushPayment,
     {
       talerUri: resp.talerUri,
@@ -60,7 +67,7 @@ export async function runPeerToPeerPushTest(t: 
GlobalTestState) {
 
   console.log(checkResp);
 
-  const acceptResp = await wallet.client.call(
+  const acceptResp = await wallet2.client.call(
     WalletApiOperation.AcceptPeerPushPayment,
     {
       peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId,
@@ -69,7 +76,8 @@ export async function runPeerToPeerPushTest(t: 
GlobalTestState) {
 
   console.log(acceptResp);
 
-  await wallet.runUntilDone();
+  await wallet1.runUntilDone();
+  await wallet2.runUntilDone();
 }
 
 runPeerToPeerPushTest.suites = ["wallet"];
diff --git a/packages/taler-wallet-core/src/operations/peer-to-peer.ts 
b/packages/taler-wallet-core/src/operations/peer-to-peer.ts
index 7ac165f9..ddfaa082 100644
--- a/packages/taler-wallet-core/src/operations/peer-to-peer.ts
+++ b/packages/taler-wallet-core/src/operations/peer-to-peer.ts
@@ -72,6 +72,7 @@ import { checkDbInvariant } from "../util/invariants.js";
 import { internalCreateWithdrawalGroup } from "./withdraw.js";
 import { GetReadOnlyAccess } from "../util/query.js";
 import { createRefreshGroup } from "./refresh.js";
+import { updateExchangeFromUrl } from "./exchanges.js";
 
 const logger = new Logger("operations/peer-to-peer.ts");
 
@@ -339,6 +340,9 @@ export async function checkPeerPushPayment(
   }
 
   const exchangeBaseUrl = uri.exchangeBaseUrl;
+
+  await updateExchangeFromUrl(ws, exchangeBaseUrl);
+
   const contractPriv = uri.contractPriv;
   const contractPub = encodeCrock(eddsaGetPublic(decodeCrock(contractPriv)));
 
@@ -463,6 +467,8 @@ export async function acceptPeerPushPayment(
     );
   }
 
+  await updateExchangeFromUrl(ws, peerInc.exchangeBaseUrl);
+
   const amount = Amounts.parseOrThrow(peerInc.contractTerms.amount);
 
   const mergeReserveInfo = await getMergeReserveInfo(ws, {

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