From 7bfd7998cfc9d4f59f0bc29d9718709d3d15a81e Mon Sep 17 00:00:00 2001 From: Everett Hildenbrandt Date: Wed, 30 May 2018 12:41:43 -0600 Subject: test.py: add checkFilled command for ensuring that tests are filled --- test.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test.py') diff --git a/test.py b/test.py index 33d397711..e7957989d 100755 --- a/test.py +++ b/test.py @@ -21,11 +21,13 @@ # # - python-json # - python-jsonschema +# - python-pysha3 import sys import os import json import jsonschema +import sha3 # Utilities # ========= @@ -115,6 +117,32 @@ def validateTestFile(jsonFile): return validateSchema(jsonFile, schemaFile) +# Check tests filled + +def hashFile(fname): + with open(fname ,"rb") as f: + k = sha3.keccak_256() + k.update(f.read()) + return k.hexdigest() + +def checkFilled(jsonFile): + jsonTest = readJSONFile(jsonFile) + if not ( jsonFile.startswith("./src/BlockchainTestsFiller/GeneralStateTests/") + # or jsonFile.startswith("./src/BlockchainTestsFiller/VMTests/") + or jsonFile.startswith("./VMTests/") + or jsonFile.startswith("./GeneralStateTests/") + or jsonFile.startswith("./TransactionTests/") + or jsonFile.startswith("./BlockchainTests/") + ): + _report("Not a file that is filled:", jsonFile) + return + for test in jsonTest: + if "_info" in jsonTest[test]: + fillerSource = jsonTest[test]["_info"]["source"] + fillerHash = jsonTest[test]["_info"]["sourceHash"] + if fillerHash != hashFile(fillerSource): + _logerror("Test must be filled:", jsonFile) + # Main # ==== @@ -148,6 +176,8 @@ def main(): testDo = lambda t: writeJSONFile(t, readJSONFile(t)) elif test_command == "validate": testDo = validateTestFile + elif test_command == "checkFilled": + testDo = checkFilled else: _usage() -- cgit