Files
chimera-gfx-Public/tests/test_phase10dc_bigapp_gate_contract.py
T
Chimera GFX release export a6037502d7
phase0-ci / build-and-audit (push) Successful in 2m14s
Publish Chimera GFX source
2026-09-03 03:27:14 +02:00

40 lines
2.6 KiB
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
"""Host tests for the pure Phase-1.0DC BigApp gate."""
from __future__ import annotations
import argparse
from dataclasses import replace
from pathlib import Path
import sys, unittest
P=argparse.ArgumentParser();P.add_argument("--root",type=Path,required=True);ROOT=P.parse_args().root
sys.path.insert(0,str(ROOT/"tools"))
from phase10dc_bigapp_gate_contract import (BigAppGateError,BigAppGateRecord,PHASE,validate_candidate,validate_inactive) # noqa:E402
def inactive():
return BigAppGateRecord(PHASE,False,*([None]*14),*([False]*13))
def candidate():
return BigAppGateRecord(PHASE,True,"9.60","PPSA01659","CHIMERA_DC_001","2030-01-01T00:00:00Z","2030-01-01T00:05:00Z","chimera_bigapp_canary_launcher.elf",65536,"a"*64,"retroarch_ps5_launch_canary.elf",1845240,"8dadce9d9faaef21ea129a3d216c768eea9a3ca9bf8ecb8d852e376b58a9bf95","b"*64,"CHD10AV1","D14",True,True,False,False,False,False,False,False,False,False,True,True,True)
class Tests(unittest.TestCase):
def test_inactive(self):validate_inactive(inactive())
def test_candidate_data(self):validate_candidate(candidate())
def test_exact_payload(self):
with self.assertRaises(BigAppGateError):validate_candidate(replace(candidate(),payload_sha256="c"*64))
def test_no_existing_bigapp(self):
with self.assertRaises(BigAppGateError):validate_candidate(replace(candidate(),no_running_bigapp_attested=False))
def test_effect_acceptance(self):
with self.assertRaises(BigAppGateError):validate_candidate(replace(candidate(),kernel_ptrace_effects_accepted=False))
def test_forbidden_effects(self):
for field in ("app_termination_authorized","persistent_write_authorized","system_remount_authorized","installation_authorized","autoload_authorized","automatic_retry","reconnect","fallback_title"):
with self.subTest(field=field),self.assertRaises(BigAppGateError):validate_candidate(replace(candidate(),**{field:True}))
def test_every_bounded_proof(self):
for field in ("bounded_parent_detach_proven","bounded_child_cleanup_proven","bounded_result_channel_proven"):
with self.subTest(field=field),self.assertRaises(BigAppGateError):validate_candidate(replace(candidate(),**{field:False}))
def test_window_and_title(self):
with self.assertRaises(BigAppGateError):validate_candidate(replace(candidate(),expires_at="2030-01-01T00:05:01Z"))
with self.assertRaises(BigAppGateError):validate_candidate(replace(candidate(),title_id="FAKE00000"))
if __name__=="__main__":unittest.main(argv=[__file__])