From aba749e4c4faf23fec9672fdec30baabe181ca6e Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Tue, 28 Nov 2017 22:53:46 +0000 Subject: [PATCH 1/2] add eth_getStorageAt RPC schema/tests --- rpc-specs-tests/schemas/eth_getStorageAt.json | 64 +++++++++++++++++++ rpc-specs-tests/tests/eth_getStorageAt.json | 45 +++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 rpc-specs-tests/schemas/eth_getStorageAt.json create mode 100644 rpc-specs-tests/tests/eth_getStorageAt.json diff --git a/rpc-specs-tests/schemas/eth_getStorageAt.json b/rpc-specs-tests/schemas/eth_getStorageAt.json new file mode 100644 index 0000000..95ae31b --- /dev/null +++ b/rpc-specs-tests/schemas/eth_getStorageAt.json @@ -0,0 +1,64 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "eth_getStorageAt", + "title": "eth_getStorageAt", + "description": "eth_getStorageAt JSON-RPC method request and response schema.", + + "request": { + "id": "#request", + "allOf": [ + { "$ref": "jsonrpc-request.json" }, + { "$ref": "#/definitions/request-obj" } + ], + "definitions": { + "request-obj": { + "id": "#request-obj", + "properties": { + "method": { + "type": "string", + "enum": ["eth_getStorageAt"] + }, + "params": { + "type": "array", + "items": [ + { + "type": "string", + "description": "DATA, 32 Bytes - Hash of a block." + }, + { + "type": "string", + "description": "QUANTITY- Integer position in the storage." + }, + { + "type": "string", + "description": "QUANTITY|TAG - integer block number, or the string \"latest\", \"earliest\" or \"pending\"" + } + ], + "minItems": 3, + "maxItems": 3 + } + } + } + } + }, + + + "response": { + "id": "#response", + "allOf": [ + { "$ref": "jsonrpc-response.json" }, + { "$ref": "#/definitions/response-obj" } + ], + "definitions": { + "response-obj": { + "id": "#response-obj", + "properties": { + "result": { + "type": "string" + } + } + } + } + } + +} diff --git a/rpc-specs-tests/tests/eth_getStorageAt.json b/rpc-specs-tests/tests/eth_getStorageAt.json new file mode 100644 index 0000000..6e7daad --- /dev/null +++ b/rpc-specs-tests/tests/eth_getStorageAt.json @@ -0,0 +1,45 @@ +{ + "title" : "eth_getStorageAt", + "schema": { + "$ref": "../schemas/eth_getStorageAt.json" + }, + + "chainConfig" : { + "$ref": "../configs/bcRPC_API_Test.json" + }, + + "tests": [ + { + "title": "eth_getStorageAt latest block with non-zero storage key", + "request" : { + "method" : "eth_getStorageAt", + "params" : ["0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "0x01", "latest"] + }, + "expectedResponse" : { + "result": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee" + }, + "asserts": [ + { + "description": "response has blockHeader hash", + "program": ".receivedResponse.result != null" + } + ] + }, + { + "title": "eth_getStorageAt earliest block with zero storage key", + "request" : { + "method" : "eth_getStorageAt", + "params" : ["0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "0x01", "earliest"] + }, + "expectedResponse" : { + "result": "0000000000000000000000000000000000000000000000000000000000000000" + }, + "asserts": [ + { + "description": "response has blockHeader hash", + "program": ".receivedResponse.result != null" + } + ] + } + ] +} From 8e7071f662a0aa4047553aec65146a8e0b99e9b8 Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Wed, 29 Nov 2017 01:29:08 +0000 Subject: [PATCH 2/2] add eth_getBalance --- rpc-specs-tests/schemas/eth_getBalance.json | 58 +++++++++++++++++++++ rpc-specs-tests/tests/eth_getBalance.json | 29 +++++++++++ 2 files changed, 87 insertions(+) create mode 100644 rpc-specs-tests/schemas/eth_getBalance.json create mode 100644 rpc-specs-tests/tests/eth_getBalance.json diff --git a/rpc-specs-tests/schemas/eth_getBalance.json b/rpc-specs-tests/schemas/eth_getBalance.json new file mode 100644 index 0000000..e6b3298 --- /dev/null +++ b/rpc-specs-tests/schemas/eth_getBalance.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "eth_getBalance", + "title": "eth_getBalance", + "description": "eth_getBalance JSON-RPC method request and response schema.", + + "request": { + "id": "#request", + "allOf": [ + { "$ref": "jsonrpc-request.json" }, + { "$ref": "#/definitions/request-obj" } + ], + "definitions": { + "request-obj": { + "id": "#request-obj", + "properties": { + "method": { + "type": "string", + "enum": ["eth_getBalance"] + }, + "params": { + "type": "array", + "items": [ + { + "type": "string", + "description": "DATA, 32 Bytes - Account." + }, + { + "type": "string", + "description": "QUANTITY|TAG - integer block number, or the string \"latest\", \"earliest\" or \"pending\"" + } + ], + "minItems": 2, + "maxItems": 2 + } + } + } + } + }, + "response": { + "id": "#response", + "allOf": [ + { "$ref": "jsonrpc-response.json" }, + { "$ref": "#/definitions/response-obj" } + ], + "definitions": { + "response-obj": { + "id": "#response-obj", + "properties": { + "result": { + "description": "QUANTITY", + "type": "string" + } + } + } + } + } +} diff --git a/rpc-specs-tests/tests/eth_getBalance.json b/rpc-specs-tests/tests/eth_getBalance.json new file mode 100644 index 0000000..e678e8b --- /dev/null +++ b/rpc-specs-tests/tests/eth_getBalance.json @@ -0,0 +1,29 @@ +{ + "title" : "eth_getBalance", + "schema": { + "$ref": "../schemas/eth_getBalance.json" + }, + + "chainConfig" : { + "$ref": "../configs/bcRPC_API_Test.json" + }, + + "tests": [ + { + "title": "eth_getBalance earliest block", + "request" : { + "method" : "eth_getBalance", + "params" : ["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "earliest"] + }, + "expectedResponse" : { + "result": "09184e72a000" + }, + "asserts": [ + { + "description": "response valid", + "program": ".receivedResponse.result != null" + } + ] + } + ] +}