Skip to content

Commit

Permalink
Test fixed with new JSON response
Browse files Browse the repository at this point in the history
  • Loading branch information
agustinkassis committed Jun 20, 2017
1 parent becb791 commit e9efae3
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions test/index.js
Expand Up @@ -75,7 +75,7 @@ describe('RpcClient', function() {
var client = new RpcClient({
user: 'user',
pass: 'pass',
port: 8332,
port: 51473,
});
client.protocol.should.equal(https);

Expand All @@ -87,7 +87,7 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
protocol: 'http'
});
client.protocol.should.equal(http);
Expand All @@ -100,12 +100,12 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
rejectUnauthorized: true,
disableAgent: true
});

var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){
var res = new FakeResponse();
var req = new FakeRequest();
setImmediate(function(){
Expand All @@ -131,12 +131,12 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
rejectUnauthorized: true,
disableAgent: false
});

var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){
var res = new FakeResponse();
var req = new FakeRequest();
setImmediate(function(){
Expand Down Expand Up @@ -167,12 +167,12 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
rejectUnauthorized: true,
disableAgent: false
});

var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){
var res = new FakeResponse();
var req = new FakeRequest();
setImmediate(function(){
Expand Down Expand Up @@ -204,12 +204,12 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
rejectUnauthorized: true,
disableAgent: false
});

var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){
var res = new FakeResponse();
setImmediate(function(){
res.emit('data', '[{}, {}, {}]');
Expand Down Expand Up @@ -243,12 +243,12 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
rejectUnauthorized: true,
disableAgent: true
});

var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){
var res = new FakeResponse();
res.statusCode = 401;
setImmediate(function(){
Expand All @@ -273,12 +273,12 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
rejectUnauthorized: true,
disableAgent: true
});

var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){
var res = new FakeResponse();
res.statusCode = 403;
setImmediate(function(){
Expand All @@ -303,12 +303,12 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
rejectUnauthorized: true,
disableAgent: true
});

var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){
var res = new FakeResponse();
res.statusCode = 500;
setImmediate(function(){
Expand All @@ -334,12 +334,12 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
rejectUnauthorized: true,
disableAgent: true
});

var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){
var req = new FakeRequest();
setImmediate(function(){
req.emit('error', new Error('write EPIPE'));
Expand Down Expand Up @@ -368,12 +368,12 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
rejectUnauthorized: true,
disableAgent: true
});

var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){
var res = new FakeResponse();
setImmediate(function(){
res.emit('data', '{}');
Expand Down Expand Up @@ -401,12 +401,12 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
rejectUnauthorized: true,
disableAgent: true
});

var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){
var res = new FakeResponse();
var req = new FakeRequest();
setImmediate(function(){
Expand All @@ -431,12 +431,12 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
rejectUnauthorized: true,
disableAgent: true
});

var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){
var res = new FakeResponse();
setImmediate(function(){
res.emit('data', 'not a json string');
Expand All @@ -450,7 +450,7 @@ describe('RpcClient', function() {
client.getDifficulty(function(error, parsedBuf) {
requestStub.restore();
should.exist(error);
error.message.should.equal('Bitcoin JSON-RPC: Error Parsing JSON: Unexpected token o');
error.message.should.equal('Bitcoin JSON-RPC: Error Parsing JSON: Unexpected token o in JSON at position 1');
done();
});

Expand All @@ -462,12 +462,12 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
rejectUnauthorized: true,
disableAgent: true
});

var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){
var res = new FakeResponse();
setImmediate(function(){
res.emit('data', '');
Expand All @@ -481,7 +481,7 @@ describe('RpcClient', function() {
client.getDifficulty(function(error, parsedBuf) {
requestStub.restore();
should.exist(error);
error.message.should.equal('Bitcoin JSON-RPC: Error Parsing JSON: Unexpected end of input');
error.message.should.equal('Bitcoin JSON-RPC: Error Parsing JSON: Unexpected end of JSON input');
done();
});

Expand All @@ -493,7 +493,7 @@ describe('RpcClient', function() {
user: 'user',
pass: 'pass',
host: 'localhost',
port: 8332,
port: 51473,
rejectUnauthorized: true,
disableAgent: true
});
Expand All @@ -504,7 +504,7 @@ describe('RpcClient', function() {

var calledPort = false;

var requestStub = sinon.stub(client.protocol, 'request', function(options, callback){
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){
calledPort = options.port;
var res = new FakeResponse();
setImmediate(function(){
Expand Down

0 comments on commit e9efae3

Please sign in to comment.