29 lines
969 B
Python
29 lines
969 B
Python
import hashlib
|
|
import json
|
|
import subprocess
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
import generate_hal_graph_report
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class HalGraphReportTests(unittest.TestCase):
|
|
def test_report_and_runtime(self):
|
|
report = json.loads((ROOT / "coverage/hal-graph.report.json").read_text(encoding="utf-8"))
|
|
self.assertEqual(report["schema"], "hal-graph-report.v1")
|
|
self.assertEqual(report["status"], "verified")
|
|
self.assertTrue(all(report[name]["status"] == "verified" for name in ("native", "wasm", "worker")))
|
|
|
|
def test_report_self_hash(self):
|
|
report = json.loads((ROOT / "coverage/hal-graph.report.json").read_text(encoding="utf-8"))
|
|
unsigned = dict(report)
|
|
actual = unsigned.pop("report_sha256")
|
|
self.assertEqual(actual, hashlib.sha256(generate_hal_graph_report.canonical(unsigned).encode("utf-8")).hexdigest())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|