bitcoind-rpc
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -64,3 +64,3 @@ 'use strict'; | ||
var errorMessage = 'Bitcoin Core JSON-RPC: host=' + self.host + ' port=' + self.port + ': '; | ||
var errorMessage = 'Bitcoin JSON-RPC: '; | ||
@@ -89,2 +89,8 @@ var req = this.protocol.request(options, function(res) { | ||
} | ||
if (res.statusCode === 500 && buf.toString('utf8') === 'Work queue depth exceeded') { | ||
var exceededError = new Error('Bitcoin JSON-RPC: ' + buf.toString('utf8')); | ||
exceededError.code = 429; // Too many requests | ||
callback(exceededError); | ||
return; | ||
} | ||
@@ -110,3 +116,2 @@ var parsedBuf; | ||
var err = new Error(errorMessage + 'Request Error: ' + e.message); | ||
self.log.err(err); | ||
if (!called) { | ||
@@ -147,8 +152,16 @@ called = true; | ||
getAddedNodeInfo: '', | ||
getAddressMempool: 'obj', | ||
getAddressUtxos: 'obj', | ||
getAddressBalance: 'obj', | ||
getAddressDeltas: 'obj', | ||
getAddressTxids: 'obj', | ||
getAddressesByAccount: '', | ||
getBalance: 'str int', | ||
getBestBlockHash: '', | ||
getBlock: '', | ||
getBlock: 'str bool', | ||
getBlockchainInfo: '', | ||
getBlockCount: '', | ||
getBlockHashes: 'int int', | ||
getBlockHash: 'int', | ||
getBlockHeader: 'str', | ||
getBlockNumber: '', | ||
@@ -171,2 +184,3 @@ getBlockTemplate: '', | ||
getReceivedByAddress: 'str int', | ||
getSpentInfo: 'obj', | ||
getTransaction: '', | ||
@@ -173,0 +187,0 @@ getTxOut: 'str int bool', |
{ | ||
"name": "bitcoind-rpc", | ||
"description": "Bitcoin Client Library to connect to Bitcoin Core via RPC", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Stephen Pair", |
@@ -264,3 +264,3 @@ 'use strict'; | ||
should.exist(error); | ||
error.message.should.equal('Bitcoin Core JSON-RPC: host=localhost port=8332: Connection Rejected: 401 Unnauthorized'); | ||
error.message.should.equal('Bitcoin JSON-RPC: Connection Rejected: 401 Unnauthorized'); | ||
done(); | ||
@@ -295,3 +295,3 @@ }); | ||
should.exist(error); | ||
error.message.should.equal('Bitcoin Core JSON-RPC: host=localhost port=8332: Connection Rejected: 403 Forbidden'); | ||
error.message.should.equal('Bitcoin JSON-RPC: Connection Rejected: 403 Forbidden'); | ||
done(); | ||
@@ -302,2 +302,33 @@ }); | ||
it('should handle 500 work limit exceeded error', function(done) { | ||
var client = new RpcClient({ | ||
user: 'user', | ||
pass: 'pass', | ||
host: 'localhost', | ||
port: 8332, | ||
rejectUnauthorized: true, | ||
disableAgent: true | ||
}); | ||
var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){ | ||
var res = new FakeResponse(); | ||
res.statusCode = 500; | ||
setImmediate(function(){ | ||
res.emit('data', 'Work queue depth exceeded'); | ||
res.emit('end'); | ||
}); | ||
callback(res); | ||
return new FakeRequest(); | ||
}); | ||
client.getDifficulty(function(error, parsedBuf) { | ||
requestStub.restore(); | ||
should.exist(error); | ||
error.message.should.equal('Bitcoin JSON-RPC: Work queue depth exceeded'); | ||
done(); | ||
}); | ||
}); | ||
it('should handle EPIPE error case 1', function(done) { | ||
@@ -331,3 +362,3 @@ | ||
should.exist(error); | ||
error.message.should.equal('Bitcoin Core JSON-RPC: host=localhost port=8332: Request Error: write EPIPE'); | ||
error.message.should.equal('Bitcoin JSON-RPC: Request Error: write EPIPE'); | ||
done(); | ||
@@ -395,3 +426,3 @@ }); | ||
should.exist(error); | ||
error.message.should.equal('Bitcoin Core JSON-RPC: host=localhost port=8332: Request Error: connect ECONNREFUSED'); | ||
error.message.should.equal('Bitcoin JSON-RPC: Request Error: connect ECONNREFUSED'); | ||
done(); | ||
@@ -427,3 +458,3 @@ }); | ||
should.exist(error); | ||
error.message.should.equal('Bitcoin Core JSON-RPC: host=localhost port=8332: Error Parsing JSON: Unexpected token o'); | ||
error.message.should.equal('Bitcoin JSON-RPC: Error Parsing JSON: Unexpected token o'); | ||
done(); | ||
@@ -459,3 +490,3 @@ }); | ||
should.exist(error); | ||
error.message.should.equal('Bitcoin Core JSON-RPC: host=localhost port=8332: Error Parsing JSON: Unexpected end of input'); | ||
error.message.should.equal('Bitcoin JSON-RPC: Error Parsing JSON: Unexpected end of input'); | ||
done(); | ||
@@ -462,0 +493,0 @@ }); |
25901
704