Skip to content

Commit ac8a5b1

Browse files
committed
ci: Setup CircleCI
1 parent 5ec21e3 commit ac8a5b1

File tree

7 files changed

+107
-95
lines changed

7 files changed

+107
-95
lines changed

.circleci/config.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: 2
2+
3+
jobs:
4+
build:
5+
working_directory: ~/iroha-javascript
6+
docker:
7+
- image: node:7.7
8+
steps:
9+
- checkout
10+
- restore_cache:
11+
key: irohajs-{{ .Branch }}-{{ checksum "package.json" }}
12+
- run:
13+
name: Pre-Dependencies
14+
command: mkdir ~/iroha-javascript/artifacts
15+
- run:
16+
name: Install Dependencies
17+
command: npm prune && npm cache clean && npm install
18+
- run:
19+
name: Test & Build
20+
command: npm run test:prod && npm run build
21+
- store_artifacts:
22+
path: ~/iroha-javascript/dist
23+
destination: iroha
24+
- save_cache:
25+
key: irohajs-{{ .Branch }}-{{ checksum "package.json" }}
26+
paths:
27+
- "~/iroha-javascript/node_modules"

.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
"author": "",
1212
"license": "Apache-2.0",
1313
"bugs": {
14-
"url": "https://github.com/soramitsu/iroha-javascript/issues"
14+
"url": "https://github.com/hyperledger/iroha-javascript/issues"
1515
},
16-
"homepage": "https://github.com/soramitsu/iroha-javascript#readme",
16+
"homepage": "https://github.com/hyperledger/iroha-javascript#readme",
1717
"engines": {
1818
"node": ">=6.0.0"
1919
},

src/irohajs.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
1-
const sha3_256 = require("js-sha3").sha3_256
2-
const supercop = require("supercop.js")
1+
const sha3_256 = require("js-sha3").sha3_256;
2+
const supercop = require("supercop.js");
33

44
export function createKeyPair (): IKeyPair {
5-
const seed = supercop.createSeed()
6-
const keys = supercop.createKeyPair(seed)
5+
const seed = supercop.createSeed();
6+
const keys = supercop.createKeyPair(seed);
77

88
return {
99
publicKey: keys.publicKey.toString("base64"),
1010
privateKey: keys.secretKey.toString("base64")
11-
}
11+
};
1212
}
1313

1414
export function sign (opt: { publicKey: string, privateKey: string, message: string }): string {
15-
const publicKey = new Buffer(opt.publicKey, "base64")
16-
const privateKey = new Buffer(opt.privateKey, "base64")
17-
const sha3Message = new Buffer(sha3_256(opt.message))
15+
const publicKey = new Buffer(opt.publicKey, "base64");
16+
const privateKey = new Buffer(opt.privateKey, "base64");
17+
const sha3Message = new Buffer(sha3_256(opt.message));
1818

1919
const sig = supercop.sign(
2020
sha3Message,
2121
publicKey,
2222
privateKey
23-
).toString("base64")
23+
).toString("base64");
2424

25-
return sig
25+
return sig;
2626
}
2727

2828
export function verify (opt: { publicKey: string, message: string, signature: string }) {
2929
const valid = supercop.verify(
3030
new Buffer(opt.signature, "base64"),
3131
new Buffer(opt.message),
3232
new Buffer(opt.publicKey, "base64")
33-
)
34-
return valid
33+
);
34+
return valid;
3535
}
3636

3737
export interface IKeyPair {
38-
privateKey: string
39-
publicKey: string
38+
privateKey: string;
39+
publicKey: string;
4040
}
4141

4242
export interface IWallet {
43-
privateKey: Buffer
44-
publicKey: Buffer
43+
privateKey: Buffer;
44+
publicKey: Buffer;
4545
}
4646

4747
export class Wallet implements IWallet {
48-
privateKey: Buffer
49-
publicKey: Buffer
48+
privateKey: Buffer;
49+
publicKey: Buffer;
5050

5151
constructor (keyPair?: IWallet) {
52-
const seed = supercop.createSeed()
53-
const keys = keyPair || supercop.createKeyPair(seed)
52+
const seed = supercop.createSeed();
53+
const keys = keyPair || supercop.createKeyPair(seed);
5454

55-
this.publicKey = keys.publicKey
56-
this.privateKey = (keyPair) ? keyPair.privateKey : keys.secretKey
55+
this.publicKey = keys.publicKey;
56+
this.privateKey = (keyPair) ? keyPair.privateKey : keys.secretKey;
5757
}
5858

5959
toJSON (): IKeyPair {
6060
return {
6161
publicKey: this.publicKey.toString("base64"),
6262
privateKey: this.privateKey.toString("base64")
63-
}
63+
};
6464
}
6565

