aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Wasinger <j-wasinger@hotmail.com>2017-07-04 15:34:57 +0800
committerUbuntu <ubuntu@ip-172-31-32-43.us-west-2.compute.internal>2017-08-08 04:41:46 +0800
commit2209036fb9ddf776b67b29e337e77175caf407bd (patch)
tree86eb36283b8f2685962f21b5de3c1c81c535e2af
parente0c62ccd02a72032c412882e85a0db72fa496946 (diff)
downloaddexon-tests-2209036fb9ddf776b67b29e337e77175caf407bd.tar.gz
dexon-tests-2209036fb9ddf776b67b29e337e77175caf407bd.tar.zst
dexon-tests-2209036fb9ddf776b67b29e337e77175caf407bd.zip
add working schema outline
-rwxr-xr-xGeneralStateTests/schema/run.sh1
-rw-r--r--GeneralStateTests/schema/schema.json189
-rwxr-xr-xGeneralStateTests/schema/validate.js66
3 files changed, 194 insertions, 62 deletions
diff --git a/GeneralStateTests/schema/run.sh b/GeneralStateTests/schema/run.sh
new file mode 100755
index 000000000..a2a0f2db8
--- /dev/null
+++ b/GeneralStateTests/schema/run.sh
@@ -0,0 +1 @@
+echo -e "$(find .. -name '*.json')" | node validate.js
diff --git a/GeneralStateTests/schema/schema.json b/GeneralStateTests/schema/schema.json
index f56ee61ca..178b80b9b 100644
--- a/GeneralStateTests/schema/schema.json
+++ b/GeneralStateTests/schema/schema.json
@@ -1,71 +1,136 @@
{
"type": "object",
- "additionalProperties": {
- "env": {
+ "patternProperties": {
+ "^.*$": {
"type": "object",
- "additionalProperties": {
- "currentCoinbase": {
- "type": "string"
+ "properties": {
+ "post": {
+ "type": "object",
+ "properties": {
+ "EIP150": {
+ "type": "array"
+ },
+ "EIP158": {
+ "type": "array"
+ },
+ "Frontier": {
+ "type": "array"
+ },
+ "Homestead": {
+ "type": "array"
+ },
+ "Metropolis": {
+ "type": "array"
+ }
+ },
+ "additionalProperties": false
},
- "currentDifficulty": {
- "type": "string"
+ "env": {
+ "type": "object",
+ "properties": {
+ "currentCoinbase": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ },
+ "currentDifficulty": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ },
+ "currentGasLimit": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ },
+ "currentNumber": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ },
+ "currentTimestamp": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ },
+ "previousHash": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ }
+ },
+ "additionalProperties": false
},
- "currentGasLimit": {
- "type": "string"
- },
- "currentNumber": {
- "type": "string"
- },
- "currentTimestamp": {
- "type": "string"
- },
- "previousHash": {
- "type": "string"
- }
- }
- },
- "post": {
- "type": "object",
- "additionalProperties": {
- "EIP150": {
- "type": "array"
- },
- "EIP158": {
- "type": "array"
- },
- "Frontier": {
- "type": "array"
+ "pre": {
+ "type": "object",
+ "patternProperties": {
+ "^0x[0-9a-f]*": {
+ "type": "object",
+ "properties": {
+ "balance": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ },
+ "code": {
+ "type": "string",
+ "pattern": "^(0x[0-9a-f]*)?$"
+ },
+ "nonce": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+
+ },
+ "storage": {
+ "type": "object"
+ }
+ },
+ "additionalProperties": false
+ },
+ "additionalProperties": false
+ },
+ "additionalProperties": false
},
- "Homestead": {
- "type": "array"
+ "transaction": {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "pattern": "^(0x[0-9a-f]*)?$"
+ }
+ },
+ "gasLimit": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ }
+ },
+ "gasPrice": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ },
+ "nonce": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ },
+ "secretKey": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ },
+ "to": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ },
+ "value": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ }
+ }
+ },
+ "additionalProperties": false
}
- }
- },
- "pre": {
-
- },
- "transaction": {
- "data": {
- "type": "array"
- },
- "gasLimit": {
- "type": "array"
- },
- "gasPrice": {
- "type": "string"
},
- "nonce": {
- "type": "string"
- },
- "secretKey": {
- "type": "string"
- },
- "to": {
- "type": "string"
- },
- "value": {
- "type": "array"
- }
- }
- }
+ "additionalProperties": false
+ },
+ "additionalProperties": false
+ },
+ "additionalProperties": false
}
diff --git a/GeneralStateTests/schema/validate.js b/GeneralStateTests/schema/validate.js
new file mode 100755
index 000000000..6f2feef9b
--- /dev/null
+++ b/GeneralStateTests/schema/validate.js
@@ -0,0 +1,66 @@
+#! /bin/env node
+
+var validate = require('jsonschema').validate;
+var fs = require('fs');
+
+var readline = require('readline');
+var schema = '';
+var testCode = '';
+
+var readline = require('readline');
+var rl = readline.createInterface({
+ input: process.stdin,
+ output: process.stdout,
+ terminal: false
+});
+
+rl.on('line', function(line){
+ fs.readFile('simple-schema.json', function(err, data) {
+ if (err) {
+ throw err;
+ }
+
+
+ schema = JSON.parse(data);
+
+
+ fs.readFile(line, function(err, data) {
+ if (err) {
+ throw err;
+ }
+
+ try {
+ testCode = JSON.parse(data);
+ } catch(e) {
+ debugger;
+ }
+
+ try {
+ var x = validate(testCode, schema);
+ } catch(e) {
+ console.log(line);
+ }
+
+ });
+ });
+});
+
+/*
+fs.readFile('simple-schema.json', function(err, data) {
+ if (err) {
+ throw err;
+ }
+
+ schema = JSON.parse(data);
+ fs.readFile('example.json', function(err, data) {
+ if (err) {
+ throw err;
+ }
+
+ testCode = JSON.parse(data);
+ var x = validate(testCode, schema);
+ console.log(x);
+ debugger;
+ });
+});
+*/