aboutsummaryrefslogtreecommitdiff
path: root/lib/wallet
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-11-03 00:47:22 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-11-03 00:47:22 +0100
commitd0a0695fb5d34996850723f7d4b1b59c3df909c2 (patch)
tree6141a1db06f8f359813c332b3c23f3777f00b568 /lib/wallet
parente9a383ede7f98512f0dd351697759d75ddb67eac (diff)
test harness for both browser and node
Diffstat (limited to 'lib/wallet')
-rw-r--r--lib/wallet/cryptoApi-test.ts6
-rw-r--r--lib/wallet/cryptoWorker.ts4
-rw-r--r--lib/wallet/emscriptif-test.ts11
-rw-r--r--lib/wallet/emscriptif.ts6
4 files changed, 21 insertions, 6 deletions
diff --git a/lib/wallet/cryptoApi-test.ts b/lib/wallet/cryptoApi-test.ts
new file mode 100644
index 000000000..6399367b1
--- /dev/null
+++ b/lib/wallet/cryptoApi-test.ts
@@ -0,0 +1,6 @@
+import {CryptoApi} from "./cryptoApi";
+import {test, TestLib} from "testlib/talertest";
+
+test("string hashing", (t: TestLib) => {
+
+});
diff --git a/lib/wallet/cryptoWorker.ts b/lib/wallet/cryptoWorker.ts
index 22feb8eb7..0689c910e 100644
--- a/lib/wallet/cryptoWorker.ts
+++ b/lib/wallet/cryptoWorker.ts
@@ -45,7 +45,7 @@ if ("object" !== typeof Module) {
// we can use it from TypeScript by importing it.
{
- let mod = System.newModule({Module: Module});
+ let mod = System.newModule({Module: Module, default: Module});
let modName = System.normalizeSync("../emscripten/taler-emscripten-lib");
console.log("registering", modName);
System.set(modName, mod);
@@ -58,4 +58,4 @@ System.import("./cryptoLib")
.catch((e) => {
console.log("crypto worker failed");
console.error(e.stack);
- }); \ No newline at end of file
+ });
diff --git a/lib/wallet/emscriptif-test.ts b/lib/wallet/emscriptif-test.ts
new file mode 100644
index 000000000..a3a9229bb
--- /dev/null
+++ b/lib/wallet/emscriptif-test.ts
@@ -0,0 +1,11 @@
+import {test, TestLib} from "testlib/talertest";
+import * as native from "./emscriptif";
+
+test("string hashing", (t: TestLib) => {
+ let x = native.ByteArray.fromStringWithNull("hello taler");
+ let h = "8RDMADB3YNF3QZBS3V467YZVJAMC2QAQX0TZGVZ6Q5PFRRAJFT70HHN0QF661QR9QWKYMMC7YEMPD679D2RADXCYK8Y669A2A5MKQFR"
+ let hc = x.hash().toCrock();
+ console.log(`# hc ${hc}`);
+ t.assert(h === hc, "must equal");
+ t.pass();
+});
diff --git a/lib/wallet/emscriptif.ts b/lib/wallet/emscriptif.ts
index aad5a12a2..3ae2db72a 100644
--- a/lib/wallet/emscriptif.ts
+++ b/lib/wallet/emscriptif.ts
@@ -15,7 +15,7 @@
*/
import {AmountJson} from "./types";
-import * as EmscWrapper from "../emscripten/taler-emscripten-lib";
+import Module, {EmscFunGen} from "../emscripten/taler-emscripten-lib";
/**
* High-level interface to emscripten-compiled modules used
@@ -34,14 +34,12 @@ const GNUNET_YES = 1;
const GNUNET_NO = 0;
const GNUNET_SYSERR = -1;
-let Module = EmscWrapper.Module;
-
function myCcall(name: string, ret: any, argTypes: any[], args: any[]) {
return Module.ccall(name, ret, argTypes, args);
}
-let getEmsc: EmscWrapper.EmscFunGen = (name: string, ret: any,
+let getEmsc: EmscFunGen = (name: string, ret: any,
argTypes: any[]) => {
return (...args: any[]) => {
return myCcall(name, ret, argTypes, args);