aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml10
-rw-r--r--JSONSchema/bc-schema.json491
-rw-r--r--JSONSchema/st-filler-schema.json (renamed from JSONSchema/filler-schema.json)0
-rw-r--r--JSONSchema/st-schema.json (renamed from JSONSchema/schema.json)0
-rwxr-xr-xJSONSchema/validate.js10
5 files changed, 507 insertions, 4 deletions
diff --git a/.travis.yml b/.travis.yml
index d9d7c58fb..e223fbc3c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,6 +10,12 @@ script:
- 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 -e "$(find GeneralStateTests -name '*.json')" | node JSONSchema/validate.js JSONSchema/schema.json
-- echo -e "$(find src/GeneralStateTestsFiller -name '*.json')" | node JSONSchema/validate.js JSONSchema/filler-schema.json \ No newline at end of file
+- echo "Linting state tests"
+- echo -e "$(find GeneralStateTests -name '*.json')" | node JSONSchema/validate.js JSONSchema/st-schema.json
+- echo -e "$(find src/GeneralStateTestsFiller -name '*.json')" | node JSONSchema/validate.js JSONSchema/st-filler-schema.json
+
+# run schema tests against BlockchainTests
+- echo "Linting blockchain tests"
+- echo -e "$(find BlockchainTests -name '*.json')" | node JSONSchema/validate.js JSONSchema/bc-schema.json
diff --git a/JSONSchema/bc-schema.json b/JSONSchema/bc-schema.json
new file mode 100644
index 000000000..26ef855e1
--- /dev/null
+++ b/JSONSchema/bc-schema.json
@@ -0,0 +1,491 @@
+{
+ "definitions": {
+ "Block": {
+ "type": "object",
+ "properties": {
+ "blockHeader": {
+ "$ref": "#/definitions/BlockHeader"
+ },
+ "rlp": {
+ "$ref": "#/definitions/HexData"
+ },
+ "transactions": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Transaction"
+ }
+ },
+ "uncleHeaders": {
+ "type": "array"
+ },
+ "expectExceptionHomestead": {
+ "type": "string"
+ },
+ "expectExceptionFrontier": {
+ "type": "string"
+ },
+ "expectExceptionEIP158": {
+ "type": "string"
+ },
+ "expectExceptionEIP150": {
+ "type": "string"
+ },
+ "expectExceptionALL": {
+ "type": "string"
+ },
+ "expectExceptionByzantium": {
+ "type": "string"
+ },
+ "expectExceptionConstantinople": {
+ "type": "string"
+ },
+ "blocknumber": {
+ "$ref": "#/definitions/IntegerOrEmptyOrConfusedHex"
+ },
+ "chainname": {
+ "type": "string"
+ },
+ "chainnetwork": {
+ "type": "string"
+ },
+ "comment": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ },
+ "BlockHeader": {
+ "properties": {
+ "bloom": {
+ "$ref": "#/definitions/HexData"
+ },
+ "coinbase": {
+ "$ref": "#/definitions/AddressMaybePrefixOrEmpty"
+ },
+ "difficulty": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "extraData": {
+ "$ref": "#/definitions/HexMaybePrefixOrEmpty"
+ },
+ "gasLimit": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "gasUsed": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "hash": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "mixHash": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "nonce": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "number": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "parentHash": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "receiptTrie": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "stateRoot": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "timestamp": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "transactionsTrie": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "uncleHash": {
+ "$ref": "#/definitions/ConfusedHexType"
+ }
+ }
+ },
+ "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,
+ "properties": {
+ "balance": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "code": {
+ "$ref": "#/definitions/HexMaybePrefixOrEmpty"
+ },
+ "nonce": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "storage": {
+ "type": "object",
+ "additionalProperties": false,
+ "patternProperties": {
+ "^0x[0-9a-f]+": {
+ "description": "storage key with 0x. data is HexData",
+ "$ref": "#/definitions/HexData"
+ }
+ }
+ }
+ },
+ "required": [
+ "balance",
+ "code",
+ "nonce"
+ ]
+ },
+ "TxSigR": {
+ "oneOf": [
+ {
+ "enum": [
+ "0x00"
+ ]
+ }
+ ]
+ },
+ "TxSigS": {
+ "oneOf": [
+ {
+ "enum": [
+ "0x00"
+ ]
+ }
+ ]
+ },
+ "TxSigV": {
+ "description": "a value of 0 is an invalid chainId, but used in a test case",
+ "oneOf": [
+ {
+ "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,
+ "not": {
+ "required": [
+ "r, s, v"
+ ]
+ },
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/HexDataOrEmpty"
+ },
+ "gasLimit": {
+ "$ref": "#/definitions/IntegerOrEmptyOrConfusedHex"
+ },
+ "gasPrice": {
+ "$ref": "#/definitions/IntegerOrEmptyOrConfusedHex"
+ },
+ "nonce": {
+ "$ref": "#/definitions/IntegerOrEmptyOrConfusedHex"
+ },
+ "secretKey": {
+ "$ref": "#/definitions/HexMaybePrefix"
+ },
+ "to": {
+ "$ref": "#/definitions/AddressMaybePrefixOrEmpty"
+ },
+ "value": {
+ "$ref": "#/definitions/IntegerOrEmptyOrConfusedHex"
+ }
+ },
+ "required": [
+ "data",
+ "gasLimit",
+ "gasPrice",
+ "nonce",
+ "to",
+ "value"
+ ]
+ },
+ "NullSenderTransaction": {
+ "type": "object",
+ "additionalProperties": true,
+ "not": {
+ "required": [
+ "secretKey"
+ ]
+ },
+ "properties": {
+ "data": {
+ "items": {
+ "$ref": "#/definitions/HexMaybePrefixOrEmpty"
+ },
+ "type": "array"
+ },
+ "gasLimit": {
+ "items": {
+ "$ref": "#/definitions/IntegerOrEmptyOrConfusedHex"
+ },
+ "type": "array"
+ },
+ "gasPrice": {
+ "$ref": "#/definitions/IntegerOrEmptyOrConfusedHex"
+ },
+ "nonce": {
+ "$ref": "#/definitions/IntegerOrEmptyOrConfusedHex"
+ },
+ "r": {
+ "$ref": "#/definitions/TxSigR"
+ },
+ "s": {
+ "$ref": "#/definitions/TxSigS"
+ },
+ "to": {
+ "$ref": "#/definitions/AddressMaybePrefixOrEmpty"
+ },
+ "v": {
+ "$ref": "#/definitions/TxSigV"
+ },
+ "value": {
+ "items": {
+ "$ref": "#/definitions/IntegerOrEmptyOrConfusedHex"
+ },
+ "type": "array"
+ }
+ },
+ "required": [
+ "data",
+ "gasLimit",
+ "gasPrice",
+ "nonce",
+ "r",
+ "s",
+ "v",
+ "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": {
+ "^.*$": {
+ "type": "object",
+ "properties": {
+ "genesisBlockHeader": {
+ "$ref": "#/definitions/BlockHeader"
+ },
+ "genesisRLP": {
+ "$ref": "#/definitions/ConfusedHexType"
+ },
+ "blocks": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Block"
+ }
+ }
+ },
+ "postState": {
+ "$ref": "#/definitions/TransactionResults"
+ },
+ "pre": {
+ "$ref": "#/definitions/TransactionResults"
+ }
+ },
+ "required": [
+ "postState",
+ "pre",
+ "network",
+ "lastblockhash",
+ "blocks",
+ "genesisRLP",
+ "genesisBlockHeader"
+ ]
+ }
+}
diff --git a/JSONSchema/filler-schema.json b/JSONSchema/st-filler-schema.json
index da9f2fea6..da9f2fea6 100644
--- a/JSONSchema/filler-schema.json
+++ b/JSONSchema/st-filler-schema.json
diff --git a/JSONSchema/schema.json b/JSONSchema/st-schema.json
index 7b1536dae..7b1536dae 100644
--- a/JSONSchema/schema.json
+++ b/JSONSchema/st-schema.json
diff --git a/JSONSchema/validate.js b/JSONSchema/validate.js
index 1a1a605db..9206f961c 100755
--- a/JSONSchema/validate.js
+++ b/JSONSchema/validate.js
@@ -3,8 +3,10 @@
var fs = require('fs');
var validate = require('jsonschema').validate;
var readline = require('readline');
+var process = require('process');
var schemaFile = process.argv[2];
+
var schema = '';
var testCode = '';
var success = true;
@@ -19,8 +21,11 @@ var rl = readline.createInterface({
terminal: false
});
-rl.on('line', function(line) {
- fileNames.push(line);
+rl.on('line', function(fileName) {
+ if (fileName == 'BlockchainTests/bcForgedTest/bcInvalidRLPTest.json') {
+ return
+ }
+ fileNames.push(fileName);
});
rl.on('close', function() {
@@ -44,6 +49,7 @@ rl.on('close', function() {
console.log('error on file:', fileNames[i])
console.log(e);
numFailed++;
+ continue;
}
try {