From 291c054b2731de7172579ca629d1499be44f15fa Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Wed, 5 Jul 2017 13:33:09 -0700 Subject: format code. Remove unused python code --- JSONSchema/schema.json | 187 ++++++++++++++++++++++++------------------------- JSONSchema/validate.js | 20 +++--- JSONSchema/validate.py | 30 -------- 3 files changed, 105 insertions(+), 132 deletions(-) delete mode 100755 JSONSchema/validate.py (limited to 'JSONSchema') diff --git a/JSONSchema/schema.json b/JSONSchema/schema.json index 6e7113950..74e796a88 100644 --- a/JSONSchema/schema.json +++ b/JSONSchema/schema.json @@ -1,131 +1,130 @@ { - "type": "object", - "patternProperties": { - "^.*$": { - "type": "object", - "properties": { - "post": { - "type": "object", - "properties": { - "EIP150": { - "type": "array" + "type":"object", + "patternProperties":{ + "^.*$":{ + "type":"object", + "properties":{ + "post":{ + "type":"object", + "properties":{ + "EIP150":{ + "type":"array" }, - "EIP158": { - "type": "array" + "EIP158":{ + "type":"array" }, - "Frontier": { - "type": "array" + "Frontier":{ + "type":"array" }, - "Homestead": { - "type": "array" + "Homestead":{ + "type":"array" }, - "Metropolis": { - "type": "array" + "Metropolis":{ + "type":"array" } - } - }, - "explanation": { - "type": "string" + } }, - "env": { - "type": "object", - "properties": { - "currentCoinbase": { - "type": "string", - "pattern": "^0x[0-9a-f]*$" + "explanation":{ + "type":"string" + }, + "env":{ + "type":"object", + "properties":{ + "currentCoinbase":{ + "type":"string", + "pattern":"^0x[0-9a-f]*$" }, - "currentDifficulty": { - "type": "string", - "pattern": "^0x[0-9a-f]*$" + "currentDifficulty":{ + "type":"string", + "pattern":"^0x[0-9a-f]*$" }, - "currentGasLimit": { - "type": "string", - "pattern": "^0x[0-9a-f]*$" + "currentGasLimit":{ + "type":"string", + "pattern":"^0x[0-9a-f]*$" }, - "currentNumber": { - "type": "string", - "pattern": "^0x[0-9a-f]*$" + "currentNumber":{ + "type":"string", + "pattern":"^0x[0-9a-f]*$" }, - "currentTimestamp": { - "type": "string", - "pattern": "^0x[0-9a-f]*$" + "currentTimestamp":{ + "type":"string", + "pattern":"^0x[0-9a-f]*$" }, - "previousHash": { - "type": "string", - "pattern": "^0x[0-9a-f]*$" + "previousHash":{ + "type":"string", + "pattern":"^0x[0-9a-f]*$" } }, - "additionalproperties": false + "additionalproperties":false }, - "pre": { - "type": "object", - "patternProperties": { - "^0x[0-9a-f]*": { - "type": "object", - "properties": { - "balance": { - "type": "string", - "pattern": "^0x[0-9a-f]*$" + "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]*)?$" + "code":{ + "type":"string", + "pattern":"^(0x[0-9a-f]*)?$" }, - "nonce": { - "type": "string", - "pattern": "^0x[0-9a-f]*$" - + "nonce":{ + "type":"string", + "pattern":"^0x[0-9a-f]*$" }, - "storage": { - "type": "object" + "storage":{ + "type":"object" } } } }, - "additionalProperties": false + "additionalProperties":false }, - "transaction": { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "type": "string", - "pattern": "^(0x[0-9a-f]*)?$" + "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]*$" + "gasLimit":{ + "type":"array", + "items":{ + "type":"string", + "pattern":"^0x[0-9a-f]*$" } }, - "gasPrice": { - "type": "string", - "pattern": "^0x[0-9a-f]*$" + "gasPrice":{ + "type":"string", + "pattern":"^0x[0-9a-f]*$" }, - "nonce": { - "type": "string", - "pattern": "^0x[0-9a-f]*$" + "nonce":{ + "type":"string", + "pattern":"^0x[0-9a-f]*$" }, - "secretKey": { - "type": "string", - "pattern": "^0x[0-9a-f]*$" + "secretKey":{ + "type":"string", + "pattern":"^0x[0-9a-f]*$" }, - "to": { - "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]*$" + "value":{ + "type":"array", + "items":{ + "type":"string", + "pattern":"^0x[0-9a-f]*$" } } }, - "additionalProperties": false + "additionalProperties":false } } } diff --git a/JSONSchema/validate.js b/JSONSchema/validate.js index 6c44b834f..e3037ccad 100755 --- a/JSONSchema/validate.js +++ b/JSONSchema/validate.js @@ -4,17 +4,20 @@ var validate = require('jsonschema').validate; var fs = require('fs'); var readline = require('readline'); +var process = require('process'); + var schema = ''; var testCode = ''; +var success = true; var readline = require('readline'); var rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, - terminal: false + input: process.stdin, + output: process.stdout, + terminal: false }); -rl.on('line', function(line){ +rl.on('line', function(line) { fs.readFile('JSONSchema/schema.json', function(err, data) { if (err) { throw err; @@ -29,7 +32,7 @@ rl.on('line', function(line){ try { testCode = JSON.parse(data); - } catch(e) { + } catch (e) { console.log(e); } @@ -37,12 +40,13 @@ rl.on('line', function(line){ var x = validate(testCode, schema); if (x.errors.length > 0) { - console.log(line+':\n'); + success = false; + console.log(line + ':\n'); for (var i = 0; i < x.errors.length; i++) { - console.log(' '+x.errors[i]+'\n') + console.log(' ' + x.errors[i] + '\n') } } - } catch(e) { + } catch (e) { console.log(e); } }); diff --git a/JSONSchema/validate.py b/JSONSchema/validate.py deleted file mode 100755 index 086abfa93..000000000 --- a/JSONSchema/validate.py +++ /dev/null @@ -1,30 +0,0 @@ -#! /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') - -- cgit v1.2.3