diff --git a/js/log.js b/js/log.js index 8a011a665..6dc4305dd 100644 --- a/js/log.js +++ b/js/log.js @@ -101,5 +101,4 @@ Logger.prototype.setLevel = function(level) { var logger = new Logger('copay'); logger.setLevel(config.logLevel); -logger.log('Log level:' + config.logLevel); module.exports = logger; diff --git a/js/services/rate.js b/js/services/rate.js index 0c28ae046..68f96c313 100644 --- a/js/services/rate.js +++ b/js/services/rate.js @@ -4,6 +4,7 @@ var RateService = function(request) { this.isAvailable = false; this.UNAVAILABLE_ERROR = 'Service is not available - check for service.isAvailable or use service.whenAvailable'; this.SAT_TO_BTC = 1 / 1e8; + this.BTC_TO_SAT = 1e8; var MINS_IN_HOUR = 60; var MILLIS_IN_SECOND = 1000; var rateServiceConfig = config.rate; @@ -62,7 +63,7 @@ RateService.prototype.fromFiat = function(amount, code) { if (!this.isAvailable) { throw new Error(this.UNAVAILABLE_ERROR); } - return amount / this.rates[code] / this.SAT_TO_BTC; + return amount / this.rates[code] * this.BTC_TO_SAT; }; RateService.prototype.listAlternatives = function() { diff --git a/test/unit/services/servicesSpec.js b/test/unit/services/servicesSpec.js index 2d827c6fd..dd2805a96 100644 --- a/test/unit/services/servicesSpec.js +++ b/test/unit/services/servicesSpec.js @@ -26,7 +26,7 @@ describe("Unit: controllerUtils", function() { var Waddr = Object.keys($rootScope.wallet.balanceByAddr)[0]; var a = {}; a[Waddr] = 100; - //SATs + //SATs $rootScope.wallet.set(100000001, 90000002, a); //retuns values in DEFAULT UNIT(bits) @@ -124,17 +124,23 @@ describe('Unit: Rate Service', function() { }); })); it('should be possible to ask for conversion from fiat', - inject(function(rateService) { - rateService.whenAvailable(function() { - (1).should.equal(rateService.fromFiat(2, 'LOL')); - }); - }) + function(done) { + inject(function(rateService) { + rateService.whenAvailable(function() { + (1e8).should.equal(rateService.fromFiat(2, 'LOL')); + done(); + }); + }) + } ); it('should be possible to ask for conversion to fiat', - inject(function(rateService) { - rateService.whenAvailable(function() { - (2).should.equal(rateService.toFiat(1e8, 'LOL')); - }); - }) + function(done) { + inject(function(rateService) { + rateService.whenAvailable(function() { + (2).should.equal(rateService.toFiat(1e8, 'LOL')); + done(); + }); + }) + } ); });