Implement AXIS parity UI and execution baseline
This commit is contained in:
37
scripts/test_hal_s2_report.py
Normal file
37
scripts/test_hal_s2_report.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import hashlib
|
||||
import json
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import generate_hal_s2_report
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
class HalS2ReportTests(unittest.TestCase):
|
||||
def test_report_contract(self):
|
||||
report = json.loads((ROOT / "coverage/hal-s2.report.json").read_text(encoding="utf-8"))
|
||||
self.assertEqual(report["schema"], "hal-s2-report.v1")
|
||||
self.assertEqual(report["task_id"], "S2-02")
|
||||
self.assertEqual(report["status"], "verified")
|
||||
self.assertTrue(report["tests"]["native_wasm_byte_identical"])
|
||||
self.assertEqual(report["capacity"]["pins"], 256)
|
||||
|
||||
def test_report_self_hash(self):
|
||||
report = json.loads((ROOT / "coverage/hal-s2.report.json").read_text(encoding="utf-8"))
|
||||
unsigned = {key: value for key, value in report.items() if key != "report_sha256"}
|
||||
canonical = json.dumps(unsigned, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode()
|
||||
self.assertEqual(report["report_sha256"], hashlib.sha256(canonical).hexdigest())
|
||||
|
||||
def test_report_is_deterministic(self):
|
||||
first = ROOT / "coverage/.hal-s2-one.json"
|
||||
second = ROOT / "coverage/.hal-s2-two.json"
|
||||
try:
|
||||
self.assertEqual(generate_hal_s2_report.generate(first), generate_hal_s2_report.generate(second))
|
||||
finally:
|
||||
first.unlink(missing_ok=True)
|
||||
second.unlink(missing_ok=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user