Skip to content

Commit

Permalink
fix blockchain tests expect section json scheme check
Browse files Browse the repository at this point in the history
more info when scheme check errors
  • Loading branch information
winsvega committed Nov 19, 2018
1 parent 03f578c commit e091b9b
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 26 deletions.
24 changes: 19 additions & 5 deletions JSONSchema/bc-filler-schema.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
Expand Down
39 changes: 39 additions & 0 deletions JSONSchema/definitions.json
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand Down
14 changes: 0 additions & 14 deletions JSONSchema/st-filler-schema.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
},
"1000000000000000000000000000000000000007" : {
"storage" : {
"0x" : "10000000000"
"0x00" : "10000000000"
}
},
"1000000000000000000000000000000000000008" : {
"storage" : {
"0x" : "0"
"0x00" : "0"
}
},
"bf4ed7b27f1d666546e30d74d50d173d20bca754" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
},
"1000000000000000000000000000000000000007" : {
"storage" : {
"0x" : "10000000000"
"0x00" : "10000000000"
}
},
"1000000000000000000000000000000000000008" : {
"storage" : {
"0x" : "0"
"0x00" : "0"
}
},
"bf4ed7b27f1d666546e30d74d50d173d20bca754" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
},
"1000000000000000000000000000000000000007" : {
"storage" : {
"0x" : "10000000000"
"0x00" : "10000000000"
}
},
"1000000000000000000000000000000000000008" : {
"storage" : {
"0x" : "0"
"0x00" : "0"
}
},
"bf4ed7b27f1d666546e30d74d50d173d20bca754" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"0x06" : "0x01",
"0x07" : "0x01",
"0x08" : "0x01",
"0x09" : "0x4176a",
"0x09" : "0x04176a",
"0x0a" : "0x057ee9",
"0x0b" : "0x5dddfce53ee040d9eb21afbc0ae1bb4dbb0ba643",
"0x64" : "0x11"
Expand Down
5 changes: 5 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"):
Expand Down

0 comments on commit e091b9b

Please sign in to comment.