gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (2be1c3c8 -> 29d710c3)


From: gnunet
Subject: [taler-wallet-core] branch master updated (2be1c3c8 -> 29d710c3)
Date: Wed, 07 Apr 2021 16:16:22 +0200

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

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

    from 2be1c3c8 re-add tests, more coin selection tests
     new 46056c41 structured clone: handle top-level booleans correctly
     new 29d710c3 fix issue in JSON canonicalization (and move stuff to 
taler-util)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../idb-bridge/src/util/structuredClone.test.ts    |  3 ++
 packages/idb-bridge/src/util/structuredClone.ts    |  3 ++
 packages/taler-util/src/helpers.test.d.ts          |  1 +
 .../src/helpers.test.js}                           | 37 ++++-----------
 packages/taler-util/src/helpers.test.js.map        |  1 +
 .../src/util => taler-util/src}/helpers.test.ts    |  0
 packages/taler-util/src/helpers.ts                 | 54 ++--------------------
 packages/taler-util/src/index.ts                   | 21 +++++----
 8 files changed, 32 insertions(+), 88 deletions(-)
 create mode 100644 packages/taler-util/src/helpers.test.d.ts
 copy packages/{taler-wallet-core/src/util/helpers.test.ts => 
taler-util/src/helpers.test.js} (53%)
 create mode 100644 packages/taler-util/src/helpers.test.js.map
 copy packages/{taler-wallet-core/src/util => taler-util/src}/helpers.test.ts 
(100%)