6666
sign (msg: string): string {
67-
const message = new Buffer(sha3_256(msg))
68-
return supercop.sign(message, this.publicKey, this.privateKey).toString("base64")
67+
const message = new Buffer(sha3_256(msg));
68+
return supercop.sign(message, this.publicKey, this.privateKey).toString("base64");
6969
}
7070
}

test/irohajs.test.ts

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,95 @@
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");
44

55
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==";
99

1010
beforeEach((done) => {
11-
done()
12-
})
11+
done();
12+
});
1313

1414
describe("Iroha Create new KeyPair", () => {
1515
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+
});
2020

2121
describe("Iroha Create new Wallet", () => {
2222
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+
});
2626

2727
it("Create new Wallet!", () => {
2828
const wallet = new iroha.Wallet({
2929
privateKey: new Buffer(privateKey, "base64"),
3030
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+
});
3535

3636
it("Check signature", () => {
3737
const wallet = new iroha.Wallet({
3838
privateKey: new Buffer(privateKey, "base64"),
3939
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+
});
4545

4646
describe("Iroha CreateSignature", () => {
4747
it("Signature succeeded!", () => {
48-
const msg = "test"
48+
const msg = "test";
4949
const sig = iroha.sign({
5050
"publicKey": publicKey,
5151
"privateKey": privateKey,
5252
"message": msg
53-
})
53+
});
5454

55-
expect(sig).toBe(signature)
56-
})
55+
expect(sig).toBe(signature);
56+
});
5757

5858
it("Signature not succeeded!", () => {
59-
const msg = "abcd"
59+
const msg = "abcd";
6060
const sig = iroha.sign({
6161
"publicKey": publicKey,
6262
"privateKey": privateKey,
6363
"message": msg
64-
})
64+
});
6565

66-
expect(sig).not.toBe(signature)
67-
})
66+
expect(sig).not.toBe(signature);
67+
});
6868

69-
})
69+
});
7070

7171
describe("Iroha Verify", () => {
7272
it("Verify succeeded!", () => {
73-
const msg = sha3_256("test")
73+
const msg = sha3_256("test");
7474
const res = iroha.verify({
7575
"publicKey": publicKey,
7676
"message": msg,
7777
"signature": signature
78-
})
78+
});
7979

80-
expect(res).toBeTruthy()
81-
})
80+
expect(res).toBeTruthy();
81+
});
8282

8383
it("Verify not succeeded!", () => {
84-
const msg = sha3_256("abcd")
84+
const msg = sha3_256("abcd");
8585
const res = iroha.verify({
8686
"publicKey": publicKey,
8787
"message": msg,
8888
"signature": signature
89-
})
89+
});
9090

91-
expect(res).not.toBeTruthy()
92-
})
91+
expect(res).not.toBeTruthy();
92+
});
9393

94-
})
95-
})
94+
});
95+
});

tslint.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
true,
66
"double",
77
"avoid-escape"
8+
],
9+
"semicolon": [
10+
true,
11+
"always"
812
]
913
}
1014
}

webpack.config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { join } from "path"
2-
const { camelCase } = require("lodash")
3-
const { TsConfigPathsPlugin, CheckerPlugin } = require("awesome-typescript-loader")
4-
const TypedocWebpackPlugin = require("typedoc-webpack-plugin")
1+
import { join } from "path";
2+
const { camelCase } = require("lodash");
3+
const { TsConfigPathsPlugin, CheckerPlugin } = require("awesome-typescript-loader");
4+
const TypedocWebpackPlugin = require("typedoc-webpack-plugin");
55

66
/**
77
* Update this variable if you change your library name
88
*/
9-
const libraryName = "irohajs"
9+
const libraryName = "irohajs";
1010

1111
export default {
1212
entry: join(__dirname, `src/${libraryName}.ts`),
@@ -51,4 +51,4 @@ export default {
5151
net: "empty",
5252
tls: "empty"
5353
}
54-
}
54+
};

0 commit comments

Comments
 (0)