Skip to content

Commit

Permalink
Simplified build process; added in-browser test script
Browse files Browse the repository at this point in the history
  • Loading branch information
tinybike committed Apr 22, 2017
1 parent cdfece3 commit 904007a
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 71 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ test/fixtures/extra
test/fixtures/state
test/fixtures/nodes
test/fixtures/geth
test/browser/bundle.js
12 changes: 6 additions & 6 deletions dist/keythereum.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ global.keythereum = keythereum;
},{"./":2}],2:[function(require,module,exports){
(function (process,Buffer){
/**
* keythereum: create/import/export ethereum keys
* Create, import, and export ethereum keys.
* @author Jack Peterson ([email protected])
*/

Expand Down Expand Up @@ -28878,7 +28878,7 @@ function HmacDRBG(options) {
this.outLen = this.hash.outSize;
this.minEntropy = options.minEntropy || this.hash.hmacStrength;

this.reseed = null;
this._reseed = null;
this.reseedInterval = null;
this.K = null;
this.V = null;
Expand All @@ -28903,7 +28903,7 @@ HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
}

this._update(seed);
this.reseed = 1;
this._reseed = 1;
this.reseedInterval = 0x1000000000000; // 2^48
};

Expand Down Expand Up @@ -28945,11 +28945,11 @@ HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');

this._update(entropy.concat(add || []));
this.reseed = 1;
this._reseed = 1;
};

HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
if (this.reseed > this.reseedInterval)
if (this._reseed > this.reseedInterval)
throw new Error('Reseed is required');

// Optional encoding
Expand All @@ -28973,7 +28973,7 @@ HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {

var res = temp.slice(0, len);
this._update(add);
this.reseed++;
this._reseed++;
return utils.encode(res, enc);
};

Expand Down
4 changes: 2 additions & 2 deletions dist/keythereum.min.js

Large diffs are not rendered by default.

43 changes: 0 additions & 43 deletions gulpfile.js

This file was deleted.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* keythereum: create/import/export ethereum keys
* Create, import, and export ethereum keys.
* @author Jack Peterson ([email protected])
*/

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
"scripts": {
"test": "mocha test/keys.js",
"geth": "mocha -R progress test/keys.js && mocha -R progress test/geth.js",
"lint": "eslint index.js && eslint gulpfile.js && eslint test",
"coverage": "istanbul cover -x **/lib/** ./node_modules/mocha/bin/_mocha test/keys.js"
"lint": "eslint index.js && eslint gulpfile.js && eslint test/*.js",
"coverage": "istanbul cover -x **/lib/** ./node_modules/mocha/bin/_mocha test/keys.js",
"build": "browserify ./exports.js > ./dist/keythereum.js && uglifyjs ./dist/keythereum.js > ./dist/keythereum.min.js",
"build:tests": "browserify test/keys.js > test/browser/bundle.js"
},
"repository": {
"type": "git",
Expand All @@ -37,10 +39,8 @@
"browserify": "^13.1.1",
"chai": "^3.2.0",
"coveralls": "^2.11.3",
"del": "^1.2.0",
"eslint": "^3.17.1",
"geth": "^0.2.2",
"gulp": "^3.9.0",
"istanbul": "^0.3.17",
"mocha": "^2.2.5",
"uglify-js": "^2.4.24",
Expand Down
24 changes: 12 additions & 12 deletions test/browser/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>keythereum</title>
<script>
window.logger = function (o) {
console.log(JSON.stringify(o, null, 2));
};
</script>
</head>
<body>
<script src="../../dist/keythereum.js"></script>
</body>
<head>
<title>keythereum tests</title>
<link rel="stylesheet" href="../../node_modules/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="../../node_modules/mocha/mocha.js"></script>
<script src="../../node_modules/chai/chai.js"></script>
<script>mocha.setup("bdd")</script>
<script src="./bundle.js"></script>
<script>mocha.run();</script>
</body>
</html>
12 changes: 9 additions & 3 deletions test/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,11 @@ describe("Generate keystore filename", function () {

describe("Export to file", function () {

var keyObj = {
var keyObj;

if (keythereum.browser) return;

keyObj = {
address: "008aeeda4d805471df9b2a5b0f38a0c3bcba786b",
crypto: {
cipher: "aes-128-ctr",
Expand Down Expand Up @@ -855,7 +859,9 @@ describe("Export to file", function () {

describe("Import from keystore file", function () {

var test = function (t) {
if (keythereum.browser) return;

function test(t) {
var label = "[" + t.expected.crypto.kdf + "] import " + t.input.address + " from file";
it(label, function (done) {
var keyObject;
Expand All @@ -869,7 +875,7 @@ describe("Import from keystore file", function () {
done();
});
});
};
}

describe("Version 3", function () {
test({
Expand Down

0 comments on commit 904007a

Please sign in to comment.