From e091b9be7a31d1985e685991c05ea3f9b548bddc Mon Sep 17 00:00:00 2001 From: Dimitry Date: Mon, 19 Nov 2018 21:28:33 +0300 Subject: fix blockchain tests expect section json scheme check more info when scheme check errors --- JSONSchema/bc-filler-schema.json | 24 ++++++++++--- JSONSchema/definitions.json | 39 ++++++++++++++++++++++ JSONSchema/st-filler-schema.json | 14 -------- .../bcHomesteadToDao/DaoTransactionsFiller.json | 4 +-- ...s_EmptyTransactionAndForkBlocksAheadFiller.json | 4 +-- .../DaoTransactions_UncleExtradataFiller.json | 4 +-- .../EIP150TransitionFiller.json | 2 +- test.py | 5 +++ 8 files changed, 70 insertions(+), 26 deletions(-) diff --git a/JSONSchema/bc-filler-schema.json b/JSONSchema/bc-filler-schema.json index b002f43ae..a6874095a 100644 --- a/JSONSchema/bc-filler-schema.json +++ b/JSONSchema/bc-filler-schema.json @@ -1,5 +1,17 @@ { "definitions": { + "BlockchainExpectSection": { + "additionalProperties": false, + "properties": { + "network": { + "$ref": "#/definitions/Networks" + }, + "result": { + "$ref": "#/definitions/AccountMap" + } + }, + "type": "array" + }, "BadHexData": { "pattern": "^0x[0-9a-zA-Z]*$", "type": "string" @@ -317,12 +329,14 @@ "type": "string" }, "expect": { - "patternProperties": { - "^0x[0-9a-f]*": { - "$ref": "#/definitions/PreStateAccount", - "description": "poststate account address with 0x prefix" + "oneOf": [ + { + "$ref": "#/definitions/AccountMap" + }, + { + "$ref": "#/definitions/BlockchainExpectSection" } - } + ] }, "genesisBlockHeader": { "$ref": "#/definitions/BlockHeader" diff --git a/JSONSchema/definitions.json b/JSONSchema/definitions.json index 529e08763..1d5a9ad69 100644 --- a/JSONSchema/definitions.json +++ b/JSONSchema/definitions.json @@ -1,5 +1,44 @@ { "definitions": { + "AccountMap": { + "additionalProperties": false, + "patternProperties": { + "^0x[0-9a-fA-F]{40}": { + "$ref": "#/definitions/ExpectAccount", + "description": "filler prestate addresses with 0x prefix" + }, + "^[0-9a-fA-F]{40}": { + "$ref": "#/definitions/ExpectAccount", + "description": "filler prestate addresses without 0x prefix" + } + }, + "type": "object" + }, + "ExpectAccount": { + "additionalproperties": true, + "properties": { + "balance": { + "$ref": "#/definitions/IntegerOrEmptyOrConfusedHex" + }, + "code": { + "type": "string" + }, + "nonce": { + "$ref": "#/definitions/IntegerOrEmptyOrConfusedHex" + }, + "storage": { + "additionalProperties": false, + "patternProperties": { + "^0x[0-9a-f]+": { + "$ref": "#/definitions/PrefixedHexOrInteger", + "description": "storage key with 0x prefix, just the prefix `0x` is null and thus not permitted, a hex quantity is permitted. for the storage value, only hex data is permitted in filled test. Both decimal and hex allowed for the fillers." + } + }, + "type": "object" + } + }, + "type": "object" + }, "AddressMaybePrefixOrEmpty": { "oneOf": [ { diff --git a/JSONSchema/st-filler-schema.json b/JSONSchema/st-filler-schema.json index ed0e14e58..c533ad819 100644 --- a/JSONSchema/st-filler-schema.json +++ b/JSONSchema/st-filler-schema.json @@ -1,19 +1,5 @@ { "definitions": { - "AccountMap": { - "additionalProperties": false, - "patternProperties": { - "^0x[0-9a-fA-F]{40}": { - "$ref": "#/definitions/PreStateAccount", - "description": "filler prestate addresses with 0x prefix" - }, - "^[0-9a-fA-F]{40}": { - "$ref": "#/definitions/PreStateAccount", - "description": "filler prestate addresses without 0x prefix" - } - }, - "type": "object" - }, "NullSenderTransaction": { "properties": { "data": { diff --git a/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToDao/DaoTransactionsFiller.json b/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToDao/DaoTransactionsFiller.json index b8b1991ce..c6f367efd 100644 --- a/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToDao/DaoTransactionsFiller.json +++ b/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToDao/DaoTransactionsFiller.json @@ -27,12 +27,12 @@ }, "1000000000000000000000000000000000000007" : { "storage" : { - "0x" : "10000000000" + "0x00" : "10000000000" } }, "1000000000000000000000000000000000000008" : { "storage" : { - "0x" : "0" + "0x00" : "0" } }, "bf4ed7b27f1d666546e30d74d50d173d20bca754" : { diff --git a/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToDao/DaoTransactions_EmptyTransactionAndForkBlocksAheadFiller.json b/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToDao/DaoTransactions_EmptyTransactionAndForkBlocksAheadFiller.json index 41e5fe3d5..0c7f0f11c 100644 --- a/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToDao/DaoTransactions_EmptyTransactionAndForkBlocksAheadFiller.json +++ b/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToDao/DaoTransactions_EmptyTransactionAndForkBlocksAheadFiller.json @@ -27,12 +27,12 @@ }, "1000000000000000000000000000000000000007" : { "storage" : { - "0x" : "10000000000" + "0x00" : "10000000000" } }, "1000000000000000000000000000000000000008" : { "storage" : { - "0x" : "0" + "0x00" : "0" } }, "bf4ed7b27f1d666546e30d74d50d173d20bca754" : { diff --git a/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToDao/DaoTransactions_UncleExtradataFiller.json b/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToDao/DaoTransactions_UncleExtradataFiller.json index 243abacc5..9df99033e 100644 --- a/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToDao/DaoTransactions_UncleExtradataFiller.json +++ b/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToDao/DaoTransactions_UncleExtradataFiller.json @@ -33,12 +33,12 @@ }, "1000000000000000000000000000000000000007" : { "storage" : { - "0x" : "10000000000" + "0x00" : "10000000000" } }, "1000000000000000000000000000000000000008" : { "storage" : { - "0x" : "0" + "0x00" : "0" } }, "bf4ed7b27f1d666546e30d74d50d173d20bca754" : { diff --git a/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToEIP150/EIP150TransitionFiller.json b/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToEIP150/EIP150TransitionFiller.json index b9b16be37..10a10ca52 100644 --- a/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToEIP150/EIP150TransitionFiller.json +++ b/src/BlockchainTestsFiller/TransitionTests/bcHomesteadToEIP150/EIP150TransitionFiller.json @@ -30,7 +30,7 @@ "0x06" : "0x01", "0x07" : "0x01", "0x08" : "0x01", - "0x09" : "0x4176a", + "0x09" : "0x04176a", "0x0a" : "0x057ee9", "0x0b" : "0x5dddfce53ee040d9eb21afbc0ae1bb4dbb0ba643", "0x64" : "0x11" diff --git a/test.py b/test.py index 0189859ad..e0a3bc24c 100755 --- a/test.py +++ b/test.py @@ -108,7 +108,12 @@ def validateSchema(testFile, schemaFile): try: jsonschema.validate(testInput, schema) except: + from jsonschema import Draft4Validator _logerror("Validation failed:", "schema", schemaFile, "on", testFile) + v = Draft4Validator(schema) + errors = sorted(v.iter_errors(testInput), key=lambda e: e.path) + for error in errors: + _logerror(error.message) def validateTestFile(testFile): if testFile.startswith("./src/VMTestsFiller/"): -- cgit