Browse Source

Squashed 'libjsqrc/ethereumjs/' changes from a0cfa3c..f3e1797

f3e1797 fixed jsonrpc response 0 not handled properly

git-subtree-dir: libjsqrc/ethereumjs
git-subtree-split: f3e1797153ebf5b19ca3e154cf1240be738e4f08
cl-refactor
Marek Kotewicz 10 years ago
parent
commit
2d09638fde
  1. 2
      dist/ethereum.js
  2. 2
      dist/ethereum.js.map
  3. 2
      dist/ethereum.min.js
  4. 2
      lib/jsonrpc.js
  5. 15
      test/jsonrpc.isValidResponse.js

2
dist/ethereum.js

@ -979,7 +979,7 @@ var isValidResponse = function (response) {
!response.error &&
response.jsonrpc === '2.0' &&
typeof response.id === 'number' &&
(!!response.result || typeof response.result === 'boolean');
response.result !== undefined; // only undefined is not valid json object
};
/// Should be called to create batch payload object

2
dist/ethereum.js.map

File diff suppressed because one or more lines are too long

2
dist/ethereum.min.js

File diff suppressed because one or more lines are too long

2
lib/jsonrpc.js

@ -45,7 +45,7 @@ var isValidResponse = function (response) {
!response.error &&
response.jsonrpc === '2.0' &&
typeof response.id === 'number' &&
(!!response.result || typeof response.result === 'boolean');
response.result !== undefined; // only undefined is not valid json object
};
/// Should be called to create batch payload object

15
test/jsonrpc.isValidResponse.js

@ -124,5 +124,20 @@ describe('jsonrpc', function () {
assert.equal(valid, true);
});
it('should validate jsonrpc response with result field === 0', function () {
// given
var response = {
jsonrpc: '2.0',
id: 1,
result: 0
};
// when
var valid = jsonrpc.isValidResponse(response);
// then
assert.equal(valid, true);
});
});
});

Loading…
Cancel
Save