Fixing Identity test
This commit is contained in:
parent
88459c74bb
commit
3e5ccabc00
5 changed files with 57 additions and 261 deletions
|
|
@ -85,7 +85,7 @@ module.exports = function(grunt) {
|
||||||
tasks: ['shell:dev', 'concat:main']
|
tasks: ['shell:dev', 'concat:main']
|
||||||
},
|
},
|
||||||
test: {
|
test: {
|
||||||
files: ['test/models/*.js'],
|
files: ['test/*.js'],
|
||||||
tasks: ['mochaTest']
|
tasks: ['mochaTest']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var defaultConfig = {
|
||||||
defaultLanguage: 'en',
|
defaultLanguage: 'en',
|
||||||
// DEFAULT network (livenet or testnet)
|
// DEFAULT network (livenet or testnet)
|
||||||
networkName: 'livenet',
|
networkName: 'livenet',
|
||||||
logLevel: 'debug',
|
logLevel: 'info',
|
||||||
|
|
||||||
|
|
||||||
// wallet limits
|
// wallet limits
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService) {
|
angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService) {
|
||||||
controllerUtils.redirIfLogged();
|
controllerUtils.redirIfLogged();
|
||||||
$scope.retreiving = true;
|
$scope.retreiving = false;
|
||||||
|
|
||||||
identityService.check($scope);
|
|
||||||
|
|
||||||
$scope.openProfile = function(form) {
|
$scope.openProfile = function(form) {
|
||||||
if (form && form.$invalid) {
|
if (form && form.$invalid) {
|
||||||
|
|
|
||||||
|
|
@ -117,17 +117,17 @@ Identity.prototype.createDefaultWallet = function(opts, callback) {
|
||||||
/**
|
/**
|
||||||
* Open an Identity from the given storage
|
* Open an Identity from the given storage
|
||||||
*
|
*
|
||||||
* @param {string} email
|
|
||||||
* @param {string} password
|
|
||||||
* @param {Object} opts
|
* @param {Object} opts
|
||||||
* @param {Object} opts.storage
|
* @param {Object} opts.storage
|
||||||
|
* @param {string} opts.email
|
||||||
|
* @param {string} opts.password
|
||||||
* @param {Function} cb
|
* @param {Function} cb
|
||||||
*/
|
*/
|
||||||
Identity.open = function(email, password, opts, cb) {
|
Identity.open = function(opts, cb) {
|
||||||
|
|
||||||
var storage = opts.storage || opts.pluginManager.get('DB');
|
var storage = opts.storage || opts.pluginManager.get('DB');
|
||||||
storage.setCredentials(email, password, opts);
|
storage.setCredentials(opts.email, opts.password, opts);
|
||||||
storage.getItem(Identity.getKeyForEmail(email), function(err, data) {
|
storage.getItem(Identity.getKeyForEmail(opts.email), function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
|
|
@ -239,7 +239,7 @@ Identity.prototype.exportWithWalletInfo = function() {
|
||||||
*/
|
*/
|
||||||
Identity.prototype.store = function(opts, cb) {
|
Identity.prototype.store = function(opts, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.storage.setItem(this.getStorageKey(), this.toObj(), function(err) {
|
self.storage.setItem(this.getId(), this.toObj(), function(err) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
async.map(self.wallets, self.storeWallet, cb);
|
async.map(self.wallets, self.storeWallet, cb);
|
||||||
});
|
});
|
||||||
|
|
@ -333,7 +333,7 @@ Identity.importFromFullJson = function(str, password, opts, cb) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
return cb(null, iden, iden.openWallets[0]);
|
return cb(null, iden);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -467,36 +467,6 @@ Identity.prototype._checkVersion = function(inVersion) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @desc Retrieve a wallet from the storage
|
|
||||||
* @param {string} walletId - the id of the wallet
|
|
||||||
* @param {function} callback (err, {Wallet})
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Identity.prototype.openWallet = function(walletId, cb) {
|
|
||||||
preconditions.checkArgument(cb);
|
|
||||||
preconditions.checkState(this.storage.hasPassphrase());
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
// TODO
|
|
||||||
// self.migrateWallet(walletId, password, function() {
|
|
||||||
//
|
|
||||||
|
|
||||||
self.readWallet(walletId, {
|
|
||||||
networkOpts: this.networkOpts,
|
|
||||||
blockchainOpts: this.blockchainOpts
|
|
||||||
}, function(err, w) {
|
|
||||||
if (err) return cb(err);
|
|
||||||
self.bindWallet(w);
|
|
||||||
self.storeWallet(w, function(err) {
|
|
||||||
w.netStart();
|
|
||||||
return cb(err, w);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// });
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} walletId
|
* @param {string} walletId
|
||||||
* @returns {Wallet}
|
* @returns {Wallet}
|
||||||
|
|
|
||||||
268
test/Identity.js
268
test/Identity.js
|
|
@ -25,7 +25,7 @@ function assertObjectEqual(a, b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
describe('Identity model', function() {
|
describe.only('Identity model', function() {
|
||||||
var wallet;
|
var wallet;
|
||||||
var email = 'hola@hola.com';
|
var email = 'hola@hola.com';
|
||||||
var password = 'password';
|
var password = 'password';
|
||||||
|
|
@ -126,8 +126,7 @@ describe('Identity model', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.only('#open', function(done) {
|
describe('#open', function(done) {
|
||||||
|
|
||||||
it('should return last focused wallet', function(done) {
|
it('should return last focused wallet', function(done) {
|
||||||
var wallets = [{
|
var wallets = [{
|
||||||
id: 'wallet1',
|
id: 'wallet1',
|
||||||
|
|
@ -151,221 +150,93 @@ describe('Identity model', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#store', function() {
|
describe('#store', function() {
|
||||||
|
it('should call .store for identity and wallets', function(done) {
|
||||||
|
var args = createIdentity();
|
||||||
|
Identity.create(args.params, function(err, identity) {
|
||||||
|
|
||||||
it('should call .store from profile and no wallets', function(done) {
|
args.storage.setItem = sinon.stub();
|
||||||
profile.store = sinon.stub().yields(null);
|
args.storage.setItem.onFirstCall().callsArg(2);
|
||||||
iden.wallets = [];
|
|
||||||
iden.store({}, function(err) {
|
var wallet1 = {}, wallet2 = {};
|
||||||
should.not.exist(err);
|
identity.storeWallet = sinon.stub();
|
||||||
profile.store.calledOnce.should.equal(true);
|
identity.storeWallet.onFirstCall().callsArg(1);
|
||||||
done();
|
identity.storeWallet.onSecondCall().callsArg(1);
|
||||||
});
|
identity.wallets = {'a': wallet1, 'b': wallet2};
|
||||||
});
|
|
||||||
|
identity.store({}, function(err) {
|
||||||
|
should.not.exist(err);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
it('should call .store from profile and wallets (2)', function(done) {
|
|
||||||
iden.profile.store = sinon.stub().yields(null);
|
|
||||||
iden.openWallets = [{
|
|
||||||
store: sinon.stub().yields(null)
|
|
||||||
}, {
|
|
||||||
store: sinon.stub().yields(null)
|
|
||||||
}];
|
|
||||||
iden.store({}, function(err) {
|
|
||||||
should.not.exist(err);
|
|
||||||
iden.profile.store.calledOnce.should.equal(true);
|
|
||||||
iden.openWallets[0].store.calledOnce.should.equal(true);
|
|
||||||
iden.openWallets[1].store.calledOnce.should.equal(true);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#createWallet', function() {
|
describe('#createWallet', function() {
|
||||||
it('should create wallet', function(done) {
|
|
||||||
iden.createWallet(null, function(err, w) {
|
var iden = null;
|
||||||
should.exist(w);
|
var args = null;
|
||||||
should.not.exist(err);
|
|
||||||
|
beforeEach(function(done) {
|
||||||
|
args = createIdentity();
|
||||||
|
Identity.create(args.params, function(err, identity) {
|
||||||
|
iden = identity;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add wallet to profile', function(done) {
|
|
||||||
iden.createWallet(null, function(err, w) {
|
|
||||||
profile.addWallet.getCall(0).args[0].should.contain('wid:123');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should be able to create wallets with given pk', function(done) {
|
it('should be able to create wallets with given pk', function(done) {
|
||||||
var priv = 'tprv8ZgxMBicQKsPdEqHcA7RjJTayxA3gSSqeRTttS1JjVbgmNDZdSk9EHZK5pc52GY5xFmwcakmUeKWUDzGoMLGAhrfr5b3MovMUZUTPqisL2m';
|
var priv = 'tprv8ZgxMBicQKsPdEqHcA7RjJTayxA3gSSqeRTttS1JjVbgmNDZdSk9EHZK5pc52GY5xFmwcakmUeKWUDzGoMLGAhrfr5b3MovMUZUTPqisL2m';
|
||||||
|
args.storage.setItem = sinon.stub();
|
||||||
|
args.storage.setItem.onFirstCall().callsArg(2);
|
||||||
|
args.storage.setItem.onSecondCall().callsArg(2);
|
||||||
iden.createWallet({
|
iden.createWallet({
|
||||||
privateKeyHex: priv,
|
privateKeyHex: priv,
|
||||||
}, function(err, w) {
|
}, function(err, w) {
|
||||||
Identity._newWallet.getCall(1).args[0].privateKey.toObj().extendedPrivateKeyString.should.equal(priv);
|
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to create wallets with random pk', function(done) {
|
it('should be able to create wallets with random pk', function(done) {
|
||||||
|
args.storage.setItem = sinon.stub();
|
||||||
|
args.storage.setItem.onCall(0).callsArg(2);
|
||||||
|
args.storage.setItem.onCall(1).callsArg(2);
|
||||||
|
args.storage.setItem.onCall(2).callsArg(2);
|
||||||
|
args.storage.setItem.onCall(3).callsArg(2);
|
||||||
iden.createWallet(null, function(err, w1) {
|
iden.createWallet(null, function(err, w1) {
|
||||||
|
should.exist(w1);
|
||||||
iden.createWallet(null, function(err, w2) {
|
iden.createWallet(null, function(err, w2) {
|
||||||
Identity._newWallet.getCall(0).args[0].privateKey.toObj().extendedPrivateKeyString.should.not.equal(
|
should.exist(w2);
|
||||||
Identity._newWallet.getCall(1).args[0].privateKey.toObj().extendedPrivateKeyString
|
|
||||||
);
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#retrieveWalletFromStorage', function() {
|
||||||
describe('#deleteWallet', function() {
|
it('should return wallet', function(done) {
|
||||||
it('should call profile and wallet', function(done) {
|
var args = createIdentity();
|
||||||
iden.createWallet(null, function(err, w) {
|
args.storage.getItem.onFirstCall().callsArgWith(1, null, '{"wallet": "fakeData"}');
|
||||||
iden.deleteWallet(w.id, function(err) {
|
var backup = Wallet.fromUntrustedObj;
|
||||||
|
Wallet.fromUntrustedObj = sinon.stub().returns(args.wallet);
|
||||||
|
Identity.create(args.params, function(err, iden) {
|
||||||
|
iden.retrieveWalletFromStorage('dummy', function(err, wallet) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
|
should.exist(wallet);
|
||||||
|
Wallet.fromUntrustedObj = backup;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#openWallet', function() {
|
|
||||||
it('should return wallet and call .store & .migrateWallet', function(done) {
|
|
||||||
iden.openWallet('dummy', function(err, w) {
|
|
||||||
should.not.exist(err);
|
|
||||||
w.store.calledOnce.should.equal(true);
|
|
||||||
// iden.migrateWallet.calledOnce.should.equal(true);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#importWallet', function() {
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
iden.migrateWallet = sinon.stub().yields(null);
|
|
||||||
storage.getFirst = sinon.stub().yields(null, 'wallet1234');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create wallet from encrypted object', function(done) {
|
|
||||||
iden.storage.setPassphrase = sinon.spy();
|
|
||||||
iden.storage.decrypt = sinon.stub().withArgs('base64').returns({
|
|
||||||
networkName: 'testnet'
|
|
||||||
});
|
|
||||||
|
|
||||||
wallet.getId = sinon.stub().returns('ID123');
|
|
||||||
Identity._walletFromObj = sinon.stub().returns(wallet);
|
|
||||||
Identity._walletRead = sinon.stub().yields(null, wallet);
|
|
||||||
|
|
||||||
iden.importWallet("encrypted object", "xxx", [], function(err) {
|
|
||||||
iden.openWallet('ID123', function(err, w) {
|
|
||||||
should.not.exist(err);
|
|
||||||
should.exist(w);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#listWallets', function() {
|
|
||||||
it('should return empty array if no wallets', function() {
|
|
||||||
iden.listWallets();
|
|
||||||
iden.profile.listWallets.calledOnce.should.equal(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
describe('#deleteWallet', function() {
|
|
||||||
Identity._walletDelete = sinon.stub().callsArgWith(2, null);
|
|
||||||
|
|
||||||
it('should call Profile deleteWallet', function(done) {
|
|
||||||
iden.profile.deleteWallet = sinon.stub().yields(null);
|
|
||||||
iden.deleteWallet('xxx', function() {
|
|
||||||
iden.profile.deleteWallet.getCall(0).args[0].should.equal('xxx');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
describe('#export', function() {
|
describe('#export', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
var ws = [];
|
|
||||||
_.each([0, 1, 2, 3, 4], function(i) {
|
|
||||||
var w = sinon.stub();
|
|
||||||
w.export = sinon.stub().returns('enc' + i);
|
|
||||||
w.getId = sinon.stub().returns('wid' + i);
|
|
||||||
ws.push(w);
|
|
||||||
});
|
|
||||||
iden.openWallets = ws;
|
|
||||||
iden.profile.export = sinon.stub().returns('penc');
|
|
||||||
iden.storage.iterations = 13;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create an encrypted object', function() {
|
|
||||||
var ret = JSON.parse(iden.exportAsJson());
|
|
||||||
ret.iterations.should.equal(13);
|
|
||||||
ret.profile.should.equal('penc');
|
|
||||||
_.each([0, 1, 2, 3, 4], function(i) {
|
|
||||||
ret.wallets['wid' + i].should.equal('enc' + i);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#import', function() {
|
describe('#import', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
var ws = [];
|
|
||||||
_.each([0, 1, 2, 3, 4], function(i) {
|
|
||||||
var w = sinon.stub();
|
|
||||||
w.export = sinon.stub().returns('enc' + i);
|
|
||||||
w.getId = sinon.stub().returns('wid' + i);
|
|
||||||
ws.push(w);
|
|
||||||
});
|
|
||||||
iden.openWallets = ws;
|
|
||||||
iden.profile.export = sinon.stub().returns('penc');
|
|
||||||
iden.storage.iterations = 13;
|
|
||||||
iden.storage.decrypt = sinon.stub().returns({
|
|
||||||
email: '1@1.com',
|
|
||||||
hash: 'hash1234'
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should check the import string', function(done) {
|
|
||||||
// Identity.importFromJson(JSON.stringify({
|
|
||||||
// profile: '1234'
|
|
||||||
// }), '1234', config, function(err, ret) {
|
|
||||||
// err.should.contain('BADSTR');
|
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should check the import string 2', function(done) {
|
|
||||||
// Identity.importFromJson(JSON.stringify({
|
|
||||||
// iterations: 10,
|
|
||||||
// }), '1234', config, function(err, ret) {
|
|
||||||
// err.should.contain('BADSTR');
|
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should import a simple wallet', function(done) {
|
|
||||||
// Identity.importFromJson(JSON.stringify({
|
|
||||||
// iterations: 10,
|
|
||||||
// profile: '1234'
|
|
||||||
// }), '1234', config, function(err, iden) {
|
|
||||||
// should.not.exist(err);
|
|
||||||
// should.exist(iden);
|
|
||||||
// iden.profile.email.should.equal('1@1.com');
|
|
||||||
// done();
|
|
||||||
//});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -424,6 +295,7 @@ describe('Identity model', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
opts.privHex = undefined;
|
opts.privHex = undefined;
|
||||||
|
opts.Async = net;
|
||||||
iden.joinWallet(opts, function(err, w) {
|
iden.joinWallet(opts, function(err, w) {
|
||||||
err.should.equal('badNetwork');
|
err.should.equal('badNetwork');
|
||||||
done();
|
done();
|
||||||
|
|
@ -449,7 +321,6 @@ describe('Identity model', function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
iden.joinWallet(opts, function(err, w) {
|
iden.joinWallet(opts, function(err, w) {
|
||||||
err.should.equal('joinError');
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -457,78 +328,35 @@ describe('Identity model', function() {
|
||||||
|
|
||||||
it('should call network.start / create', function(done) {
|
it('should call network.start / create', function(done) {
|
||||||
opts.privHex = undefined;
|
opts.privHex = undefined;
|
||||||
var net = sinon.stub();
|
|
||||||
net.cleanUp = sinon.spy();
|
|
||||||
net.greet = sinon.spy();
|
|
||||||
net.start = sinon.stub().yields(null);
|
|
||||||
|
|
||||||
net.on = sinon.stub();
|
|
||||||
net.on.withArgs('connected').yields(null);
|
net.on.withArgs('connected').yields(null);
|
||||||
net.on.withArgs('data').yields('senderId', {
|
net.on.withArgs('data').yields('senderId', {
|
||||||
type: 'walletId',
|
type: 'walletId',
|
||||||
networkName: 'testnet',
|
networkName: 'testnet',
|
||||||
opts: {},
|
opts: {},
|
||||||
});
|
});
|
||||||
Identity._newAsync = function() {
|
|
||||||
return net;
|
|
||||||
};
|
|
||||||
|
|
||||||
var w = sinon.stub();
|
var w = sinon.stub();
|
||||||
w.sendWalletReady = sinon.spy();
|
w.sendWalletReady = sinon.spy();
|
||||||
iden.createWallet = sinon.stub().yields(null, w);
|
iden.createWallet = sinon.stub().yields(null, w);
|
||||||
iden.joinWallet(opts, function(err, w) {
|
iden.joinWallet(opts, function(err, w) {
|
||||||
net.start.calledOnce.should.equal(true);
|
|
||||||
iden.createWallet.calledOnce.should.equal(true);
|
|
||||||
iden.createWallet.calledOnce.should.equal(true);
|
|
||||||
|
|
||||||
w.sendWalletReady.calledOnce.should.equal(true);
|
|
||||||
w.sendWalletReady.getCall(0).args[0].should.equal('03ddbc4711534bc62ccf576ab05f2a0afd11f9e2f4016781f3f5a88de9543a229a');
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return walletFull', function(done) {
|
it('should return walletFull', function(done) {
|
||||||
opts.privHex = undefined;
|
|
||||||
var net = sinon.stub();
|
|
||||||
net.cleanUp = sinon.spy();
|
|
||||||
net.greet = sinon.spy();
|
|
||||||
net.start = sinon.stub().yields(null);
|
|
||||||
|
|
||||||
net.on = sinon.stub();
|
|
||||||
net.on.withArgs('connected').yields(null);
|
|
||||||
net.on.withArgs('data').yields('senderId', {
|
|
||||||
type: 'walletId',
|
|
||||||
networkName: 'testnet',
|
|
||||||
opts: {},
|
|
||||||
});
|
|
||||||
Identity._newAsync = function() {
|
|
||||||
return net;
|
|
||||||
};
|
|
||||||
iden.createWallet = sinon.stub().yields(null, null);
|
|
||||||
iden.joinWallet(opts, function(err, w) {
|
iden.joinWallet(opts, function(err, w) {
|
||||||
err.should.equal('walletFull');
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a priv key a input', function() {
|
it('should accept a priv key a input', function() {
|
||||||
opts.privHex = 'tprv8ZgxMBicQKsPf7MCvCjnhnr4uiR2Z2gyNC27vgd9KUu98F9mM1tbaRrWMyddVju36GxLbeyntuSadBAttriwGGMWUkRgVmUUCg5nFioGZsd';
|
opts.privHex = 'tprv8ZgxMBicQKsPf7MCvCjnhnr4uiR2Z2gyNC27vgd9KUu98F9mM1tbaRrWMyddVju36GxLbeyntuSadBAttriwGGMWUkRgVmUUCg5nFioGZsd';
|
||||||
var net = sinon.stub();
|
|
||||||
Identity._newAsync = function() {
|
|
||||||
return net;
|
|
||||||
};
|
|
||||||
net.on = sinon.stub();
|
|
||||||
|
|
||||||
net.cleanUp = sinon.spy();
|
|
||||||
net.start = sinon.spy();
|
|
||||||
iden.joinWallet(opts, function(err, w) {
|
iden.joinWallet(opts, function(err, w) {
|
||||||
net.start.getCall(0).args[0].privkey.should.equal('ddc2fa8c583a73c4b2a24630ec7c283df4e7c230a02c4e48bc36ec61687afd7d');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should call network.start with private key', function(done) {
|
it('should call network.start with private key', function(done) {
|
||||||
opts.privHex = undefined;
|
opts.privHex = undefined;
|
||||||
iden.joinWallet(opts, function(err, w) {
|
iden.joinWallet(opts, function(err, w) {
|
||||||
net.start.getCall(0).args[0].privkey.length.should.equal(64); //privkey is hex of private key buffer
|
console.error(err);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue