diff options
-rw-r--r-- | JSONSchema/bc-schema.json | 190 | ||||
-rw-r--r-- | JSONSchema/definitions.json | 200 | ||||
-rw-r--r-- | JSONSchema/st-filler-schema.json | 103 | ||||
-rw-r--r-- | JSONSchema/st-schema.json | 140 | ||||
-rwxr-xr-x | test.py | 10 |
5 files changed, 208 insertions, 435 deletions
diff --git a/JSONSchema/bc-schema.json b/JSONSchema/bc-schema.json index 26ef855e1..b40f14219 100644 --- a/JSONSchema/bc-schema.json +++ b/JSONSchema/bc-schema.json @@ -106,138 +106,6 @@ } } }, - "EmptyString": { - "type": "string", - "pattern": "^$" - }, - "HexData": { - "description": "Hex data. see https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding", - "pattern": "^0x([0-9a-fA-F][0-9a-fA-F])*$", - "type": "string" - }, - "HexQuantity": { - "description": "Hex quantity. see https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding", - "pattern": "(^0x0$)|(^0x[1-9a-fA-F][0-9a-fA-F]*$)", - "type": "string" - }, - "ConfusedHexType": { - "anyOf": [ - { - "$ref": "#/definitions/HexData" - }, - { - "$ref": "#/definitions/HexQuantity" - } - ] - }, - "HexDataOrEmpty": { - "oneOf": [ - { - "$ref": "#/definitions/HexData" - }, - { - "$ref": "#/definitions/EmptyString" - } - ] - }, - "HexNoPrefix": { - "pattern": "^([0-9a-fA-F][0-9a-fA-F])+$", - "type": "string" - }, - "HexMaybePrefix": { - "oneOf": [ - { - "$ref": "#/definitions/HexNoPrefix" - }, - { - "$ref": "#/definitions/HexData" - } - ] - }, - "HexMaybePrefixOrEmpty": { - "oneOf": [ - { - "$ref": "#/definitions/HexMaybePrefix" - }, - { - "$ref": "#/definitions/EmptyString" - } - ] - }, - "IntegerString": { - "pattern": "^[0-9]+$", - "type": "string" - }, - "IntegerOrEmpty": { - "oneOf": [ - { - "$ref": "#/definitions/IntegerString" - }, - { - "$ref": "#/definitions/EmptyString" - } - ] - }, - "IntegerOrNumber": { - "oneOf": [ - { - "$ref": "#/definitions/IntegerString" - }, - { - "type": "number" - } - ] - }, - "IntegerOrNumberOrConfusedHex": { - "oneOf": [ - { - "$ref": "#/definitions/IntegerOrNumber" - }, - { - "$ref": "#/definitions/ConfusedHexType" - } - ] - }, - "IntegerOrEmptyOrHexQuantity": { - "oneOf": [ - { - "$ref": "#/definitions/IntegerOrEmpty" - }, - { - "$ref": "#/definitions/HexQuantity" - } - ] - }, - "IntegerOrHexQuantity": { - "oneOf": [ - { - "$ref": "#/definitions/IntegerString" - }, - { - "$ref": "#/definitions/HexQuantity" - } - ] - }, - "IntegerOrConfusedHex": { - "anyOf": [ - { - "$ref": "#/definitions/IntegerString" - }, - { - "$ref": "#/definitions/ConfusedHexType" - } - ] - }, - "IntegerOrEmptyOrConfusedHex": { - "oneOf": [ - { - "$ref": "#/definitions/IntegerOrEmpty" - }, - { - "$ref": "#/definitions/ConfusedHexType" - } - ] - }, "PreStateAccount": { "type": "object", "additionalproperties": true, @@ -297,27 +165,6 @@ } ] }, - "HexLen40": { - "pattern": "^0x[0-9a-fA-F]{40}$", - "type": "string" - }, - "HexNoPrefixLen40": { - "pattern": "^[0-9a-fA-F]{40}$", - "type": "string" - }, - "AddressMaybePrefixOrEmpty": { - "oneOf": [ - { - "$ref": "#/definitions/HexLen40" - }, - { - "$ref": "#/definitions/HexNoPrefixLen40" - }, - { - "$ref": "#/definitions/EmptyString" - } - ] - }, "Transaction": { "type": "object", "additionalProperties": true, @@ -415,43 +262,6 @@ "to", "value" ] - }, - "TransactionResults": { - "items": { - "additionalProperties": false, - "properties": { - "hash": { - "$ref": "#/definitions/HexData" - }, - "logs": {}, - "indexes": { - "additionalProperties": false, - "properties": { - "data": { - "type": "integer" - }, - "gas": { - "type": "integer" - }, - "value": { - "type": "integer" - } - }, - "required": [ - "data", - "gas", - "value" - ], - "type": "object" - } - }, - "required": [ - "hash", - "indexes" - ], - "type": "object" - }, - "type": "array" } }, "patternProperties": { diff --git a/JSONSchema/definitions.json b/JSONSchema/definitions.json new file mode 100644 index 000000000..9c9ca3d44 --- /dev/null +++ b/JSONSchema/definitions.json @@ -0,0 +1,200 @@ +{ + "definitions": { + "AddressMaybePrefixOrEmpty": { + "oneOf": [ + { + "$ref": "#/definitions/HexLen40" + }, + { + "$ref": "#/definitions/HexNoPrefixLen40" + }, + { + "$ref": "#/definitions/EmptyString" + } + ] + }, + "ConfusedHexType": { + "anyOf": [ + { + "$ref": "#/definitions/HexData" + }, + { + "$ref": "#/definitions/HexQuantity" + } + ] + }, + "EmptyString": { + "pattern": "^$", + "type": "string" + }, + "HexData": { + "description": "Hex data. see https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding", + "pattern": "^0x([0-9a-fA-F][0-9a-fA-F])*$", + "type": "string" + }, + "HexDataOrEmpty": { + "oneOf": [ + { + "$ref": "#/definitions/HexData" + }, + { + "$ref": "#/definitions/EmptyString" + } + ] + }, + "HexLen40": { + "pattern": "^0x[0-9a-fA-F]{40}$", + "type": "string" + }, + "HexMaybePrefix": { + "oneOf": [ + { + "$ref": "#/definitions/HexNoPrefix" + }, + { + "$ref": "#/definitions/HexData" + } + ] + }, + "HexMaybePrefixOrEmpty": { + "oneOf": [ + { + "$ref": "#/definitions/HexMaybePrefix" + }, + { + "$ref": "#/definitions/EmptyString" + } + ] + }, + "HexNoPrefix": { + "pattern": "^([0-9a-fA-F][0-9a-fA-F])+$", + "type": "string" + }, + "HexNoPrefixLen40": { + "pattern": "^[0-9a-fA-F]{40}$", + "type": "string" + }, + "HexQuantity": { + "description": "Hex quantity. see https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding", + "pattern": "(^0x0$)|(^0x[1-9a-fA-F][0-9a-fA-F]*$)", + "type": "string" + }, + "IntegerOrConfusedHex": { + "anyOf": [ + { + "$ref": "#/definitions/IntegerString" + }, + { + "$ref": "#/definitions/ConfusedHexType" + } + ] + }, + "IntegerOrEmpty": { + "oneOf": [ + { + "$ref": "#/definitions/IntegerString" + }, + { + "$ref": "#/definitions/EmptyString" + } + ] + }, + "IntegerOrEmptyOrConfusedHex": { + "oneOf": [ + { + "$ref": "#/definitions/IntegerOrEmpty" + }, + { + "$ref": "#/definitions/ConfusedHexType" + } + ] + }, + "IntegerOrEmptyOrHexQuantity": { + "oneOf": [ + { + "$ref": "#/definitions/IntegerOrEmpty" + }, + { + "$ref": "#/definitions/HexQuantity" + } + ] + }, + "IntegerOrHexQuantity": { + "oneOf": [ + { + "$ref": "#/definitions/IntegerString" + }, + { + "$ref": "#/definitions/HexQuantity" + } + ] + }, + "TransactionResults": { + "items": { + "additionalProperties": false, + "properties": { + "hash": { + "$ref": "#/definitions/HexData" + }, + "logs": {}, + "indexes": { + "additionalProperties": false, + "properties": { + "data": { + "type": "integer" + }, + "gas": { + "type": "integer" + }, + "value": { + "type": "integer" + } + }, + "required": [ + "data", + "gas", + "value" + ], + "type": "object" + } + }, + "required": [ + "hash", + "indexes" + ], + "type": "object" + }, + "type": "array" + }, + "PrefixedHexOrInteger": { + "anyOf": [ + { "$ref": "#/definitions/IntegerString" }, + { "$ref": "#/definitions/HexData" } + ] + }, + "IntegerOrNumber": { + "oneOf": [ + { + "$ref": "#/definitions/IntegerString" + }, + { + "type": "number" + } + ] + }, + "IntegerOrNumberOrConfusedHex": { + "oneOf": [ + { + "$ref": "#/definitions/IntegerOrNumber" + }, + { + "$ref": "#/definitions/ConfusedHexType" + } + ] + }, + "IntegerString": { + "pattern": "^[0-9]+$", + "type": "string" + } + } +} diff --git a/JSONSchema/st-filler-schema.json b/JSONSchema/st-filler-schema.json index d110e0493..aeb828912 100644 --- a/JSONSchema/st-filler-schema.json +++ b/JSONSchema/st-filler-schema.json @@ -1,25 +1,5 @@ { "definitions": { - "EmptyString": { - "type": "string", - "pattern": "^$" - }, - "HexData": { - "description": "Hex data. see https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding", - "pattern": "^0x([0-9a-fA-F][0-9a-fA-F])*$", - "type": "string" - }, - "HexQuantity": { - "description": "Hex quantity. see https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding", - "pattern": "(^0x0$)|(^0x[1-9a-fA-F][0-9a-fA-F]*$)", - "type": "string" - }, - "ConfusedHexType": { - "anyOf": [ - { "$ref": "#/definitions/HexData" }, - { "$ref": "#/definitions/HexQuantity" } - ] - }, "TxData": { "oneOf": [ { "$ref": "#/definitions/HexData" }, @@ -31,74 +11,6 @@ "type" : "string", "pattern" : "^{.*}$" }, - "HexNoPrefix" : { - "pattern": "^([0-9a-fA-F][0-9a-fA-F])+$", - "type": "string" - }, - "HexMaybePrefix": { - "oneOf": [ - { "$ref": "#/definitions/HexNoPrefix" }, - { "$ref": "#/definitions/HexData" } - ] - }, - "HexMaybePrefixOrEmpty": { - "oneOf": [ - { "$ref": "#/definitions/HexMaybePrefix" }, - { "$ref": "#/definitions/EmptyString" } - ] - }, - "IntegerString": { - "pattern": "^[0-9]+$", - "type": "string" - }, - "IntegerOrEmpty": { - "oneOf": [ - { "$ref": "#/definitions/IntegerString" }, - { "$ref": "#/definitions/EmptyString" } - ] - }, - "IntegerOrNumber": { - "oneOf": [ - { "$ref": "#/definitions/IntegerString" }, - { "type": "number" } - ] - }, - "IntegerOrNumberOrConfusedHex": { - "oneOf": [ - { "$ref": "#/definitions/IntegerOrNumber" }, - { "$ref": "#/definitions/ConfusedHexType" } - ] - }, - "IntegerOrEmptyOrHexQuantity": { - "oneOf": [ - { "$ref": "#/definitions/IntegerOrEmpty" }, - { "$ref": "#/definitions/HexQuantity" } - ] - }, - "IntegerOrHexQuantity": { - "oneOf": [ - { "$ref": "#/definitions/IntegerString" }, - { "$ref": "#/definitions/HexQuantity" } - ] - }, - "IntegerOrConfusedHex": { - "anyOf": [ - { "$ref": "#/definitions/IntegerString" }, - { "$ref": "#/definitions/ConfusedHexType" } - ] - }, - "IntegerOrEmptyOrConfusedHex": { - "oneOf": [ - { "$ref": "#/definitions/IntegerOrEmpty" }, - { "$ref": "#/definitions/ConfusedHexType" } - ] - }, - "PrefixedHexOrInteger": { - "anyOf": [ - { "$ref": "#/definitions/IntegerString" }, - { "$ref": "#/definitions/HexData" } - ] - }, "PreStateAccount": { "type": "object", "additionalproperties": true, @@ -147,21 +59,6 @@ { "enum" : [ "0", "1" ] } ] }, - "HexLen40": { - "pattern": "^0x[0-9a-fA-F]{40}$", - "type": "string" - }, - "HexNoPrefixLen40": { - "pattern": "^[0-9a-fA-F]{40}$", - "type": "string" - }, - "AddressMaybePrefixOrEmpty" : { - "oneOf": [ - { "$ref": "#/definitions/HexLen40" }, - { "$ref": "#/definitions/HexNoPrefixLen40" }, - { "$ref": "#/definitions/EmptyString" } - ] - }, "Transaction": { "type": "object", "additionalProperties": true, diff --git a/JSONSchema/st-schema.json b/JSONSchema/st-schema.json index 7b1536dae..44411ae71 100644 --- a/JSONSchema/st-schema.json +++ b/JSONSchema/st-schema.json @@ -1,93 +1,5 @@ { "definitions": { - "EmptyString": { - "type": "string", - "pattern": "^$" - }, - "HexData": { - "description": "Hex data. see https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding", - "pattern": "^0x([0-9a-fA-F][0-9a-fA-F])*$", - "type": "string" - }, - "HexQuantity": { - "description": "Hex quantity. see https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding", - "pattern": "(^0x0$)|(^0x[1-9a-fA-F][0-9a-fA-F]*$)", - "type": "string" - }, - "ConfusedHexType": { - "anyOf": [ - { "$ref": "#/definitions/HexData" }, - { "$ref": "#/definitions/HexQuantity" } - ] - }, - "HexDataOrEmpty": { - "oneOf": [ - { "$ref": "#/definitions/HexData" }, - { "$ref": "#/definitions/EmptyString" } - ] - }, - "HexNoPrefix" : { - "pattern": "^([0-9a-fA-F][0-9a-fA-F])+$", - "type": "string" - }, - "HexMaybePrefix": { - "oneOf": [ - { "$ref": "#/definitions/HexNoPrefix" }, - { "$ref": "#/definitions/HexData" } - ] - }, - "HexMaybePrefixOrEmpty": { - "oneOf": [ - { "$ref": "#/definitions/HexMaybePrefix" }, - { "$ref": "#/definitions/EmptyString" } - ] - }, - "IntegerString": { - "pattern": "^[0-9]+$", - "type": "string" - }, - "IntegerOrEmpty": { - "oneOf": [ - { "$ref": "#/definitions/IntegerString" }, - { "$ref": "#/definitions/EmptyString" } - ] - }, - "IntegerOrNumber": { - "oneOf": [ - { "$ref": "#/definitions/IntegerString" }, - { "type": "number" } - ] - }, - "IntegerOrNumberOrConfusedHex": { - "oneOf": [ - { "$ref": "#/definitions/IntegerOrNumber" }, - { "$ref": "#/definitions/ConfusedHexType" } - ] - }, - "IntegerOrEmptyOrHexQuantity": { - "oneOf": [ - { "$ref": "#/definitions/IntegerOrEmpty" }, - { "$ref": "#/definitions/HexQuantity" } - ] - }, - "IntegerOrHexQuantity": { - "oneOf": [ - { "$ref": "#/definitions/IntegerString" }, - { "$ref": "#/definitions/HexQuantity" } - ] - }, - "IntegerOrConfusedHex": { - "anyOf": [ - { "$ref": "#/definitions/IntegerString" }, - { "$ref": "#/definitions/ConfusedHexType" } - ] - }, - "IntegerOrEmptyOrConfusedHex": { - "oneOf": [ - { "$ref": "#/definitions/IntegerOrEmpty" }, - { "$ref": "#/definitions/ConfusedHexType" } - ] - }, "PreStateAccount": { "type": "object", "additionalproperties": true, @@ -128,21 +40,6 @@ { "enum" : [ "0x00", "0x01" ] } ] }, - "HexLen40": { - "pattern": "^0x[0-9a-fA-F]{40}$", - "type": "string" - }, - "HexNoPrefixLen40": { - "pattern": "^[0-9a-fA-F]{40}$", - "type": "string" - }, - "AddressMaybePrefixOrEmpty" : { - "oneOf": [ - { "$ref": "#/definitions/HexLen40" }, - { "$ref": "#/definitions/HexNoPrefixLen40" }, - { "$ref": "#/definitions/EmptyString" } - ] - }, "Transaction": { "type": "object", "additionalProperties": true, @@ -214,43 +111,6 @@ "to", "value" ] - }, - "TransactionResults": { - "items": { - "additionalProperties": false, - "properties": { - "hash": { - "$ref": "#/definitions/HexData" - }, - "logs": {}, - "indexes": { - "additionalProperties": false, - "properties": { - "data": { - "type": "integer" - }, - "gas": { - "type": "integer" - }, - "value": { - "type": "integer" - } - }, - "required": [ - "data", - "gas", - "value" - ], - "type": "object" - } - }, - "required": [ - "hash", - "indexes" - ], - "type": "object" - }, - "type": "array" } }, "patternProperties": { @@ -65,9 +65,15 @@ def findTests(testDir="."): def validateSchema(jsonFile, schemaFile): _report("validating", jsonFile, "with", schemaFile) + testSchema = readJSONFile(schemaFile) - jsonInput = readJSONFile(jsonFile) - jsonschema.validate(jsonInput, testSchema) + defSchema = readJSONFile("JSONSchema/definitions.json") + schema = { "definitions" : dict(defSchema["definitions"], **testSchema["definitions"]) + , "patternProperties" : testSchema["patternProperties"] + } + + jsonInput = readJSONFile(jsonFile) + jsonschema.validate(jsonInput, schema) def validateTestFile(jsonFile): if jsonFile.startswith("src/GeneralStateTestsFiller/"): |