Merge pull request #509 from tenthirtyone/fee-service

Updated fee service and cleaned console log from header service
This commit is contained in:
Alex 2017-07-25 18:32:31 -04:00 committed by GitHub
commit 1617681afb
3 changed files with 49 additions and 5 deletions

View File

@ -10,7 +10,7 @@ var FeeService = function(options) {
pass: 'local321',
host: 'localhost',
protocol: 'http',
port: this._getDefaultPort()
port: 8332
};
BaseService.call(this, options);
@ -34,8 +34,7 @@ FeeService.prototype.stop = function(callback) {
FeeService.prototype.getAPIMethods = function() {
return [
['estimateFee', this, this.estimateFee, 1],
['syncPercentage', this, this.syncPercentage, 0]
['estimateFee', this, this.estimateFee, 1]
];
};

View File

@ -34,8 +34,6 @@ HeaderService.STARTING_CHAINWORK = '00000000000000000000000000000000000000000000
// --- public prototype functions
HeaderService.prototype.subscribe = function(name, emitter) {
console.log(this.subscriptions, name);
this.subscriptions[name].push(emitter);
log.info(emitter.remoteAddress, 'subscribe:', 'header/' + name, 'total:', this.subscriptions[name].length);

View File

@ -0,0 +1,47 @@
'use strict';
var sinon = require('sinon');
var FeeService = require('../../../lib/services/fee');
var expect = require('chai').expect;
describe.only('#Fee Service', function() {
var feeService;
var sandbox;
beforeEach(function() {
sandbox = sinon.sandbox.create();
feeService = new FeeService({
"rpc": {
"user": "bitcoin",
"pass": "local321",
"host": "localhost",
"protocol": "http",
"port": 8332
}
});
});
afterEach(function() {
sandbox.restore();
});
/*
Running in regtest mode or unsync'd will return -1
*/
it("Has an estimateFee method", function() {
var method = feeService.getAPIMethods()[0][0];
expect(method).to.equal('estimateFee');
})
it("Can estimate fees", function(done) {
feeService.estimateFee(4, function(err, fee) {
expect(err).to.be.a('null');
expect(fee.result).to.exist;
expect(fee.result).to.be.at.least(-1);
done();
});
})
});