Fixing Identity Network Tests
This commit is contained in:
parent
3e5ccabc00
commit
291975bb24
3 changed files with 35 additions and 26 deletions
|
|
@ -85,7 +85,7 @@ module.exports = function(grunt) {
|
||||||
tasks: ['shell:dev', 'concat:main']
|
tasks: ['shell:dev', 'concat:main']
|
||||||
},
|
},
|
||||||
test: {
|
test: {
|
||||||
files: ['test/*.js'],
|
files: ['test/**/*.js', 'js/**/*.js'],
|
||||||
tasks: ['mochaTest']
|
tasks: ['mochaTest']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -607,8 +607,9 @@ Identity.prototype.joinWallet = function(opts, cb) {
|
||||||
if (w) {
|
if (w) {
|
||||||
w.sendWalletReady(decodedSecret.pubKey);
|
w.sendWalletReady(decodedSecret.pubKey);
|
||||||
} else {
|
} else {
|
||||||
if (!err) err = 'walletFull';
|
if (!err) {
|
||||||
log.info(err);
|
err = 'walletFull';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return cb(err, w);
|
return cb(err, w);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ function assertObjectEqual(a, b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
describe.only('Identity model', function() {
|
describe('Identity model', function() {
|
||||||
var wallet;
|
var wallet;
|
||||||
var email = 'hola@hola.com';
|
var email = 'hola@hola.com';
|
||||||
var password = 'password';
|
var password = 'password';
|
||||||
|
|
@ -303,7 +303,7 @@ describe.only('Identity model', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should yield to join error', function(done) {
|
it('should callback with a join error in case of a problem', function(done) {
|
||||||
opts.privHex = undefined;
|
opts.privHex = undefined;
|
||||||
var net = sinon.stub();
|
var net = sinon.stub();
|
||||||
net.greet = sinon.stub();
|
net.greet = sinon.stub();
|
||||||
|
|
@ -316,47 +316,55 @@ describe.only('Identity model', function() {
|
||||||
type: 'walletId',
|
type: 'walletId',
|
||||||
networkName: iden.networkName,
|
networkName: iden.networkName,
|
||||||
});
|
});
|
||||||
Identity._newAsync = function() {
|
opts.Async = net;
|
||||||
return net;
|
|
||||||
};
|
|
||||||
|
|
||||||
iden.joinWallet(opts, function(err, w) {
|
iden.joinWallet(opts, function(err, w) {
|
||||||
done();
|
err.should.equal('joinError');
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should call network.start / create', function(done) {
|
|
||||||
opts.privHex = undefined;
|
|
||||||
net.on.withArgs('connected').yields(null);
|
|
||||||
net.on.withArgs('data').yields('senderId', {
|
|
||||||
type: 'walletId',
|
|
||||||
networkName: 'testnet',
|
|
||||||
opts: {},
|
|
||||||
});
|
|
||||||
var w = sinon.stub();
|
|
||||||
w.sendWalletReady = sinon.spy();
|
|
||||||
iden.createWallet = sinon.stub().yields(null, w);
|
|
||||||
iden.joinWallet(opts, function(err, w) {
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return walletFull', function(done) {
|
it('should return walletFull', function(done) {
|
||||||
|
net = sinon.stub();
|
||||||
|
net.on = sinon.stub();
|
||||||
|
net.start = sinon.stub();
|
||||||
|
net.start.onFirstCall().callsArg(1);
|
||||||
|
net.greet = sinon.stub();
|
||||||
|
iden.createWallet = sinon.stub();
|
||||||
|
iden.createWallet.onFirstCall().yields();
|
||||||
|
net.on.withArgs('data').yields('senderId', {
|
||||||
|
type: 'walletId',
|
||||||
|
networkName: 'testnet',
|
||||||
|
opts: {},
|
||||||
|
});
|
||||||
|
opts.privHex = undefined;
|
||||||
|
opts.Async = net;
|
||||||
|
|
||||||
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 as an input', function(done) {
|
||||||
opts.privHex = 'tprv8ZgxMBicQKsPf7MCvCjnhnr4uiR2Z2gyNC27vgd9KUu98F9mM1tbaRrWMyddVju36GxLbeyntuSadBAttriwGGMWUkRgVmUUCg5nFioGZsd';
|
net = sinon.stub();
|
||||||
iden.joinWallet(opts, function(err, w) {
|
net.on = sinon.stub();
|
||||||
|
net.start = sinon.stub();
|
||||||
|
net.start.onFirstCall().callsArg(1);
|
||||||
|
net.greet = sinon.stub();
|
||||||
|
iden.createWallet = sinon.stub();
|
||||||
|
var fakeWallet = {sendWalletReady: _.noop};
|
||||||
|
iden.createWallet.onFirstCall().yields(null, fakeWallet);
|
||||||
|
net.on.withArgs('data').yields('senderId', {
|
||||||
|
type: 'walletId',
|
||||||
|
networkName: 'testnet',
|
||||||
|
opts: {},
|
||||||
});
|
});
|
||||||
});
|
|
||||||
it('should call network.start with private key', function(done) {
|
opts.privHex = 'tprv8ZgxMBicQKsPf7MCvCjnhnr4uiR2Z2gyNC27vgd9KUu98F9mM1tbaRrWMyddVju36GxLbeyntuSadBAttriwGGMWUkRgVmUUCg5nFioGZsd';
|
||||||
opts.privHex = undefined;
|
opts.Async = net;
|
||||||
iden.joinWallet(opts, function(err, w) {
|
iden.joinWallet(opts, function(err, w) {
|
||||||
console.error(err);
|
w.should.equal(fakeWallet);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue