diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-27 19:20:27 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-27 19:20:27 +0200 |
commit | 9a1b2c8ccc5f079dae4966dfd011f4076a53dc20 (patch) | |
tree | 961e2d42c69126791b9e890fa971f0f33ded1920 /src | |
parent | 592fd62402b7f0fdb8dbe08605381d3a74d929f2 (diff) |
convert tests to ava tests
Diffstat (limited to 'src')
-rw-r--r-- | src/crypto/cryptoApi-test.ts | 14 | ||||
-rw-r--r-- | src/crypto/emscInterface-test.ts | 44 | ||||
-rw-r--r-- | src/helpers-test.ts | 16 | ||||
-rw-r--r-- | src/types-test.ts | 22 | ||||
-rw-r--r-- | src/wallet-test.ts | 22 |
5 files changed, 59 insertions, 59 deletions
diff --git a/src/crypto/cryptoApi-test.ts b/src/crypto/cryptoApi-test.ts index 89b74d776..cc5d1156e 100644 --- a/src/crypto/cryptoApi-test.ts +++ b/src/crypto/cryptoApi-test.ts @@ -1,6 +1,6 @@ import {CryptoApi} from "./cryptoApi"; import {ReserveRecord, DenominationRecord, DenominationStatus} from "../types"; -import {test, TestLib} from "talertest"; +import {test} from "ava"; let masterPub1: string = "CQQZ9DY3MZ1ARMN5K1VKDETS04Y2QCKMMCFHZSWJWWVN82BTTH00"; @@ -45,15 +45,15 @@ let denomValid1: DenominationRecord = { let denomInvalid1 = JSON.parse(JSON.stringify(denomValid1)); denomInvalid1.value.value += 1; -test("string hashing", async (t: TestLib) => { +test("string hashing", async t => { let crypto = new CryptoApi(); let s = await crypto.hashString("hello taler"); let sh = "8RDMADB3YNF3QZBS3V467YZVJAMC2QAQX0TZGVZ6Q5PFRRAJFT70HHN0QF661QR9QWKYMMC7YEMPD679D2RADXCYK8Y669A2A5MKQFR"; - t.assert(s == sh); + t.true(s == sh); t.pass(); }); -test("precoin creation", async (t: TestLib) => { +test("precoin creation", async t => { let crypto = new CryptoApi(); let {priv, pub} = await crypto.createEddsaKeypair(); let r: ReserveRecord = { @@ -73,12 +73,12 @@ test("precoin creation", async (t: TestLib) => { t.pass(); }); -test("denom validation", async (t: TestLib) => { +test("denom validation", async t => { let crypto = new CryptoApi(); let v: boolean; v = await crypto.isValidDenom(denomValid1, masterPub1); - t.assert(v); + t.true(v); v = await crypto.isValidDenom(denomInvalid1, masterPub1); - t.assert(!v); + t.true(!v); t.pass(); }); diff --git a/src/crypto/emscInterface-test.ts b/src/crypto/emscInterface-test.ts index 4f57bf802..dc98308fb 100644 --- a/src/crypto/emscInterface-test.ts +++ b/src/crypto/emscInterface-test.ts @@ -1,55 +1,55 @@ -import {test, TestLib} from "talertest"; +import {test} from "ava"; import * as native from "./emscInterface"; -test("string hashing", (t: TestLib) => { +test("string hashing", t => { 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.true(h === hc, "must equal"); t.pass(); }); -test("signing", (t: TestLib) => { +test("signing", t => { let x = native.ByteArray.fromStringWithNull("hello taler"); let priv = native.EddsaPrivateKey.create(); let pub = priv.getPublicKey(); let purpose = new native.EccSignaturePurpose(native.SignaturePurpose.TEST, x); let sig = native.eddsaSign(purpose, priv); - t.assert(native.eddsaVerify(native.SignaturePurpose.TEST, purpose, sig, pub)); + t.true(native.eddsaVerify(native.SignaturePurpose.TEST, purpose, sig, pub)); t.pass(); }); -test("signing-fixed-data", (t: TestLib) => { +test("signing-fixed-data", t => { let x = native.ByteArray.fromStringWithNull("hello taler"); let purpose = new native.EccSignaturePurpose(native.SignaturePurpose.TEST, x); const privStr = "G9R8KRRCAFKPD0KW7PW48CC2T03VQ8K2AN9J6J6K2YW27J5MHN90"; const pubStr = "YHCZB442FQFJ0ET20MWA8YJ53M61EZGJ6QKV1KTJZMRNXDY45WT0"; const sigStr = "7V6XY4QGC1406GPMT305MZQ1HDCR7R0S5BP02GTGDQFPSXB6YD2YDN5ZS7NJQCNP61Y39MRHXNXQ1Z15JY4CJY4CPDA6CKQ3313WG38"; let priv = native.EddsaPrivateKey.fromCrock(privStr); - t.assert(privStr == priv.toCrock()) + t.true(privStr == priv.toCrock()) let pub = priv.getPublicKey(); - t.assert(pubStr == pub.toCrock()); + t.true(pubStr == pub.toCrock()); let sig = native.EddsaSignature.fromCrock(sigStr); - t.assert(sigStr == sig.toCrock()) + t.true(sigStr == sig.toCrock()) let sig2 = native.eddsaSign(purpose, priv); - t.assert(sig.toCrock() == sig2.toCrock()); - t.assert(native.eddsaVerify(native.SignaturePurpose.TEST, purpose, sig, pub)); + t.true(sig.toCrock() == sig2.toCrock()); + t.true(native.eddsaVerify(native.SignaturePurpose.TEST, purpose, sig, pub)); t.pass(); }); const denomPubStr1 = "51R7ARKCD5HJTTV5F4G0M818E9SP280A40G2GVH04CR30G9R64VK6HHS6MW42DSN8MVKJGHK6WR3CGT18MWMCDSM75138E1K8S0MADSQ68W34DHH6MW4CHA270W4CG9J6GW48DHG8MVK4E9S7523GEA56H0K4E1Q891KCCSG752KGC1M88VMCDSQ6D23CHHG8H33AGHG6MSK8GT26CRKAC1M64V3JCJ56CVKCC228MWMCHA26MS30H1J8MVKEDHJ70TMADHK892KJC1H60TKJDHM710KGGT584T38H9K851KCDHG60W30HJ28CT4CC1G8CR3JGJ28H236DJ28H330H9S890M2D9S8S14AGA369344GA36S248CHS70RKEDSS6MWKGDJ26D136GT465348CSS8S232CHM6GS34C9N8CS3GD9H60W36H1R8MSK2GSQ8MSM6C9R70SKCHHN6MW3ACJ28N0K2CA58RS3GCA26MV42G9P891KAG9Q8N0KGD9M850KEHJ16S130CA27124AE1G852KJCHR6S1KGDSJ8RTKED1S8RR3CCHP68W4CH9Q6GT34GT18GS36EA46N24AGSP6933GCHM60VMAE1S8GV3EHHN74W3GC1J651KEH9N8MSK0CSG6S2KEEA460R32C1M8D144GSR6RWKEC218S0KEGJ4611KEEA36CSKJC2564TM4CSJ6H230E1N74TM8C1P61342CSG60WKCGHH64VK2G9S8CRKAHHK88W30HJ388R3CH1Q6X2K2DHK8GSM4D1Q74WM4HA461146H9S6D33JDJ26D234C9Q6923ECSS60RM6CT46CSKCH1M6S13EH9J8S33GCSN4CMGM81051JJ08SG64R30C1H4CMGM81054520A8A00"; -test("rsa-encode", (t: TestLib) => { +test("rsa-encode", t => { const pubHashStr = "JM63YM5X7X547164QJ3MGJZ4WDD47GEQR5DW5SH35G4JFZXEJBHE5JBNZM5K8XN5C4BRW25BE6GSVAYBF790G2BZZ13VW91D41S4DS0" let denomPub = native.RsaPublicKey.fromCrock(denomPubStr1); let pubHash = denomPub.encode().hash(); - t.assert(pubHashStr == pubHash.toCrock()); + t.true(pubHashStr == pubHash.toCrock()); t.pass(); }); -test("withdraw-request", (t: TestLib) => { +test("withdraw-request", t => { const reservePrivStr = "G9R8KRRCAFKPD0KW7PW48CC2T03VQ8K2AN9J6J6K2YW27J5MHN90"; const reservePriv = native.EddsaPrivateKey.fromCrock(reservePrivStr); const reservePub = reservePriv.getPublicKey(); @@ -72,30 +72,30 @@ test("withdraw-request", (t: TestLib) => { var sigStr = "AD3T8W44NV193J19RAN3NAJHPP6RVB0R3NWV7ZK5G8Q946YDK0B6F8YJBNRRBXSPVTKY31S7BVZPJFFTJJRMY61DH51X4JSXK677428"; var sig = native.eddsaSign(withdrawRequest.toPurpose(), reservePriv); - t.assert(native.eddsaVerify(native.SignaturePurpose.RESERVE_WITHDRAW, withdrawRequest.toPurpose(), sig, reservePub)); - t.assert(sig.toCrock() == sigStr); + t.true(native.eddsaVerify(native.SignaturePurpose.RESERVE_WITHDRAW, withdrawRequest.toPurpose(), sig, reservePub)); + t.true(sig.toCrock() == sigStr); t.pass(); }); -test("withdraw-request", (t: TestLib) => { +test("withdraw-request", t => { const a1 = new native.Amount({currency: "KUDOS", value: 1, fraction: 50000000}); const a2 = new native.Amount({currency: "KUDOS", value: 1, fraction: 50000000}); a1.add(a2); let x = a1.toJson(); - t.assert(x.currency == "KUDOS"); - t.assert(x.fraction == 0); - t.assert(x.value == 3); + t.true(x.currency == "KUDOS"); + t.true(x.fraction == 0); + t.true(x.value == 3); t.pass(); }); -test("ecdsa", (t: TestLib) => { +test("ecdsa", t => { const priv = native.EcdsaPrivateKey.create(); const pub1 = priv.getPublicKey(); t.pass(); }); -test("ecdhe", (t: TestLib) => { +test("ecdhe", t => { const priv = native.EcdhePrivateKey.create(); const pub = priv.getPublicKey(); t.pass(); diff --git a/src/helpers-test.ts b/src/helpers-test.ts index d252e9720..4e9b994d6 100644 --- a/src/helpers-test.ts +++ b/src/helpers-test.ts @@ -1,21 +1,21 @@ -import {test, TestLib} from "talertest"; +import {test} from "ava"; import * as helpers from "./helpers"; -test("URL canonicalization", (t: TestLib) => { +test("URL canonicalization", t => { // converts to relative, adds https - t.assertEqualsStrict( + t.is( "https://alice.example.com/exchange/", - helpers.canonicalizeBaseUrl("alice.example.com/exchange")) + helpers.canonicalizeBaseUrl("alice.example.com/exchange")); // keeps http, adds trailing slash - t.assertEqualsStrict( + t.is( "http://alice.example.com/exchange/", - helpers.canonicalizeBaseUrl("http://alice.example.com/exchange")) + helpers.canonicalizeBaseUrl("http://alice.example.com/exchange")); // keeps http, adds trailing slash - t.assertEqualsStrict( + t.is( "http://alice.example.com/exchange/", - helpers.canonicalizeBaseUrl("http://alice.example.com/exchange#foobar")) + helpers.canonicalizeBaseUrl("http://alice.example.com/exchange#foobar")); t.pass(); }); diff --git a/src/types-test.ts b/src/types-test.ts index 32e07bd0f..bc053b40b 100644 --- a/src/types-test.ts +++ b/src/types-test.ts @@ -1,44 +1,44 @@ -import {test, TestLib} from "talertest"; +import {test} from "ava"; import {Amounts} from "./types"; import * as types from "./types"; let amt = (value: number, fraction: number, currency: string): types.AmountJson => ({value, fraction, currency}); -test("amount addition (simple)", (t: TestLib) => { +test("amount addition (simple)", t => { let a1 = amt(1,0,"EUR"); let a2 = amt(1,0,"EUR"); let a3 = amt(2,0,"EUR"); - t.assert(0 == types.Amounts.cmp(Amounts.add(a1, a2).amount, a3)); + t.true(0 == types.Amounts.cmp(Amounts.add(a1, a2).amount, a3)); t.pass(); }); -test("amount addition (saturation)", (t: TestLib) => { +test("amount addition (saturation)", t => { let a1 = amt(1,0,"EUR"); let res = Amounts.add(Amounts.getMaxAmount("EUR"), a1); - t.assert(res.saturated); + t.true(res.saturated); t.pass(); }); -test("amount subtraction (simple)", (t: TestLib) => { +test("amount subtraction (simple)", t => { let a1 = amt(2,5,"EUR"); let a2 = amt(1,0,"EUR"); let a3 = amt(1,5,"EUR"); - t.assert(0 == types.Amounts.cmp(Amounts.sub(a1, a2).amount, a3)); + t.true(0 == types.Amounts.cmp(Amounts.sub(a1, a2).amount, a3)); t.pass(); }); -test("amount subtraction (saturation)", (t: TestLib) => { +test("amount subtraction (saturation)", t => { let a1 = amt(0,0,"EUR"); let a2 = amt(1,0,"EUR"); let res = Amounts.sub(a1, a2); - t.assert(res.saturated); + t.true(res.saturated); res = Amounts.sub(a1, a1); - t.assert(!res.saturated); + t.true(!res.saturated); t.pass(); }); -test("contract validation", (t: TestLib) => { +test("contract validation", t => { let c = { H_wire: "123", summary: "hello", diff --git a/src/wallet-test.ts b/src/wallet-test.ts index e317c3bd9..56b5e6027 100644 --- a/src/wallet-test.ts +++ b/src/wallet-test.ts @@ -1,9 +1,9 @@ -import {test, TestLib} from "talertest"; +import {test} from "ava"; import {mkAmount} from "./types"; import * as wallet from "./wallet"; -test("coin selection 1", (t: TestLib) => { +test("coin selection 1", t => { let cds: any = []; cds.push({ coin: { @@ -29,12 +29,12 @@ test("coin selection 1", (t: TestLib) => { t.fail(); return; } - t.assert(res.length == 2); + t.true(res.length == 2); t.pass(); }); -test("coin selection 2", (t: TestLib) => { +test("coin selection 2", t => { let cds: any = []; cds.push({ coin: { @@ -70,12 +70,12 @@ test("coin selection 2", (t: TestLib) => { t.fail(); return; } - t.assert(res.length == 2); + t.true(res.length == 2); t.pass(); }); -test("coin selection 2", (t: TestLib) => { +test("coin selection 2", t => { let cds: any = []; cds.push({ coin: { @@ -110,13 +110,13 @@ test("coin selection 2", (t: TestLib) => { t.fail(); return; } - t.assert(res.length == 2); + t.true(res.length == 2); t.pass(); }); -test("coin selection 3", (t: TestLib) => { +test("coin selection 3", t => { let cds: any = []; cds.push({ coin: { @@ -151,12 +151,12 @@ test("coin selection 3", (t: TestLib) => { t.fail(); return; } - t.assert(res.length == 3); + t.true(res.length == 3); t.pass(); }); -test("coin selection 3", (t: TestLib) => { +test("coin selection 3", t => { let cds: any = []; cds.push({ coin: { @@ -187,7 +187,7 @@ test("coin selection 3", (t: TestLib) => { }); let res = wallet.selectCoins(cds, mkAmount(4,0,"EUR"), mkAmount(0,2,"EUR")); - t.assert(!res); + t.true(!res); t.pass(); }); |