fix confirmations computation

This commit is contained in:
Ivan Socolsky 2016-08-06 13:12:25 -03:00
parent 4e7f1f39d9
commit f423f8a567
No known key found for this signature in database
GPG Key ID: FAECE6A05FAA4F56
2 changed files with 5 additions and 5 deletions

View File

@ -2838,7 +2838,7 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
if (err || !height) return next(err); if (err || !height) return next(err);
_.each(txs, function(tx) { _.each(txs, function(tx) {
if (tx.blockheight >= 0) { if (tx.blockheight >= 0) {
tx.confirmations = height - tx.blockheight; tx.confirmations = height - tx.blockheight + 1;
} }
}); });
next(); next();

View File

@ -6271,7 +6271,7 @@ describe('Wallet service', function() {
calls[0].args[3].length.should.equal(5); // 5 txs have confirmations>= 100 calls[0].args[3].length.should.equal(5); // 5 txs have confirmations>= 100
// should be reversed! // should be reversed!
calls[0].args[3][0].confirmations.should.equal(currentHeight - (totalItems - (skip + limit))); calls[0].args[3][0].confirmations.should.equal(currentHeight - (totalItems - (skip + limit)) + 1);
calls[0].args[3][0].txid.should.equal(h[skip + limit - 1].txid); calls[0].args[3][0].txid.should.equal(h[skip + limit - 1].txid);
server.storage.storeTxHistoryCache.restore(); server.storage.storeTxHistoryCache.restore();
done(); done();
@ -6325,7 +6325,7 @@ describe('Wallet service', function() {
calls[0].args[3].length.should.equal(5); calls[0].args[3].length.should.equal(5);
// should be reversed! // should be reversed!
calls[0].args[3][0].confirmations.should.equal(currentHeight); calls[0].args[3][0].confirmations.should.equal(currentHeight + 1);
calls[0].args[3][0].txid.should.equal(h[totalItems - 1].txid); calls[0].args[3][0].txid.should.equal(h[totalItems - 1].txid);
server.storage.storeTxHistoryCache.restore(); server.storage.storeTxHistoryCache.restore();
done(); done();
@ -6354,8 +6354,8 @@ describe('Wallet service', function() {
var calls = storeTxHistoryCacheSpy.getCalls(); var calls = storeTxHistoryCacheSpy.getCalls();
calls.length.should.equal(1); calls.length.should.equal(1);
_.first(txs).confirmations.should.equal(81); _.first(txs).confirmations.should.equal(82);
_.last(txs).confirmations.should.equal(100); _.last(txs).confirmations.should.equal(101);
server.storage.storeTxHistoryCache.restore(); server.storage.storeTxHistoryCache.restore();
Defaults.CONFIRMATIONS_TO_START_CACHING = _confirmations; Defaults.CONFIRMATIONS_TO_START_CACHING = _confirmations;