tests/test_anchor.py
| 1 | """Tests for MerkleAnchor and NullAnchorSink.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pqc_audit_log_fs.anchor import MerkleAnchor, NullAnchorSink |
| 6 | |
| 7 | |
| 8 | def test_null_sink_records_publishes() -> None: |
| 9 | sink = NullAnchorSink() |
| 10 | receipt = sink.publish("urn:log:1", 1, "ab" * 32) |
| 11 | assert receipt == "null-receipt-1" |
| 12 | assert sink.received == [("urn:log:1", 1, "ab" * 32)] |
| 13 | |
| 14 | |
| 15 | def test_merkle_anchor_stores_receipt() -> None: |
| 16 | sink = NullAnchorSink() |
| 17 | anchor = MerkleAnchor(sink=sink) |
| 18 | r1 = anchor.anchor_segment("urn:log:1", 1, "aa" * 32) |
| 19 | r2 = anchor.anchor_segment("urn:log:1", 2, "bb" * 32) |
| 20 | assert anchor.published == {1: r1, 2: r2} |
| 21 | assert r1 != r2 |
| 22 | |