|
1 | | -import * as iroha from "../src/irohajs" |
2 | | -const sha3_256 = require("js-sha3").sha3_256 |
3 | | -const supercop = require("supercop.js") |
| 1 | +import * as iroha from "../src/irohajs"; |
| 2 | +const sha3_256 = require("js-sha3").sha3_256; |
| 3 | +const supercop = require("supercop.js"); |
4 | 4 |
|
5 | 5 | describe("TEST Iroha javascript", () => { |
6 | | - const publicKey = "qzesd0bqIFfx1RQDS2HgcG5DQq/7DYF8u1YfMHAeJUs=" |
7 | | - const privateKey = "MEjhWDSSeQobXA55uYR+EFxEQOoQ68db59Gi1ocQ7ljWZNNQM35MJQpst83FcCKI1hra/53IxeZijEUIiM/Reg==" |
8 | | - const signature = "wg8rlcWHe+PjkmJDllfMIF4PYUEbvNJ/yaoTmWzQUFe3mjnvuXnG3UWwNJfn47ms670sMvELXcliugBBhgeoCA==" |
| 6 | + const publicKey = "qzesd0bqIFfx1RQDS2HgcG5DQq/7DYF8u1YfMHAeJUs="; |
| 7 | + const privateKey = "MEjhWDSSeQobXA55uYR+EFxEQOoQ68db59Gi1ocQ7ljWZNNQM35MJQpst83FcCKI1hra/53IxeZijEUIiM/Reg=="; |
| 8 | + const signature = "wg8rlcWHe+PjkmJDllfMIF4PYUEbvNJ/yaoTmWzQUFe3mjnvuXnG3UWwNJfn47ms670sMvELXcliugBBhgeoCA=="; |
9 | 9 |
|
10 | 10 | beforeEach((done) => { |
11 | | - done() |
12 | | - }) |
| 11 | + done(); |
| 12 | + }); |
13 | 13 |
|
14 | 14 | describe("Iroha Create new KeyPair", () => { |
15 | 15 | it("Create new KeyPair!", () => { |
16 | | - const keyPair = iroha.createKeyPair() |
17 | | - expect(keyPair).toBeDefined() |
18 | | - }) |
19 | | - }) |
| 16 | + const keyPair = iroha.createKeyPair(); |
| 17 | + expect(keyPair).toBeDefined(); |
| 18 | + }); |
| 19 | + }); |
20 | 20 |
|
21 | 21 | describe("Iroha Create new Wallet", () => { |
22 | 22 | it("Create new Wallet!", () => { |
23 | | - const wallet = new iroha.Wallet() |
24 | | - expect(wallet.toJSON()).toBeDefined() |
25 | | - }) |
| 23 | + const wallet = new iroha.Wallet(); |
| 24 | + expect(wallet.toJSON()).toBeDefined(); |
| 25 | + }); |
26 | 26 |
|
27 | 27 | it("Create new Wallet!", () => { |
28 | 28 | const wallet = new iroha.Wallet({ |
29 | 29 | privateKey: new Buffer(privateKey, "base64"), |
30 | 30 | publicKey: new Buffer(publicKey, "base64") |
31 | | - }) |
32 | | - expect(wallet.privateKey.toString("base64")).toBe(privateKey) |
33 | | - expect(wallet.publicKey.toString("base64")).toBe(publicKey) |
34 | | - }) |
| 31 | + }); |
| 32 | + expect(wallet.privateKey.toString("base64")).toBe(privateKey); |
| 33 | + expect(wallet.publicKey.toString("base64")).toBe(publicKey); |
| 34 | + }); |
35 | 35 |
|
36 | 36 | it("Check signature", () => { |
37 | 37 | const wallet = new iroha.Wallet({ |
38 | 38 | privateKey: new Buffer(privateKey, "base64"), |
39 | 39 | publicKey: new Buffer(publicKey, "base64") |
40 | | - }) |
41 | | - const sig = wallet.sign("test") |
42 | | - expect(sig).toBe(signature) |
43 | | - }) |
44 | | - }) |
| 40 | + }); |
| 41 | + const sig = wallet.sign("test"); |
| 42 | + expect(sig).toBe(signature); |
| 43 | + }); |
| 44 | + }); |
45 | 45 |
|
46 | 46 | describe("Iroha CreateSignature", () => { |
47 | 47 | it("Signature succeeded!", () => { |
48 | | - const msg = "test" |
| 48 | + const msg = "test"; |
49 | 49 | const sig = iroha.sign({ |
50 | 50 | "publicKey": publicKey, |
51 | 51 | "privateKey": privateKey, |
52 | 52 | "message": msg |
53 | | - }) |
| 53 | + }); |
54 | 54 |
|
55 | | - expect(sig).toBe(signature) |
56 | | - }) |
| 55 | + expect(sig).toBe(signature); |
| 56 | + }); |
57 | 57 |
|
58 | 58 | it("Signature not succeeded!", () => { |
59 | | - const msg = "abcd" |
| 59 | + const msg = "abcd"; |
60 | 60 | const sig = iroha.sign({ |
61 | 61 | "publicKey": publicKey, |
62 | 62 | "privateKey": privateKey, |
63 | 63 | "message": msg |
64 | | - }) |
| 64 | + }); |
65 | 65 |
|
66 | | - expect(sig).not.toBe(signature) |
67 | | - }) |
| 66 | + expect(sig).not.toBe(signature); |
| 67 | + }); |
68 | 68 |
|
69 | | - }) |
| 69 | + }); |
70 | 70 |
|
71 | 71 | describe("Iroha Verify", () => { |
72 | 72 | it("Verify succeeded!", () => { |
73 | | - const msg = sha3_256("test") |
| 73 | + const msg = sha3_256("test"); |
74 | 74 | const res = iroha.verify({ |
75 | 75 | "publicKey": publicKey, |
76 | 76 | "message": msg, |
77 | 77 | "signature": signature |
78 | | - }) |
| 78 | + }); |
79 | 79 |
|
80 | | - expect(res).toBeTruthy() |
81 | | - }) |
| 80 | + expect(res).toBeTruthy(); |
| 81 | + }); |
82 | 82 |
|
83 | 83 | it("Verify not succeeded!", () => { |
84 | | - const msg = sha3_256("abcd") |
| 84 | + const msg = sha3_256("abcd"); |
85 | 85 | const res = iroha.verify({ |
86 | 86 | "publicKey": publicKey, |
87 | 87 | "message": msg, |
88 | 88 | "signature": signature |
89 | | - }) |
| 89 | + }); |
90 | 90 |
|
91 | | - expect(res).not.toBeTruthy() |
92 | | - }) |
| 91 | + expect(res).not.toBeTruthy(); |
| 92 | + }); |
93 | 93 |
|
94 | | - }) |
95 | | -}) |
| 94 | + }); |
| 95 | +}); |
0 commit comments