fixed jsonrpc response 0 not handled properly
This commit is contained in:
parent
a0cfa3ca21
commit
f3e1797153
2
dist/ethereum.js
vendored
2
dist/ethereum.js
vendored
@ -979,7 +979,7 @@ var isValidResponse = function (response) {
|
|||||||
!response.error &&
|
!response.error &&
|
||||||
response.jsonrpc === '2.0' &&
|
response.jsonrpc === '2.0' &&
|
||||||
typeof response.id === 'number' &&
|
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
|
/// Should be called to create batch payload object
|
||||||
|
2
dist/ethereum.js.map
vendored
2
dist/ethereum.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/ethereum.min.js
vendored
2
dist/ethereum.min.js
vendored
File diff suppressed because one or more lines are too long
@ -45,7 +45,7 @@ var isValidResponse = function (response) {
|
|||||||
!response.error &&
|
!response.error &&
|
||||||
response.jsonrpc === '2.0' &&
|
response.jsonrpc === '2.0' &&
|
||||||
typeof response.id === 'number' &&
|
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
|
/// Should be called to create batch payload object
|
||||||
|
@ -124,5 +124,20 @@ describe('jsonrpc', function () {
|
|||||||
assert.equal(valid, true);
|
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…
Reference in New Issue
Block a user