refactor lock warning and add tests
This commit is contained in:
parent
fb3a7191e5
commit
35ab711846
13 changed files with 632 additions and 557 deletions
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
@ -1024,11 +1025,34 @@ describe('Wallet model', function() {
|
|||
});
|
||||
|
||||
it('should check if wallet is already opened', function() {
|
||||
var w = createW();
|
||||
w._checkLocked();
|
||||
w.isLocked.should.equal(false);
|
||||
w._checkLocked();
|
||||
w.isLocked.should.equal(true);
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue