Cache addressesInfo

This commit is contained in:
Esteban Ordano 2014-11-11 19:10:42 -03:00
commit 87facad839
2 changed files with 46 additions and 10 deletions

View file

@ -148,6 +148,30 @@ describe('PublicKeyRing model', function() {
});
});
it('caches calls to getAddress', function() {
var setup = getCachedW();
var pubkeyring = setup.w;
var address = pubkeyring.getAddress(3, false, 4);
(pubkeyring._cacheAddressMap[3][0][4]).should.equal(address);
});
it('getAddress cache hit doesn\'t alter state', function() {
var setup = getCachedW();
var pubkeyring = setup.w;
var spySave;
pubkeyring.getAddress(3, false, 4);
spySave = sinon.stub(pubkeyring, '_cacheAddress');
spySave.onFirstCall().throws(new Error());
pubkeyring.getAddress(3, false, 4);
spySave.restore();
});
it('should return PublicKeyRing addresses', function() {
var k = createW();
var w = k.w;