rm Identity#import

This commit is contained in:
Matias Alejo Garcia 2014-09-27 17:14:49 -03:00
commit c4c7dc8eb1
5 changed files with 18 additions and 392 deletions

View file

@ -81,11 +81,11 @@ describe('Storage model', function() {
});
});
describe('#_getWalletIds', function() {
describe('#_getWalletIds_Old', function() {
it('should get wallet ids', function(done) {
s._write('1::hola', 'juan', function() {
s._write('2::hola', 'juan', function() {
s._getWalletIds(function(v) {
s._getWalletIds_Old(function(v) {
v.should.deep.equal(['1', '2']);
done();
});
@ -118,13 +118,13 @@ describe('Storage model', function() {
});
}
describe('#getWallets_Old', function() {
describe('#getWallets1_Old', function() {
it('should retrieve wallets from storage', function(done) {
s._write('1::hola', 'juan', function() {
s._write('2::hola', 'juan', function() {
s.setGlobal('nameFor::1', 'hola', function() {
s.getWallets_Old(function(ws) {
s.getWallets1_Old(function(ws) {
ws[0].should.deep.equal({
id: '1',
name: 'hola',
@ -151,7 +151,7 @@ describe('Storage model', function() {
}, 1);
};
s.getWallets_Old(function(ws) {
s.getWallets1_Old(function(ws) {
ws[0].should.deep.equal({
id: '1',
name: 'hola',
@ -168,7 +168,7 @@ describe('Storage model', function() {
});
});
describe('#getWallets2', function() {
describe('#getWallets2_Old', function() {
it('should retrieve wallets from storage', function(done) {
var w1 = {
name: 'juan',
@ -181,7 +181,7 @@ describe('Storage model', function() {
};
s.setFromObj('wallet::1_wallet1', w1, function() {
s.setFromObj('wallet::2', w2, function() {
s.getWallets2(function(ws) {
s.getWallets2_Old(function(ws) {
ws[0].should.deep.equal({
id: '1',
name: 'wallet1',
@ -215,7 +215,7 @@ describe('Storage model', function() {
s._write('3::name', 'matias', function() {
s._write('1::name', 'juan', function() {
s.setGlobal('nameFor::3', 'wallet3', function() {
s.getWallets(function(ws) {
s.getWallets_Old(function(ws) {
ws.length.should.equal(3);
ws[0].should.deep.equal({
id: '1',
@ -307,7 +307,7 @@ describe('Storage model', function() {
s.setFromObj('wallet::2', w2, function() {
s.deleteWallet('1', function(err) {
should.not.exist(err);
s.getWallets2(function(ws) {
s.getWallets2_Old(function(ws) {
ws.length.should.equal(1);
ws[0].id.should.equal('2');
done();

View file

@ -162,9 +162,6 @@ describe('Identity model', function() {
wf.storage.import.calledOnce.should.be.true;
wf.fromObj.calledWith('walletObj').should.be.true;
});
});
describe('#import', function() {
it('should import and update indexes', function() {
var wallet = {
id: "fake wallet",
@ -174,14 +171,14 @@ describe('Identity model', function() {
};
wf.fromEncryptedObj = sinon.stub().returns(wallet);
var w = wf.import("encrypted", "password");
var w = wf.fromEncryptedObj("encrypted", "password");
should.exist(w);
wallet.should.equal(w);
});
it('should import with a wrong password', function() {
wf.fromEncryptedObj = sinon.stub().returns(null);
var w = wf.import("encrypted", "passwordasdfasdf");
var w = wf.fromEncryptedObj("encrypted", "passwordasdfasdf");
should.not.exist(w);
});
});
@ -272,7 +269,7 @@ describe('Identity model', function() {
describe('#read', function() {
it('should fail to read unexisting wallet', function(done) {
wf.storage.readWallet = sinon.stub().yields(null, {});
wf.storage.getFirst = sinon.stub().yields(null, {});
wf.read('id', [], function(err, w) {
should.not.exist(w);
@ -284,7 +281,7 @@ describe('Identity model', function() {
});
});
it('should fail to read broken wallet', function(done) {
wf.storage.readWallet = sinon.stub().yields(null, {
wf.storage.getFirst = sinon.stub().yields(null, {
'opts': 1
});
wf.read('id', [], function(err, w) {
@ -298,7 +295,7 @@ describe('Identity model', function() {
});
it('should read existing wallet', function(done) {
var wf = new Identity(config, '0.0.1');
wf.storage.readWallet = sinon.stub().yields(null, {
wf.storage.getFirst = sinon.stub().yields(null, {
'opts': 1
});
wf.fromObj = sinon.stub().returns('ok');
@ -568,7 +565,7 @@ describe('Identity model', function() {
wf.storage.setPassphrase = sinon.spy();
wf.storage.import.withArgs('dummy').returns(JSON.parse(legacy1));
var w = wf.import('dummy', 'xxx');
var w = wf.fromEncryptedObj('dummy', 'xxx');
should.exist(w);
wf.storage.setPassphrase.calledOnce.should.equal(true);
wf.storage.setPassphrase.getCall(0).args[0].should.equal('xxx');