aboutsummaryrefslogtreecommitdiffstats
path: root/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'test.py')
-rwxr-xr-xtest.py30
1 files changed, 30 insertions, 0 deletions
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()