Merge pull request #509 from tenthirtyone/fee-service
Updated fee service and cleaned console log from header service
This commit is contained in:
commit
1617681afb
@ -10,7 +10,7 @@ var FeeService = function(options) {
|
|||||||
pass: 'local321',
|
pass: 'local321',
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
protocol: 'http',
|
protocol: 'http',
|
||||||
port: this._getDefaultPort()
|
port: 8332
|
||||||
};
|
};
|
||||||
BaseService.call(this, options);
|
BaseService.call(this, options);
|
||||||
|
|
||||||
@ -34,8 +34,7 @@ FeeService.prototype.stop = function(callback) {
|
|||||||
|
|
||||||
FeeService.prototype.getAPIMethods = function() {
|
FeeService.prototype.getAPIMethods = function() {
|
||||||
return [
|
return [
|
||||||
['estimateFee', this, this.estimateFee, 1],
|
['estimateFee', this, this.estimateFee, 1]
|
||||||
['syncPercentage', this, this.syncPercentage, 0]
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -34,8 +34,6 @@ HeaderService.STARTING_CHAINWORK = '00000000000000000000000000000000000000000000
|
|||||||
|
|
||||||
// --- public prototype functions
|
// --- public prototype functions
|
||||||
HeaderService.prototype.subscribe = function(name, emitter) {
|
HeaderService.prototype.subscribe = function(name, emitter) {
|
||||||
|
|
||||||
console.log(this.subscriptions, name);
|
|
||||||
this.subscriptions[name].push(emitter);
|
this.subscriptions[name].push(emitter);
|
||||||
log.info(emitter.remoteAddress, 'subscribe:', 'header/' + name, 'total:', this.subscriptions[name].length);
|
log.info(emitter.remoteAddress, 'subscribe:', 'header/' + name, 'total:', this.subscriptions[name].length);
|
||||||
|
|
||||||
|
|||||||
47
test/services/fee/index.unit.js
Normal file
47
test/services/fee/index.unit.js
Normal 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();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user