Game tests: every known build's hash is one identify() can match #303

Closed
SkippySteve wants to merge 1 commit from upstream-pr/303 into main
SkippySteve commented 2026-11-24 02:11:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SkippySteve on 2026-11-24T02:11:08Z.


KNOWN_BUILDS is matched against the hex BLAKE3 that run.rs computes for the executable. An entry with a typo, a truncated hash, stray whitespace or a duplicate would compile fine and simply never identify the build it names. victory-game/src/lib.rs has no tests today.

This adds a test module (tests only, no behaviour change):

  • known_builds_are_well_formed: each entry has a label, its hash is 64 lowercase hex digits (the form blake3::Hash::to_hex writes), and no label or hash appears twice.
  • every_known_build_is_identified_by_its_hash: identify() finds each build by its own hash, in lower or upper case.
  • unknown_hashes_are_not_identified: the BLAKE3 of empty input, an empty string and non-hex text identify nothing.

The list is empty on main, so the first two guard future entries. To check they bite, I temporarily added an entry with an uppercase hash; known_builds_are_well_formed failed as expected.

No game files or new dependencies; it runs on every host.

Tested on Linux:

  • cargo test -p victory-game: 5 passed
  • cargo clippy -p victory-game --all-targets -- -D warnings: clean
  • cargo fmt -p victory-game -- --check: clean
<!-- greyfinch-sync:Marvisak/VIctory:issue:6573021778 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/303). Originally posted by [SkippySteve](https://github.com/SkippySteve) on 2026-11-24T02:11:08Z. --- `KNOWN_BUILDS` is matched against the hex BLAKE3 that `run.rs` computes for the executable. An entry with a typo, a truncated hash, stray whitespace or a duplicate would compile fine and simply never identify the build it names. `victory-game/src/lib.rs` has no tests today. This adds a test module (tests only, no behaviour change): - `known_builds_are_well_formed`: each entry has a label, its hash is 64 lowercase hex digits (the form `blake3::Hash::to_hex` writes), and no label or hash appears twice. - `every_known_build_is_identified_by_its_hash`: `identify()` finds each build by its own hash, in lower or upper case. - `unknown_hashes_are_not_identified`: the BLAKE3 of empty input, an empty string and non-hex text identify nothing. The list is empty on `main`, so the first two guard future entries. To check they bite, I temporarily added an entry with an uppercase hash; `known_builds_are_well_formed` failed as expected. No game files or new dependencies; it runs on every host. Tested on Linux: - `cargo test -p victory-game`: 5 passed - `cargo clippy -p victory-game --all-targets -- -D warnings`: clean - `cargo fmt -p victory-game -- --check`: clean
upstream-sync closed this pull request 2026-11-24 06:52:19 +00:00
SkippySteve commented 2026-11-24 06:55:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SkippySteve on 2026-11-24T02:32:35Z.


Superseded by #273, which now carries this commit (KNOWN_BUILDS tests) alongside the other victory-game fix.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7120246355 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/303#issuecomment-7120246355). Originally posted by [SkippySteve](https://github.com/SkippySteve) on 2026-11-24T02:32:35Z. --- Superseded by #273, which now carries this commit (KNOWN_BUILDS tests) alongside the other victory-game fix.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!303
No description provided.