Merge pull request #1076 from matiu/bug/02-open-wallet
Bug/02 open wallet
This commit is contained in:
commit
815c98f7e8
15 changed files with 682 additions and 478 deletions
|
|
@ -27,6 +27,18 @@ FakeStorage.prototype.getLastOpened = function() {
|
|||
return this.storage['lastOpened'];
|
||||
};
|
||||
|
||||
FakeStorage.prototype.setLock = function(id) {
|
||||
this.storage[id + '::lock'] = true;
|
||||
}
|
||||
|
||||
FakeStorage.prototype.getLock = function(id) {
|
||||
return this.storage[id + '::lock'];
|
||||
}
|
||||
|
||||
FakeStorage.prototype.removeLock = function(id) {
|
||||
delete this.storage[id + '::lock'];
|
||||
}
|
||||
|
||||
FakeStorage.prototype.removeGlobal = function(id) {
|
||||
delete this.storage[id];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ var FakeWallet = function() {
|
|||
this.safeBalance = 1000;
|
||||
this.totalCopayers = 2;
|
||||
this.requiredCopayers = 2;
|
||||
this.isLocked = false;
|
||||
this.balanceByAddr = {
|
||||
'1CjPR7Z5ZSyWk6WtXvSFgkptmpoi4UM9BC': 1000
|
||||
};
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ describe('Wallet model', function() {
|
|||
cachedW2obj.opts.reconnectDelay = 100;
|
||||
}
|
||||
var w = Wallet.fromObj(cachedW2obj, cachedW2.storage, cachedW2.network, cachedW2.blockchain);
|
||||
w.unlock();
|
||||
return w;
|
||||
};
|
||||
|
||||
|
|
@ -1022,6 +1023,37 @@ describe('Wallet model', function() {
|
|||
w.netStart();
|
||||
w.network.start.getCall(0).args[0].privkey.length.should.equal(64);
|
||||
});
|
||||
|
||||
it('should check if wallet is already opened', function() {
|
||||
var w = cachedCreateW2();
|
||||
should.not.exist(w.getLock());
|
||||
w.checkAndLock().should.equal(false);
|
||||
w.getLock().should.equal(true);
|
||||
});
|
||||
it('should check if wallet is already opened', function() {
|
||||
var w = cachedCreateW2();
|
||||
should.not.exist(w.getLock());
|
||||
w.checkAndLock().should.equal(false);
|
||||
w.getLock().should.equal(true);
|
||||
});
|
||||
|
||||
|
||||
it('should not start if locked', function() {
|
||||
var w = cachedCreateW2();
|
||||
w.netStart();
|
||||
w.emit = sinon.spy();
|
||||
w.netStart();
|
||||
w.emit.getCall(0).args[0].should.equal('locked');
|
||||
});
|
||||
|
||||
it('should accept ignoreLocked', function() {
|
||||
var w = cachedCreateW2();
|
||||
w.netStart();
|
||||
w.network.start = sinon.spy();
|
||||
w.ignoreLock=1;
|
||||
w.netStart();
|
||||
w.network.start.getCall(0).args[0].privkey.length.should.equal(64);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#forceNetwork in config', function() {
|
||||
|
|
|
|||
|
|
@ -160,6 +160,19 @@ describe('Storage/LocalEncrypted model', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#WalletLock', function() {
|
||||
it('should get/set/remove opened', function() {
|
||||
var s = new LocalEncrypted({
|
||||
localStorage: localMock,
|
||||
password: 'password'
|
||||
});
|
||||
s.setLock('walletId');
|
||||
s.getLock('walletId').should.equal(true);
|
||||
s.removeLock('walletId');
|
||||
should.not.exist(s.getLock('walletId'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getWallets', function() {
|
||||
it('should retreive wallets from storage', function() {
|
||||
var s = new LocalEncrypted({
|
||||
|
|
|
|||
|
|
@ -288,8 +288,10 @@ describe("Unit: Controllers", function() {
|
|||
describe("Unit: Sidebar Controller", function() {
|
||||
var rootScope;
|
||||
beforeEach(inject(function($controller, $rootScope) {
|
||||
rootScope = $rootScope;
|
||||
scope = $rootScope.$new();
|
||||
rootScope = $rootScope;
|
||||
rootScope.wallet = new FakeWallet(config);
|
||||
|
||||
headerCtrl = $controller('SidebarController', {
|
||||
$scope: scope,
|
||||
});
|
||||
|
|
@ -437,4 +439,18 @@ describe("Unit: Controllers", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Warning Controller', function() {
|
||||
var what;
|
||||
beforeEach(inject(function($controller, $rootScope) {
|
||||
scope = $rootScope.$new();
|
||||
what = $controller('WarningController', {
|
||||
$scope: scope,
|
||||
});
|
||||
}));
|
||||
|
||||
it('should exist', function() {
|
||||
should.exist(what);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue