diff --git a/lib/fiatrateservice.js b/lib/fiatrateservice.js index 0b6849d..a0f06e7 100644 --- a/lib/fiatrateservice.js +++ b/lib/fiatrateservice.js @@ -110,11 +110,11 @@ FiatRateService.prototype.getRate = function(code, opts, cb) { opts = opts || {}; - var providerName = opts.providerName || DEFAULT_PROVIDER; + var provider = opts.provider || DEFAULT_PROVIDER; var ts = opts.ts || Date.now(); async.map([].concat(ts), function(ts, cb) { - self.storage.fetchFiatRate(providerName, code, ts, function(err, rate) { + self.storage.fetchFiatRate(provider, code, ts, function(err, rate) { if (err) return cb(err); return cb(null, { ts: +ts, diff --git a/test/integration/fiatrateservice.js b/test/integration/fiatrateservice.js index 304dd48..ea6b6bb 100644 --- a/test/integration/fiatrateservice.js +++ b/test/integration/fiatrateservice.js @@ -67,6 +67,33 @@ describe.only('Fiat rate service', function() { }); }); }); + + it('should get current rate for different provider', function(done) { + service.storage.storeFiatRate('BitPay', [{ + code: 'USD', + value: 100.00, + }], function(err) { + should.not.exist(err); + service.storage.storeFiatRate('Bitstamp', [{ + code: 'USD', + value: 200.00, + }], function(err) { + should.not.exist(err); + service.getRate('USD', {}, function(err, res) { + should.not.exist(err); + res.rate.should.equal(100.00, 'Should use default provider'); + service.getRate('USD', { + provider: 'Bitstamp' + }, function(err, res) { + should.not.exist(err); + res.rate.should.equal(200.00); + done(); + }); + }); + }); + }); + }); + it('should get rate for specific ts', function(done) { var clock = sinon.useFakeTimers(0, 'Date'); clock.tick(20);