diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-02-04 06:00:02 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-02-04 06:00:02 +0800 |
commit | e58e2f5ee466f054405b3e90a67720254ea17ead (patch) | |
tree | 292927f3c2b7ac548376b0d42aa5e6ac67ec85c0 /dist/ethereum.js | |
parent | 45134de7401b58f0118deb16bf0644495715fbdb (diff) | |
download | go-tangerine-e58e2f5ee466f054405b3e90a67720254ea17ead.tar go-tangerine-e58e2f5ee466f054405b3e90a67720254ea17ead.tar.gz go-tangerine-e58e2f5ee466f054405b3e90a67720254ea17ead.tar.bz2 go-tangerine-e58e2f5ee466f054405b3e90a67720254ea17ead.tar.lz go-tangerine-e58e2f5ee466f054405b3e90a67720254ea17ead.tar.xz go-tangerine-e58e2f5ee466f054405b3e90a67720254ea17ead.tar.zst go-tangerine-e58e2f5ee466f054405b3e90a67720254ea17ead.zip |
jsonrpc.js tests && jsonrpc response validation is more strict
Diffstat (limited to 'dist/ethereum.js')
-rw-r--r-- | dist/ethereum.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/dist/ethereum.js b/dist/ethereum.js index 06dfff0b7..564d59b4a 100644 --- a/dist/ethereum.js +++ b/dist/ethereum.js @@ -973,9 +973,13 @@ var toPayload = function (method, params) { }; /// Should be called to check if jsonrpc response is valid -/// @returns true if response doesn't have error field +/// @returns true if response is valid, otherwise false var isValidResponse = function (response) { - return response && !response.error; + return !!response && + !response.error && + response.jsonrpc === '2.0' && + typeof response.id === 'number' && + (!!response.result || typeof response.result === 'boolean'); }; /// Should be called to create batch payload object @@ -1051,6 +1055,7 @@ var ProviderManager = function() { var result = results[index]; if (!jsonrpc.isValidResponse(result)) { + console.log(result); return; } @@ -1083,7 +1088,7 @@ ProviderManager.prototype.send = function(data) { var result = this.provider.send(payload); if (!jsonrpc.isValidResponse(result)) { - console.log(result.error); + console.log(result); return null; } |