gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-wallet-webex] branch master updated (4d70795c -> 2b1


From: gnunet
Subject: [GNUnet-SVN] [taler-wallet-webex] branch master updated (4d70795c -> 2b1e8873)
Date: Sun, 04 Jun 2017 19:41:51 +0200

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

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

    from 4d70795c v0.2.6
     new 55a1b25e Add libtool version comparison module and tests
     new 2b1e8873 v0.2.7

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:
 manifest.json              |  4 +--
 src/libtoolVersion-test.ts | 30 +++++++++++++++++
 src/libtoolVersion.ts      | 83 ++++++++++++++++++++++++++++++++++++++++++++++
 src/wallet.ts              | 20 +++--------
 tsconfig.json              |  2 ++
 5 files changed, 122 insertions(+), 17 deletions(-)
 create mode 100644 src/libtoolVersion-test.ts
 create mode 100644 src/libtoolVersion.ts

diff --git a/manifest.json b/manifest.json
index ff8e8187..947155b9 100644
--- a/manifest.json
+++ b/manifest.json
@@ -4,8 +4,8 @@
   "name": "GNU Taler Wallet (git)",
   "description": "Privacy preserving and transparent payments",
   "author": "GNU Taler Developers",
-  "version": "0.6.43",
-  "version_name": "0.2.6",
+  "version": "0.6.44",
+  "version_name": "0.2.7",
 
   "minimum_chrome_version": "51",
   "minimum_opera_version": "36",
diff --git a/src/libtoolVersion-test.ts b/src/libtoolVersion-test.ts
new file mode 100644
index 00000000..5b8d5445
--- /dev/null
+++ b/src/libtoolVersion-test.ts
@@ -0,0 +1,30 @@
+/*
+ This file is part of TALER
+ (C) 2017 GNUnet e.V.
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+ 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 * as LibtoolVersion from "./libtoolVersion";
+
+import {test} from "ava";
+
+test("version comparison", (t) => {
+  t.deepEqual(LibtoolVersion.compare("0:0:0", "0:0:0"), {compatible: true, 
currentCmp: 0});
+  t.deepEqual(LibtoolVersion.compare("0:0:0", ""), undefined);
+  t.deepEqual(LibtoolVersion.compare("foo", "0:0:0"), undefined);
+  t.deepEqual(LibtoolVersion.compare("0:0:0", "1:0:1"), {compatible: true, 
currentCmp: -1});
+  t.deepEqual(LibtoolVersion.compare("0:0:0", "1:5:1"), {compatible: true, 
currentCmp: -1});
+  t.deepEqual(LibtoolVersion.compare("0:0:0", "1:5:0"), {compatible: false, 
currentCmp: -1});
+  t.deepEqual(LibtoolVersion.compare("1:0:0", "0:5:0"), {compatible: false, 
currentCmp: 1});
+  t.deepEqual(LibtoolVersion.compare("1:0:1", "1:5:1"), {compatible: true, 
currentCmp: 0});
+});
diff --git a/src/libtoolVersion.ts b/src/libtoolVersion.ts
new file mode 100644
index 00000000..0525f5c0
--- /dev/null
+++ b/src/libtoolVersion.ts
@@ -0,0 +1,83 @@
+/*
+ This file is part of TALER
+ (C) 2017 GNUnet e.V.
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+ 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/>
+ */
+
+/**
+ * Semantic versioning, but libtool-style.
+ * See 
https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html 
+ */
+
+
+/**
+ * Result of comparing two libtool versions.
+ */
+export interface VersionMatchResult {
+  /**
+   * Is the first version compatible with the second?
+   */
+  compatible: boolean;
+  /**
+   * Is the first version older (-1), newser (+1) or
+   * identical (0)?
+   */
+  currentCmp: number
+}
+
+interface Version {
+  current: number;
+  revision: number;
+  age: number;
+}
+
+export function compare(me: string, other: string): 
VersionMatchResult|undefined {
+  const meVer = parseVersion(me);
+  const otherVer = parseVersion(other);
+
+  if (!(meVer && otherVer)) {
+    return undefined;
+  }
+
+  const compatible = (meVer.current <= otherVer.current &&
+                      meVer.current >= (otherVer.current - otherVer.age));
+
+  const currentCmp = Math.sign(meVer.current - otherVer.current);
+
+  return {compatible, currentCmp};
+}
+
+
+function parseVersion(v: string): Version|undefined {
+  const [currentStr, revisionStr, ageStr, ...rest] = v.split(":");
+  if (rest.length != 0) {
+    return undefined;
+  }
+  const current = Number.parseInt(currentStr);
+  const revision = Number.parseInt(revisionStr);
+  const age = Number.parseInt(ageStr);
+
+  if (Number.isNaN(current)) {
+    return undefined;
+  }
+
+  if (Number.isNaN(revision)) {
+    return undefined;
+  }
+
+  if (Number.isNaN(age)) {
+    return undefined;
+  }
+
+  return {current, revision, age};
+}
diff --git a/src/wallet.ts b/src/wallet.ts
index 1d72489c..b0029e75 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -321,13 +321,13 @@ export interface ConfigRecord {
 }
 
 
-const WALLET_PROTOCOL_VERSION = "0:0:0";
+export const WALLET_PROTOCOL_VERSION = "0:0:0";
 
 const builtinCurrencies: CurrencyRecord[] = [
   {
     auditors: [
       {
-        auditorPub: "XN9KMN5G2KGPCAN0E89MM5HE8FV4WBWA9KDTMTDR817MWBCYA7H0",
+        auditorPub: "BW9DC48PHQY4NH011SHHX36DZZ3Q22Y6X7FZ1VD1CMZ2PTFZ6PN0",
         baseUrl: "https://auditor.demo.taler.net/";,
         expirationStamp: (new Date(2027, 1)).getTime(),
       },
@@ -336,15 +336,6 @@ const builtinCurrencies: CurrencyRecord[] = [
     fractionalDigits: 2,
     name: "KUDOS",
   },
-  {
-    auditors: [
-    ],
-    exchanges: [
-      { baseUrl: "https://exchange.test.taler.net/";, priority: 0 },
-    ],
-    fractionalDigits: 2,
-    name: "PUDOS",
-  },
 ];
 
 
@@ -1503,13 +1494,12 @@ export class Wallet {
           .toArray()
     ) || [];
 
+    const trustedAuditorPubs = [];
     const currencyRecord = await 
this.q().get<CurrencyRecord>(Stores.currencies, amount.currency);
-    if (!currencyRecord) {
-      throw Error("currency not found");
+    if (currencyRecord) {
+      trustedAuditorPubs.push(...currencyRecord.auditors.map((a) => 
a.auditorPub));
     }
 
-    const trustedAuditorPubs = currencyRecord.auditors.map((a) => 
a.auditorPub);
-
     const ret: ReserveCreationInfo = {
       earliestDepositExpiration,
       exchangeInfo,
diff --git a/tsconfig.json b/tsconfig.json
index dee558cf..7bcf7d49 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -39,6 +39,8 @@
     "src/http.ts",
     "src/i18n.tsx",
     "src/i18n/strings.ts",
+    "src/libtoolVersion-test.ts",
+    "src/libtoolVersion.ts",
     "src/logging.ts",
     "src/memidb-test.ts",
     "src/memidb.ts",

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]