diff --git a/packages/idb-bridge/src/util/structuredClone.test.ts 
b/packages/idb-bridge/src/util/structuredClone.test.ts
index ed404c6b..352c2c30 100644
--- a/packages/idb-bridge/src/util/structuredClone.test.ts
+++ b/packages/idb-bridge/src/util/structuredClone.test.ts
@@ -24,7 +24,10 @@ function checkClone(t: ExecutionContext, x: any): void {
 test("structured clone", (t) => {
   checkClone(t, "foo");
   checkClone(t, [1, 2]);
+  checkClone(t, true);
+  checkClone(t, false);
   checkClone(t, { x1: "foo" });
+  checkClone(t, { x1: true, x2: false });
   checkClone(t, new Date());
   checkClone(t, [new Date()]);
   checkClone(t, undefined);
diff --git a/packages/idb-bridge/src/util/structuredClone.ts 
b/packages/idb-bridge/src/util/structuredClone.ts
index 4ba97dd7..181e9ca0 100644
--- a/packages/idb-bridge/src/util/structuredClone.ts
+++ b/packages/idb-bridge/src/util/structuredClone.ts
@@ -180,6 +180,9 @@ export function internalStructuredRevive(val: any): any {
   if (typeof val === "string") {
     return val;
   }
+  if (typeof val === "boolean") {
+    return val;
+  }
   if (!isPlainObject(val)) {
     throw Error();
   }
diff --git a/packages/taler-util/src/helpers.test.d.ts 
b/packages/taler-util/src/helpers.test.d.ts
new file mode 100644
index 00000000..cb0ff5c3
--- /dev/null
+++ b/packages/taler-util/src/helpers.test.d.ts
@@ -0,0 +1 @@
+export {};
diff --git a/packages/taler-wallet-core/src/util/helpers.test.ts 
b/packages/taler-util/src/helpers.test.js
similarity index 53%
copy from packages/taler-wallet-core/src/util/helpers.test.ts
copy to packages/taler-util/src/helpers.test.js
index dbecf14b..ed3198c8 100644
--- a/packages/taler-wallet-core/src/util/helpers.test.ts
+++ b/packages/taler-util/src/helpers.test.js
@@ -13,34 +13,17 @@
  You should have received a copy of the GNU General Public License along with
  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
-
 import test from "ava";
 import * as helpers from "./helpers";
-
 test("URL canonicalization", (t) => {
-  // converts to relative, adds https
-  t.is(
-    "https://alice.example.com/exchange/";,
-    helpers.canonicalizeBaseUrl("alice.example.com/exchange"),
-  );
-
-  // keeps http, adds trailing slash
-  t.is(
-    "http://alice.example.com/exchange/";,
-    helpers.canonicalizeBaseUrl("http://alice.example.com/exchange";),
-  );
-
-  // keeps http, adds trailing slash
-  t.is(
-    "http://alice.example.com/exchange/";,
-    helpers.canonicalizeBaseUrl("http://alice.example.com/exchange#foobar";),
-  );
-
-  // Remove search component
-  t.is(
-    "http://alice.example.com/exchange/";,
-    helpers.canonicalizeBaseUrl("http://alice.example.com/exchange?foo=bar";),
-  );
-
-  t.pass();
+    // converts to relative, adds https
+    t.is("https://alice.example.com/exchange/";, 
helpers.canonicalizeBaseUrl("alice.example.com/exchange"));
+    // keeps http, adds trailing slash
+    t.is("http://alice.example.com/exchange/";, 
helpers.canonicalizeBaseUrl("http://alice.example.com/exchange";));
+    // keeps http, adds trailing slash
+    t.is("http://alice.example.com/exchange/";, 
helpers.canonicalizeBaseUrl("http://alice.example.com/exchange#foobar";));
+    // Remove search component
+    t.is("http://alice.example.com/exchange/";, 
helpers.canonicalizeBaseUrl("http://alice.example.com/exchange?foo=bar";));
+    t.pass();
 });
+//# sourceMappingURL=helpers.test.js.map
\ No newline at end of file
diff --git a/packages/taler-util/src/helpers.test.js.map 
b/packages/taler-util/src/helpers.test.js.map
new file mode 100644
index 00000000..1289a5d9
--- /dev/null
+++ b/packages/taler-util/src/helpers.test.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"helpers.test.js","sourceRoot":"","sources":["helpers.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,IAAI,MAAM,KAAK,CAAC;AACvB,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAC,EAAE,EAAE;IACjC,mCAAmC;IACnC,CAAC,CAAC,EAAE,CACF,qCAAqC,EACrC,OAAO,CAAC,mBAAmB,CAAC,4BAA4B,CAAC,CAC1D,CAAC;IAEF,kCAAkC;IAClC,CAAC,CAAC,EAAE,CACF,oCAAoC,EACpC,OAAO,CAAC,mBAAmB,CAAC,mCAAmC,CAAC,CACjE,CAAC;IAEF,kCAAkC;IAClC,CAAC,CAAC,EAAE,CACF,oCAAoC,EACpC,OAAO
 [...]
\ No newline at end of file
diff --git a/packages/taler-wallet-core/src/util/helpers.test.ts 
b/packages/taler-util/src/helpers.test.ts
similarity index 100%
copy from packages/taler-wallet-core/src/util/helpers.test.ts
copy to packages/taler-util/src/helpers.test.ts
diff --git a/packages/taler-util/src/helpers.ts 
b/packages/taler-util/src/helpers.ts
index d3093d1b..28272446 100644
--- a/packages/taler-util/src/helpers.ts
+++ b/packages/taler-util/src/helpers.ts
@@ -83,57 +83,6 @@ export function canonicalJson(obj: any): string {
   return s + "}";
 }
 
-/**
- * Check for deep equality of two objects.
- * Only arrays, objects and primitives are supported.
- */
-export function deepEquals(x: any, y: any): boolean {
-  if (x === y) {
-    return true;
-  }
-
-  if (Array.isArray(x) && x.length !== y.length) {
-    return false;
-  }
-
-  const p = Object.keys(x);
-  return (
-    Object.keys(y).every((i) => p.indexOf(i) !== -1) &&
-    p.every((i) => deepEquals(x[i], y[i]))
-  );
-}
-
-export function deepCopy(x: any): any {
-  // FIXME: this has many issues ...
-  return JSON.parse(JSON.stringify(x));
-}
-
-/**
- * Map from a collection to a list or results and then
- * concatenate the results.
- */
-export function flatMap<T, U>(xs: T[], f: (x: T) => U[]): U[] {
-  return xs.reduce((acc: U[], next: T) => [...f(next), ...acc], []);
-}
-
-/**
- * Compute the hash function of a JSON object.
- */
-export function hash(val: any): number {
-  const str = canonicalJson(val);
-  // https://github.com/darkskyapp/string-hash
-  let h = 5381;
-  let i = str.length;
-  while (i) {
-    h = (h * 33) ^ str.charCodeAt(--i);
-  }
-
-  /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
-   * integers. Since we want the results to be always positive, convert the
-   * signed int to an unsigned by doing an unsigned bitshift. */
-  return h >>> 0;
-}
-
 /**
  * Lexically compare two strings.
  */
@@ -147,6 +96,9 @@ export function strcmp(s1: string, s2: string): number {
   return 0;
 }
 
+/**
+ * Shorthand function for formatted JSON stringification.
+ */
 export function j2s(x: any): string {
   return JSON.stringify(x, undefined, 2);
 }
diff --git a/packages/taler-util/src/index.ts b/packages/taler-util/src/index.ts
index 255d6cbc..3416c7d1 100644
--- a/packages/taler-util/src/index.ts
+++ b/packages/taler-util/src/index.ts
@@ -2,17 +2,18 @@ import { TalerErrorCode } from "./taler-error-codes.js";
 
 export { TalerErrorCode };
 
-export * from "./codec.js";
 export * from "./amounts.js";
-export * from "./talerconfig.js";
-export * from "./time.js";
-export * from "./walletTypes.js";
-export * from "./transactionsTypes.js";
+export * from "./backupTypes.js";
+export * from "./codec.js";
+export * from "./helpers.js";
+export * from "./libtool-version.js";
 export * from "./notifications.js";
-export * from "./talerTypes.js";
-export * from "./taleruri.js";
+export * from "./payto.js";
 export * from "./ReserveStatus.js";
 export * from "./ReserveTransaction.js";
-export * from "./backupTypes.js";
-export * from "./payto.js";
-export * from "./libtool-version.js";
\ No newline at end of file
+export * from "./talerconfig.js";
+export * from "./talerTypes.js";
+export * from "./taleruri.js";
+export * from "./time.js";
+export * from "./transactionsTypes.js";
+export * from "./walletTypes.js";
\ No newline at end of file

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