improve # of confirmations tests
This commit is contained in:
parent
f423f8a567
commit
13735829c7
|
@ -6337,29 +6337,47 @@ describe('Wallet service', function() {
|
||||||
Defaults.CONFIRMATIONS_TO_START_CACHING = 6;
|
Defaults.CONFIRMATIONS_TO_START_CACHING = 6;
|
||||||
|
|
||||||
var h = helpers.historyCacheTest(20);
|
var h = helpers.historyCacheTest(20);
|
||||||
|
_.each(h, function(x, i) {
|
||||||
|
x.blockheight = 100 - i;
|
||||||
|
});
|
||||||
helpers.stubHistory(h);
|
helpers.stubHistory(h);
|
||||||
var storeTxHistoryCacheSpy = sinon.spy(server.storage, 'storeTxHistoryCache');
|
var storeTxHistoryCacheSpy = sinon.spy(server.storage, 'storeTxHistoryCache');
|
||||||
var skip = 0;
|
|
||||||
var limit = 20;
|
|
||||||
|
|
||||||
blockchainExplorer.getBlockchainHeight = sinon.stub().callsArgWith(0, null, 100);
|
blockchainExplorer.getBlockchainHeight = sinon.stub().callsArgWith(0, null, 100);
|
||||||
|
|
||||||
|
// Cache txs
|
||||||
server.getTxHistory({
|
server.getTxHistory({
|
||||||
skip: skip,
|
skip: 0,
|
||||||
limit: limit,
|
limit: 30,
|
||||||
}, function(err, txs) {
|
}, function(err, txs) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
should.exist(txs);
|
should.exist(txs);
|
||||||
txs.length.should.equal(limit);
|
|
||||||
var calls = storeTxHistoryCacheSpy.getCalls();
|
var calls = storeTxHistoryCacheSpy.getCalls();
|
||||||
calls.length.should.equal(1);
|
calls.length.should.equal(1);
|
||||||
|
|
||||||
_.first(txs).confirmations.should.equal(82);
|
server.getTxHistory({
|
||||||
_.last(txs).confirmations.should.equal(101);
|
skip: 0,
|
||||||
|
limit: 30,
|
||||||
|
}, function(err, txs) {
|
||||||
|
should.not.exist(err);
|
||||||
|
txs.length.should.equal(20);
|
||||||
|
_.first(txs).confirmations.should.equal(1);
|
||||||
|
_.last(txs).confirmations.should.equal(20);
|
||||||
|
|
||||||
server.storage.storeTxHistoryCache.restore();
|
blockchainExplorer.getBlockchainHeight = sinon.stub().callsArgWith(0, null, 200);
|
||||||
Defaults.CONFIRMATIONS_TO_START_CACHING = _confirmations;
|
server.getTxHistory({
|
||||||
done();
|
skip: 0,
|
||||||
|
limit: 30,
|
||||||
|
}, function(err, txs) {
|
||||||
|
should.not.exist(err);
|
||||||
|
_.first(txs).confirmations.should.equal(101);
|
||||||
|
_.last(txs).confirmations.should.equal(120);
|
||||||
|
|
||||||
|
server.storage.storeTxHistoryCache.restore();
|
||||||
|
Defaults.CONFIRMATIONS_TO_START_CACHING = _confirmations;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -6370,29 +6388,35 @@ describe('Wallet service', function() {
|
||||||
var h = helpers.historyCacheTest(20);
|
var h = helpers.historyCacheTest(20);
|
||||||
helpers.stubHistory(h);
|
helpers.stubHistory(h);
|
||||||
var storeTxHistoryCacheSpy = sinon.spy(server.storage, 'storeTxHistoryCache');
|
var storeTxHistoryCacheSpy = sinon.spy(server.storage, 'storeTxHistoryCache');
|
||||||
var skip = 0;
|
|
||||||
var limit = 20;
|
|
||||||
|
|
||||||
var _getLastKnownBlockchainHeight = server._getLastKnownBlockchainHeight;
|
var _getLastKnownBlockchainHeight = server._getLastKnownBlockchainHeight;
|
||||||
server._getLastKnownBlockchainHeight = sinon.stub().callsArgWith(1, null, null);
|
server._getLastKnownBlockchainHeight = sinon.stub().callsArgWith(1, null, null);
|
||||||
|
|
||||||
|
// Cache txs
|
||||||
server.getTxHistory({
|
server.getTxHistory({
|
||||||
skip: skip,
|
skip: 0,
|
||||||
limit: limit,
|
limit: 30,
|
||||||
}, function(err, txs) {
|
}, function(err, txs) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
should.exist(txs);
|
should.exist(txs);
|
||||||
txs.length.should.equal(limit);
|
txs.length.should.equal(20);
|
||||||
var calls = storeTxHistoryCacheSpy.getCalls();
|
var calls = storeTxHistoryCacheSpy.getCalls();
|
||||||
calls.length.should.equal(1);
|
calls.length.should.equal(1);
|
||||||
|
|
||||||
_.first(txs).confirmations.should.equal(0);
|
server.getTxHistory({
|
||||||
_.last(txs).confirmations.should.equal(19);
|
skip: 0,
|
||||||
|
limit: 30,
|
||||||
|
}, function(err, txs) {
|
||||||
|
should.not.exist(err);
|
||||||
|
txs.length.should.equal(20);
|
||||||
|
_.first(txs).confirmations.should.equal(0);
|
||||||
|
_.last(txs).confirmations.should.equal(19);
|
||||||
|
|
||||||
server.storage.storeTxHistoryCache.restore();
|
server.storage.storeTxHistoryCache.restore();
|
||||||
Defaults.CONFIRMATIONS_TO_START_CACHING = _confirmations;
|
Defaults.CONFIRMATIONS_TO_START_CACHING = _confirmations;
|
||||||
server._getLastKnownBlockchainHeight = _getLastKnownBlockchainHeight;
|
server._getLastKnownBlockchainHeight = _getLastKnownBlockchainHeight;
|
||||||
done();
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue