aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml3
-rwxr-xr-xJSONSchema/run.sh1
-rw-r--r--JSONSchema/schema.json28
-rwxr-xr-xJSONSchema/validate.py30
4 files changed, 42 insertions, 20 deletions
diff --git a/.travis.yml b/.travis.yml
index dbced1cd9..24267e38a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,11 @@
language: python
python: 2.7
sudo: false
+install: "pip install jsonschema"
script:
# won't fail, but print problems
- find . -name "*.json" -not -name "*Filler.json" -exec echo {} \; -exec python -mjson.tool {} /dev/null \; 2>&1 | grep -v -B 1 "^\./" | cat
# will fail, if linting fails
- find . -name "*.json" -not -name "*Filler.json" -print0 | xargs -I file -n1 -0 python -mjson.tool file /dev/null
+# run schema tests against GeneralStateTests
+- echo "$(find GeneralStateTests -name '*.json' ! -path '../schema/*.json')" | python JSONSchema/validate.py
diff --git a/JSONSchema/run.sh b/JSONSchema/run.sh
deleted file mode 100755
index 0624037bb..000000000
--- a/JSONSchema/run.sh
+++ /dev/null
@@ -1 +0,0 @@
-echo -e "$(find ../GeneralStateTests -name '*.json' ! -path '../schema/*.json')" | node validate.js
diff --git a/JSONSchema/schema.json b/JSONSchema/schema.json
index 1ca91c03d..5ac5e7a71 100644
--- a/JSONSchema/schema.json
+++ b/JSONSchema/schema.json
@@ -22,9 +22,7 @@
"Metropolis": {
"type": "array"
}
- },
- "additionalProperties": false
- },
+ } },
"explanation": {
"type": "string"
},
@@ -55,8 +53,7 @@
"type": "string",
"pattern": "^0x[0-9a-f]*$"
}
- },
- "additionalProperties": false
+ }
},
"pre": {
"type": "object",
@@ -80,12 +77,9 @@
"storage": {
"type": "object"
}
- },
- "additionalProperties": false
- },
- "additionalProperties": false
- },
- "additionalProperties": false
+ }
+ }
+ }
},
"transaction": {
"type": "object",
@@ -127,13 +121,9 @@
"pattern": "^0x[0-9a-f]*$"
}
}
- },
- "additionalProperties": false
+ }
}
- },
- "additionalProperties": false
- },
- "additionalProperties": false
- },
- "additionalProperties": false
+ }
+ }
+ }
}
diff --git a/JSONSchema/validate.py b/JSONSchema/validate.py
new file mode 100755
index 000000000..086abfa93
--- /dev/null
+++ b/JSONSchema/validate.py
@@ -0,0 +1,30 @@
+#! /bin/env python
+
+import glob, json, sys, jsonschema
+
+with open('JSONSchema/schema.json') as schema_data:
+ schema = json.load(schema_data)
+
+#for filename in glob.glob('GeneralStateTests/*.json'):
+# print(filename)
+
+while True:
+ line = sys.stdin.readline()
+ if not line:
+ if success:
+ sys.exit(0)
+ else:
+ sys.exit(-1)
+
+ line = line.strip('\n')
+ with open(line) as test_data:
+ test = json.load(test_data)
+
+ try:
+ jsonschema.validate(test, schema)
+ except jsonschema.exceptions.ValidationError as e:
+ success = False
+ print(line+':\n\n')
+ print(e)
+ print('\n')
+