Skip to content

Commit

Permalink
Merge 076d00e into 54af702
Browse files Browse the repository at this point in the history
  • Loading branch information
Prtfw committed Mar 3, 2017
2 parents 54af702 + 076d00e commit ec2a1fe
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/services/bitcoind.js
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,16 @@ Bitcoin.prototype.getInfo = function(callback) {
});
};

Bitcoin.prototype.getMNlist = function(callback) {
var self = this;
this.client.masternodelist('full', function(err, response) {
if (err) {
return callback(self._wrapRPCError(err));
}
callback(null, response.result);
});
};

Bitcoin.prototype.generateBlock = function(num, callback) {
var self = this;
this.client.generate(num, function(err, response) {
Expand Down
41 changes: 41 additions & 0 deletions test/services/bitcoind.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5177,6 +5177,47 @@ describe('Bitcoin Service', function() {

});

describe('#getMNlist', function() {
var MNdetails = {
'3e739c0219595365c28cb8e14606f18d183500ee13bbedfee8c755a502cbc70a-1': 'NEW_START_REQUIRED 70206 yXXQNnSDhijos1Ucq9NiJMEcFRF6nZGjKq 1486207842 170674 0 0 88.99.15.34:19999',
'a9dec34daa02d7537d47cefdb2c5131585f97eb8b90c1ccf63675ed3129ca704-1': 'NEW_START_REQUIRED 70206 yaffS5bPkfZ211SXbvNyQxFRRP5tL2dZtN 1486196162 0 0 0 176.31.145.17:19999',
'88f33da9565bfa2e793402900a894d55ad96039c82ca0ef6919d33141761c4c9-0': 'NEW_START_REQUIRED 70206 yTJSNXHqp1uxSTVQDm1abPUsQJKgvcUqsb 1487206254 302622 0 0 5.45.104.74:19999',
};
it('will give rpc error', function(done) {
var bitcoind = new BitcoinService(baseConfig);
var masternodelist = sinon.stub().callsArgWith(1, 'full', {message: 'error', code: -1});
bitcoind.nodes.push({
client: {
masternodelist: masternodelist
}
});
bitcoind.getMNlist(function(err, response) {
should.exist(err);
err.should.be.an.instanceof(errors.RPCError);
done();
});
});
it('will call client masternode full and give result', function(done) {
var bitcoind = new BitcoinService(baseConfig);
bitcoind.node.getNetworkName = sinon.stub().returns('testnet');
var masternodelist = sinon.stub().callsArgWith(1, null, {
result: MNdetails
});
bitcoind.nodes.push({
client: {
masternodelist: masternodelist
}
});
bitcoind.getMNlist(function(err, response) {
if (err) {
return done(err);
}
response.should.equal(MNdetails);
done();
});
});
});

describe('#generateBlock', function() {
it('will give rpc error', function(done) {
var bitcoind = new BitcoinService(baseConfig);
Expand Down

0 comments on commit ec2a1fe

Please sign in to comment.