mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-08-08 06:56:10 +00:00
Addresses both asks in the #1472 review. The tests duplicated every vector as a Swift literal, so a format change that updated only the Swift side would have left docs/courier-test-vectors.json silently stale — the document was published as authoritative but nothing checked it. Each test now reads the file and asserts against what it says. The NoiseTestVectors.json precedent does not transfer directly: that fixture lives inside its test target and loads from the test bundle, whereas this one lives at repo-root docs/, outside the package, so SwiftPM cannot carry it as a resource. It resolves the path from #filePath instead, the way bitchatTests/LocalizationCoverageTests already reaches the repo root. CI runs this package with the full tree checked out, and the target is not in the xcodeproj, so there is no bundle-only run to break. Two things beyond a mechanical swap: - The published `label` for the tag HMAC is now load-bearing. The implementation's context string is private, so the test recomputes the tag from the label in the file and compares — otherwise the document could name the wrong label and nothing would notice. - A dedicated test fails loudly if the file is missing or has lost a key, rather than letting a rename skip every assertion while the suite reports green. Also fixes the stale prose. The review caught "the finished 110-byte wire packet"; the same deleted spray-receipt example had left three more wrong numbers in packetSigning._comment — the padding worked example read 46 + 16 = 62 with shortfall 210 = 0xd2, where the real frame is 104 + 16 = 120 with shortfall 152 = 0x98. Proven by mutation, not by green: flipping a byte in envelopeTLV.encoded, a byte in signingPreimage, and the HMAC label each fail the matching test, and removing the file fails all seven. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>