Browse Source

log failed attempts to fetch network fee

activeAddress
Ivan Socolsky 10 years ago
parent
commit
28a6603032
  1. 13
      lib/server.js
  2. 16
      test/integration/server.js

13
lib/server.js

@ -777,6 +777,9 @@ WalletService.prototype._sampleFeeLevels = function(network, points, cb) {
log.error('Error estimating fee', err);
return next(err);
}
if (result.feePerKB < 0) {
log.warn('Could not compute fee estimation (nbBlocks=' + p + ')');
}
return next(null, [p, result.feePerKB * 1e8]);
});
}, function(err, results) {
@ -802,22 +805,22 @@ WalletService.prototype.getFeeLevels = function(opts, cb) {
var levels = [{
name: 'emergency',
nbBlocks: 2,
nbBlocks: 1,
modifier: 1.5,
defaultValue: 50000
}, {
name: 'priority',
nbBlocks: 2,
nbBlocks: 1,
modifier: 1,
defaultValue: 20000
}, {
name: 'normal',
nbBlocks: 6,
nbBlocks: 3,
modifier: 1,
defaultValue: 10000
}, {
name: 'economy',
nbBlocks: 25,
nbBlocks: 10,
modifier: 1,
defaultValue: 5000
}, ];
@ -830,7 +833,7 @@ WalletService.prototype.getFeeLevels = function(opts, cb) {
feePerKB = level.defaultValue;
} else {
var sample = feeSamples[level.nbBlocks];
feePerKB = (sample <= 0) ? level.defaultValue : sample * level.modifier;
feePerKB = (sample < 0) ? level.defaultValue : sample * level.modifier;
}
return {
level: level.name,

16
test/integration/server.js

@ -201,7 +201,7 @@ helpers.stubHistory = function(txs) {
helpers.stubFeeLevels = function(levels) {
blockchainExplorer.estimateFee = function(nbBlocks, cb) {
return cb(null, {
feePerKB: levels[nbBlocks] / 1e8 || -1
feePerKB: levels[nbBlocks] / 1e8
});
};
};
@ -1463,9 +1463,9 @@ describe('Wallet service', function() {
it('should get current fee levels', function(done) {
helpers.stubFeeLevels({
2: 40000,
6: 20000,
25: 18000,
1: 40000,
3: 20000,
10: 18000,
});
server.getFeeLevels({}, function(err, fees) {
should.not.exist(err);
@ -1495,9 +1495,9 @@ describe('Wallet service', function() {
});
it('should get default fees if network cannot estimate (returns -1)', function(done) {
helpers.stubFeeLevels({
2: -1,
6: 18000,
25: 0,
1: -1,
3: 18000,
10: 0,
});
server.getFeeLevels({}, function(err, fees) {
should.not.exist(err);
@ -1507,7 +1507,7 @@ describe('Wallet service', function() {
fees.emergency.should.equal(50000);
fees.priority.should.equal(20000);
fees.normal.should.equal(18000);
fees.economy.should.equal(5000);
fees.economy.should.equal(0);
done();
});
});

Loading…
Cancel
Save