diff --git a/Gruntfile.js b/Gruntfile.js
index a63da775d..a043256b8 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -45,8 +45,6 @@ module.exports = function(grunt) {
'js/models/**/*.js',
'js/models/*.js',
'plugins/*.js',
- 'copay.js',
- 'utils/*.js'
],
tasks: ['shell:dev']
},
@@ -181,7 +179,7 @@ module.exports = function(grunt) {
},
jsdoc: {
dist : {
- src: ['js/models/core/*.js'],
+ src: ['js/models/core/*.js', 'js/models/*.js', 'plugins/*.js'],
options: {
destination: 'doc',
configure: 'jsdoc.conf.json',
diff --git a/index.html b/index.html
index 40b22b4da..9a79d3090 100644
--- a/index.html
+++ b/index.html
@@ -22,9 +22,6 @@
-
diff --git a/js/models/Storage.js b/js/models/Storage.js
index 103cb9a8d..17a422bdb 100644
--- a/js/models/Storage.js
+++ b/js/models/Storage.js
@@ -27,6 +27,7 @@ function Storage(opts) {
var pps = {};
Storage.prototype._getPassphrase = function() {
+
if (!pps[this.__uniqueid])
throw new Error('NOPASSPHRASE: No passphrase set');
diff --git a/karma.conf.js b/karma.conf.js
index e9c89b577..052e215fb 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -60,6 +60,8 @@ module.exports = function(config) {
'test/mocks/FakeWallet.js',
'test/mocks/FakeBlockchainSocket.js',
'test/mocks/FakePayProServer.js',
+ 'test/mocks/FakeLocalStorage.js',
+ 'test/mocks/FakeStorage.js',
'test/mocha.conf.js',
diff --git a/package.json b/package.json
index 248cac974..7248c5c0f 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,7 @@
"dependencies": {
"browser-request": "^0.3.2",
"inherits": "^2.0.1",
- "mocha": "^1.21.4",
+ "mocha": "^1.18.2",
"mocha-lcov-reporter": "0.0.1",
"optimist": "^0.6.1",
"preconditions": "^1.0.7",
@@ -27,14 +27,12 @@
"chrome": "source browser-extensions/chrome/build.sh",
"setup-shell": "node shell/scripts/download-atom-shell.js",
"start": "node server.js",
- "coverage": "mochacoverage",
- "test": "mocha --ui exports --reporter spec",
+ "coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter spec test",
+ "test": "sh test/run.sh",
"dist": "node shell/scripts/dist.js",
"sign": "gpg -u 1112CFA1 --output browser-extensions/firefox/copay.xpi.sig --detach-sig browser-extensions/firefox/copay.xpi; gpg -u 1112CFA1 --output browser-extensions/chrome/copay-chrome-extension.zip.sig --detach-sig browser-extensions/chrome/copay-chrome-extension.zip",
"verify": "gpg --verify browser-extensions/firefox/copay.xpi.sig browser-extensions/firefox/copay.xpi; gpg --verify browser-extensions/chrome/copay-chrome-extension.zip.sig browser-extensions/chrome/copay-chrome-extension.zip",
- "postinstall": "./node_modules/.bin/grunt",
- "monitor": "mocha --ui exports --reporter min --watch",
- "debugtest": "mocha --debug-brk --ui exports --reporter spec"
+ "postinstall": "./node_modules/.bin/grunt"
},
"keywords": [
"wallet",
@@ -83,8 +81,7 @@
"shelljs": "0.3.0",
"socket.io-client": "1.0.6",
"travis-cov": "0.2.5",
- "uglifyify": "1.2.3",
- "mochawrapper": ""
+ "uglifyify": "1.2.3"
},
"main": "app.js",
"homepage": "https://github.com/bitpay/copay",
diff --git a/test/mocks/FakeStorage.js b/test/mocks/FakeStorage.js
deleted file mode 100644
index 7bb9de7b6..000000000
--- a/test/mocks/FakeStorage.js
+++ /dev/null
@@ -1,162 +0,0 @@
-var FakeStorage = function() {
- this.reset();
-};
-
-
-FakeStorage.prototype.reset = function(password) {
- this.storage = {};
-};
-
-FakeStorage.prototype.setPassphrase = function(password) {
- this.storage.passphrase = password;
-};
-
-FakeStorage.prototype.setGlobal = function(id, v, cb) {
- this.storage[id] = typeof v === 'object' ? JSON.stringify(v) : v;
- cb();
-};
-
-FakeStorage.prototype.getGlobal = function(id, cb) {
- return cb(this.storage[id]);
-};
-
-FakeStorage.prototype.getMany = function(wid, fields, cb) {
- var self = this;
- var ret = [];
- for (var ii in fields) {
- var k = fields[ii];
- ret[k] = this.storage[wid + '::' + k];
- }
-
- return cb(ret);
-};
-
-
-
-FakeStorage.prototype.setLastOpened = function(val, cb) {
- this.storage['lastOpened'] = val;
- return cb();
-};
-
-FakeStorage.prototype.getLastOpened = function(cb) {
- return cb(this.storage['lastOpened']);
-};
-
-FakeStorage.prototype.setLock = function(id) {
- this.storage[id + '::lock'] = true;
- return cb();
-}
-
-FakeStorage.prototype.getLock = function(id, cb) {
- return cb(this.storage[id + '::lock']);
-}
-
-FakeStorage.prototype.getSessionId = function(cb) {
- this.sessionId = this.sessionId || 'aSessionId';
- return cb(this.sessionId);
-};
-
-
-FakeStorage.prototype.removeLock = function(id, cb) {
- delete this.storage[id + '::lock'];
- cb();
-}
-
-FakeStorage.prototype.removeGlobal = function(id, cb) {
- delete this.storage[id];
- cb();
-};
-
-
-FakeStorage.prototype.set = function(wid, id, payload, cb) {
- this.storage[wid + '::' + id] = payload;
- if (cb) return cb();
-};
-
-FakeStorage.prototype.get = function(wid, id, cb) {
- return cb(this.storage[wid + '::' + id]);
-};
-
-FakeStorage.prototype.clear = function(cb) {
- delete this['storage'];
- cb();
-};
-
-FakeStorage.prototype.getWalletIds = function(cb) {
- var walletIds = [];
- var uniq = {};
-
- for (var ii in this.storage) {
- var split = ii.split('::');
- if (split.length == 2) {
- var walletId = split[0];
-
- if (!walletId || walletId === 'nameFor' || walletId === 'lock')
- continue;
-
- if (typeof uniq[walletId] === 'undefined') {
- walletIds.push(walletId);
- uniq[walletId] = 1;
- }
- }
- }
- return cb(walletIds);
-};
-
-FakeStorage.prototype.deleteWallet = function(walletId, cb) {
- var toDelete = {};
- toDelete['nameFor::' + walletId] = 1;
-
- for (var key in this.storage) {
- var split = key.split('::');
- if (split.length == 2 && split[0] === walletId) {
- toDelete[key] = 1;
- }
- }
- var l = toDelete.length,
- j = 0;
-
- if (!l)
- return cb(new Error('WNOTFOUND: Wallet not found'));
-
- for (var i in toDelete) {
- this.removeGlobal(i, cb);
- if (++j == l)
- return cb(err);
-
- }
-};
-
-
-FakeStorage.prototype.getName = function(walletId, cb) {
- this.getGlobal('nameFor::' + walletId, cb);
-};
-
-
-FakeStorage.prototype.setName = function(walletId, name, cb) {
- this.setGlobal('nameFor::' + walletId, name, cb);
-};
-
-
-FakeStorage.prototype.getWallets = function(cb) {
- var wallets = [];
- var self= this;
- this.getWalletIds(function(ids) {
- for (var i in ids) {
- wallets.push({
- id: ids[i],
- name: self.storage['nameFor::' + ids[i]],
- });
- }
- return cb(wallets);
- });
-};
-
-FakeStorage.prototype.setFromObj = function(walletId, obj, cb) {
- for (var k in obj) {
- this.set(walletId, k, obj[k]);
- }
- this.setName(walletId, obj.opts.name, cb);
-};
-
-module.exports = FakeStorage;
diff --git a/test/test.PayPro.js b/test/test.PayPro.js
index 77872c23e..997b8e9cb 100644
--- a/test/test.PayPro.js
+++ b/test/test.PayPro.js
@@ -11,7 +11,6 @@ if (is_browser) {
}
var Wallet = copay.Wallet;
var PrivateKey = copay.PrivateKey;
-var Storage = require('./mocks/FakeStorage');
var Network = require('./mocks/FakeNetwork');
var Blockchain = require('./mocks/FakeBlockchain');
var bitcore = bitcore || require('bitcore');
@@ -21,6 +20,10 @@ var Address = bitcore.Address;
var PayPro = bitcore.PayPro;
var bignum = bitcore.Bignum;
var startServer = copay.FakePayProServer; // TODO should be require('./mocks/FakePayProServer');
+var localMock = require('./mocks/FakeLocalStorage');
+var sessionMock = require('./mocks/FakeLocalStorage');
+var Storage = copay.Storage;
+
var server;
@@ -30,6 +33,10 @@ var walletConfig = {
spendUnconfirmed: true,
reconnectDelay: 100,
networkName: 'testnet',
+ storage: {
+ storage: localMock,
+ sessionStorage: sessionMock,
+ }
};
var getNewEpk = function() {
diff --git a/test/test.Storage.js b/test/test.Storage.js
index 5a3032030..c7e75e2db 100644
--- a/test/test.Storage.js
+++ b/test/test.Storage.js
@@ -25,8 +25,7 @@ describe('Storage model', function() {
});
should.exist(s2);
});
- it.only('should fail when encrypting without a password', function() {
-
+ it('should fail when encrypting without a password', function() {
var s2 = new Storage({
storage: localMock,
sessionStorage: sessionMock,
diff --git a/test/test.Wallet.js b/test/test.Wallet.js
index c8ae349e5..056d5e4bb 100644
--- a/test/test.Wallet.js
+++ b/test/test.Wallet.js
@@ -13,7 +13,7 @@ if (is_browser) {
var copayConfig = require('../config');
var Wallet = copay.Wallet;
var PrivateKey = copay.PrivateKey;
-var Storage = require('./mocks/FakeStorage');
+var Storage = copay.Storage;
var Network = require('./mocks/FakeNetwork');
var Blockchain = require('./mocks/FakeBlockchain');
var Builder = require('./mocks/FakeBuilder');
@@ -21,6 +21,8 @@ var bitcore = bitcore || require('bitcore');
var TransactionBuilder = bitcore.TransactionBuilder;
var Transaction = bitcore.Transaction;
var Address = bitcore.Address;
+var localMock = require('./mocks/FakeLocalStorage');
+var sessionMock = require('./mocks/FakeLocalStorage');
var walletConfig = {
requiredCopayers: 3,
@@ -28,6 +30,10 @@ var walletConfig = {
spendUnconfirmed: true,
reconnectDelay: 100,
networkName: 'testnet',
+ storage: {
+ storage: localMock,
+ sessionStorage: sessionMock,
+ }
};
var getNewEpk = function() {
diff --git a/test/test.WalletLock.js b/test/test.WalletLock.js
index e8e418a96..abf2af9fd 100644
--- a/test/test.WalletLock.js
+++ b/test/test.WalletLock.js
@@ -13,12 +13,19 @@ var copayConfig = require('../config');
var WalletLock = copay.WalletLock;
var PrivateKey = copay.PrivateKey;
-var Storage = require('./mocks/FakeStorage');
+var localMock = require('./mocks/FakeLocalStorage');
+var sessionMock = require('./mocks/FakeLocalStorage');
+var Storage = copay.Storage;
+
+
var storage;
describe('WalletLock model', function() {
beforeEach(function() {
- storage = new Storage();
+ storage = new Storage({
+ storage: localMock,
+ sessionStorage: sessionMock,
+ });
});
it('should fail with missing args', function() {
diff --git a/util/build.js b/util/build.js
index 2c078f458..0d5b0f44e 100644
--- a/util/build.js
+++ b/util/build.js
@@ -104,9 +104,6 @@ var createBundle = function(opts) {
//include dev dependencies
b.require('sinon');
b.require('blanket');
- b.require('./test/mocks/FakeStorage', {
- expose: './mocks/FakeStorage'
- });
b.require('./test/mocks/FakeLocalStorage', {
expose: './mocks/FakeLocalStorage'
});