test cache

This commit is contained in:
Ivan Socolsky 2015-10-28 13:42:38 -03:00
parent 64a48db991
commit ff1ca22825
1 changed files with 23 additions and 0 deletions

View File

@ -1751,6 +1751,29 @@ describe('Wallet service', function() {
});
});
});
it('should cache address activity', function(done) {
var MAX_MAIN_ADDRESS_GAP_old = WalletService.MAX_MAIN_ADDRESS_GAP;
WalletService.MAX_MAIN_ADDRESS_GAP = 2;
helpers.stubAddressActivity([]);
async.map(_.range(2), function(i, next) {
server.createAddress({}, next);
}, function(err, addresses) {
addresses.length.should.equal(2);
helpers.stubAddressActivity([addresses[1].address]);
var getAddressActivitySpy = sinon.spy(blockchainExplorer, 'getAddressActivity');
server.createAddress({}, function(err, address) {
should.not.exist(err);
server.createAddress({}, function(err, address) {
should.not.exist(err);
getAddressActivitySpy.callCount.should.equal(1);
WalletService.MAX_MAIN_ADDRESS_GAP = MAX_MAIN_ADDRESS_GAP_old;
done();
});
});
});
});
});
});