return array instead of object

This commit is contained in:
Ivan Socolsky 2015-07-16 16:17:58 -03:00
parent b59a2a7d58
commit 6c6f726a06
2 changed files with 15 additions and 3 deletions

View File

@ -824,7 +824,7 @@ WalletService.prototype.getFeeLevels = function(opts, cb) {
var samplePoints = _.uniq(_.pluck(levels, 'nbBlocks')); var samplePoints = _.uniq(_.pluck(levels, 'nbBlocks'));
self._sampleFeeLevels(network, samplePoints, function(err, feeSamples) { self._sampleFeeLevels(network, samplePoints, function(err, feeSamples) {
var values = _.zipObject(_.map(levels, function(level) { var values = _.map(levels, function(level) {
var feePerKB; var feePerKB;
if (err) { if (err) {
feePerKB = level.defaultValue; feePerKB = level.defaultValue;
@ -832,8 +832,11 @@ WalletService.prototype.getFeeLevels = function(opts, cb) {
var sample = feeSamples[level.nbBlocks]; var sample = feeSamples[level.nbBlocks];
feePerKB = (sample <= 0) ? level.defaultValue : sample * level.modifier; feePerKB = (sample <= 0) ? level.defaultValue : sample * level.modifier;
} }
return [level.name, feePerKB] return {
})); level: level.name,
feePerKB: feePerKB,
};
});
return cb(null, values); return cb(null, values);
}); });

View File

@ -1469,6 +1469,9 @@ describe('Wallet service', function() {
}); });
server.getFeeLevels({}, function(err, fees) { server.getFeeLevels({}, function(err, fees) {
should.not.exist(err); should.not.exist(err);
fees = _.zipObject(_.map(fees, function(item) {
return [item.level, item.feePerKB];
}));
fees.emergency.should.equal(60000); fees.emergency.should.equal(60000);
fees.priority.should.equal(40000); fees.priority.should.equal(40000);
fees.normal.should.equal(20000); fees.normal.should.equal(20000);
@ -1480,6 +1483,9 @@ describe('Wallet service', function() {
blockchainExplorer.estimateFee = sinon.stub().yields('dummy error'); blockchainExplorer.estimateFee = sinon.stub().yields('dummy error');
server.getFeeLevels({}, function(err, fees) { server.getFeeLevels({}, function(err, fees) {
should.not.exist(err); should.not.exist(err);
fees = _.zipObject(_.map(fees, function(item) {
return [item.level, item.feePerKB];
}));
fees.emergency.should.equal(50000); fees.emergency.should.equal(50000);
fees.priority.should.equal(20000); fees.priority.should.equal(20000);
fees.normal.should.equal(10000); fees.normal.should.equal(10000);
@ -1495,6 +1501,9 @@ describe('Wallet service', function() {
}); });
server.getFeeLevels({}, function(err, fees) { server.getFeeLevels({}, function(err, fees) {
should.not.exist(err); should.not.exist(err);
fees = _.zipObject(_.map(fees, function(item) {
return [item.level, item.feePerKB];
}));
fees.emergency.should.equal(50000); fees.emergency.should.equal(50000);
fees.priority.should.equal(20000); fees.priority.should.equal(20000);
fees.normal.should.equal(18000); fees.normal.should.equal(18000);