diff options
author | Everett Hildenbrandt <hildenb2@illinois.edu> | 2018-05-31 02:41:43 +0800 |
---|---|---|
committer | Everett Hildenbrandt <hildenb2@illinois.edu> | 2018-06-01 02:51:32 +0800 |
commit | 7bfd7998cfc9d4f59f0bc29d9718709d3d15a81e (patch) | |
tree | d566c0218cc36973fd1ccae017fe75cf7209adbb /test.py | |
parent | 8137a8bbd0458dbdf912901abdea77127ddaf870 (diff) | |
download | tangerine-tests-7bfd7998cfc9d4f59f0bc29d9718709d3d15a81e.tar.gz tangerine-tests-7bfd7998cfc9d4f59f0bc29d9718709d3d15a81e.tar.zst tangerine-tests-7bfd7998cfc9d4f59f0bc29d9718709d3d15a81e.zip |
test.py: add checkFilled command for ensuring that tests are filled
Diffstat (limited to 'test.py')
-rwxr-xr-x | test.py | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -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() |