Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before(async() => {
reset();
bitcoindHelp = sinon.stub(require('bitcoind-rpc').prototype, 'help').callsFake(callback => callback(undefined, {}));
// TODO: expires Dec 1st, 2019
jwt = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6InRlc3QtdXNlciIsImlhdCI6MTU3NTIyNjQxMn0.N06esl2dhN1mFqn-0o4KQmmAaDW9OsHA39calpp_N9B3Ig3aXWgl064XAR9YVK0qwX7zMOnK9UrJ48KUZ-Sb4A';
});
it('should respond with a valid version', done => {
bitcoindRPCGetNetworkInfo = sinon.stub(require('bitcoind-rpc').prototype, 'getNetworkInfo').callsFake(callback => callback(undefined, {
result:
{
subversion: '/Satoshi:0.17.0/'
}
}));
requester
.get('/v1/bitcoind/info/version')
.set('authorization', `JWT ${token}`)
.end((err, res) => {
if (err) {
done(err);
}
res.should.have.status(200);
res.should.be.json;
res.body.should.have.property('version');
res.body.version.should.equal('0.17.0');
if (!MODE[this.mode]) { throw new Error(`unexpected mode ${this.mode}`) }
this.reconnect = (this.config.reconnect === undefined ? true : false);
const rpcconfig = Object.assign({}, {
protocol: "http",
host: "127.0.0.1",
port: "8332",
}, this.config.rpc);
this.ready = function() {};
this.blockreq = null;
this.queue = new Queue(1, Infinity);
this.rpc = new RPCClient(rpcconfig);
this.currheight = 0;
this.blockheight = 0;
this.peer = new Peer({ host: this.config.peer.host, messages });
this.peer.on("ready", () => {
this.onconnect();
});
this.peer.on("disconnect", async () => {
await this.ondisconnect();
});
this.peer.on("block", async (message) => {
if (this.mode == MODE.MEMPOOL) {