better tests

This commit is contained in:
Matias Alejo Garcia 2016-07-27 09:57:54 -03:00
parent 5db61703b4
commit 63e6847767
No known key found for this signature in database
GPG Key ID: 02470DB551277AB3
3 changed files with 11 additions and 4 deletions

View File

@ -81,6 +81,5 @@ var config = {
// api_user: xxx,
// api_key: xxx,
// });
confirmationsToStartCaching: 100,
};
module.exports = config;

View File

@ -70,4 +70,8 @@ Defaults.UTXO_SELECTION_MAX_FEE_VS_SINGLE_UTXO_FEE_FACTOR = 5;
// Minimum allowed amount for tx outputs (including change) in SAT
Defaults.MIN_OUTPUT_AMOUNT = 5000;
Defaults.CONFIRMATIONS_TO_START_CACHING = 100;
Defaults.HISTORY_CACHE_ADDRESS_THRESOLD = 100;
module.exports = Defaults;

View File

@ -57,7 +57,6 @@ function WalletService() {
this.messageBroker = messageBroker;
this.fiatRateService = fiatRateService;
this.notifyTicker = 0;
this.confirmationsToStartCaching = config.confirmationsToStartCaching || 100;
};
function checkRequired(obj, args, cb) {
@ -2789,13 +2788,18 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
bc.getTransactions(addressStrs, from, to, function(err, txs, total) {
if (err) return cb(err);
var txsNormalized = self._normalizeTxHistory(txs);
next(err, txsNormalized);
if (addresses.length < Defaults.HISTORY_CACHE_ADDRESS_THRESOLD)
return;
var txsToCache = _.filter(txsNormalized, function(i) {
return i.confirmations >= self.confirmationsToStartCaching;
return i.confirmations >= Defaults.CONFIRMATIONS_TO_START_CACHING;
}).reverse();
var index = total - to;
if (index < 0) index = 0;
self.storage.storeTxHistoryCache(self.walletId, total, index, txsToCache, function(err) {
next(err, txsNormalized);
if (err) log.warn(err);
})
});
},