test_p_evidence_stress.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
12 hours ago
| 1 | """Stress tests for P-evidence large artifact lists (§PE.10).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from tests.fixtures.p_evidence import load_p_evidence_entry, seed_p_evidence_repo |
| 6 | from tools.honesty.canonical import canonical_json, compute_entry_hash |
| 7 | from tools.honesty.ledger import append_entry, verify_ledger_file |
| 8 | from tools.honesty.types import LedgerAppendOptions |
| 9 | |
| 10 | |
| 11 | def test_large_artifacts_append_and_verify(repo_root) -> None: |
| 12 | config = seed_p_evidence_repo(repo_root) |
| 13 | body = load_p_evidence_entry("verification-evidence-pass.json") |
| 14 | body["artifacts"] = [ |
| 15 | { |
| 16 | "type": "test_output", |
| 17 | "sha256": f"{index:064x}", |
| 18 | "ref": f"capture-{index}", |
| 19 | } |
| 20 | for index in range(50) |
| 21 | ] |
| 22 | result = append_entry( |
| 23 | config=config, |
| 24 | repo_root=repo_root, |
| 25 | options=LedgerAppendOptions(kind="verification_evidence", body=body), |
| 26 | ) |
| 27 | assert result.exit_code == 0 |
| 28 | verify = verify_ledger_file(config=config, repo_root=repo_root) |
| 29 | assert verify.exit_code == 0 |
| 30 | |
| 31 | |
| 32 | def test_many_evidence_entries_chain_verify(repo_root) -> None: |
| 33 | config = seed_p_evidence_repo(repo_root) |
| 34 | for round_num in range(1, 21): |
| 35 | body = load_p_evidence_entry("verification-evidence-pass.json") |
| 36 | body["round"] = round_num |
| 37 | body["actor_session_id"] = f"bv-{round_num}" |
| 38 | code = append_entry( |
| 39 | config=config, |
| 40 | repo_root=repo_root, |
| 41 | options=LedgerAppendOptions(kind="verification_evidence", body=body), |
| 42 | ).exit_code |
| 43 | assert code == 0 |
| 44 | verify = verify_ledger_file(config=config, repo_root=repo_root) |
| 45 | assert verify.exit_code == 0 |
| 46 | |
| 47 | |
| 48 | def test_artifact_order_affects_canonical_hash() -> None: |
| 49 | first = [{"type": "test_output", "sha256": "a" * 64}, {"type": "screenshot", "sha256": "b" * 64, "ref": "x.png"}] |
| 50 | second = list(reversed(first)) |
| 51 | h1 = compute_entry_hash({"artifacts": first, "kind": "verification_evidence", "v": 1}) |
| 52 | h2 = compute_entry_hash({"artifacts": second, "kind": "verification_evidence", "v": 1}) |
| 53 | assert h1 != h2 |
| 54 | assert canonical_json({"artifacts": first}) != canonical_json({"artifacts": second}) |
File History
1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
12 hours ago