test-audit: fix RNG-reuse bug, trim an oversized test loop#758
Merged
Conversation
game_loop_test.rs's simulate_tick()/simulate_ticks() reseeded a fresh ChaCha8Rng on every call, so multi-tick loops replayed the same "random" roll every tick instead of a real sequence. Thread one RNG through each loop instead. combat_submodules_test.rs's test_consecutive_deaths_triggers_retreat looped 100 times for an event that resolves within ~20 ticks (one enemy attack interval); trimmed to 40 for a comfortable margin. Found by /test-audit.
stphung
added a commit
that referenced
this pull request
Jul 15, 2026
PR #758 fixed an RNG-reuse bug in game_loop_test.rs and trimmed an oversized loop in combat_submodules_test.rs; remaining findings (redundant test coverage across deep_tests/game_tick_tests/ achievement_tests, and two production-side unseeded-RNG call sites) are flagged for human review, not auto-fixed. Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/game_tick_tests/game_loop_test.rs'ssimulate_tick()/simulate_ticks()helpers reseeded a freshChaCha8Rngon every call, so multi-tick test loops replayed the identical "random" roll every tick instead of a real sequence. Threaded one RNG through each affected loop instead (spawn/combat/regen/kill-tracking tests), and removed the now-unusedsimulate_tick()wrapper.tests/combat_tests/combat_submodules_test.rs::test_consecutive_deaths_triggers_retreatlooped 100 times for an event that actually resolves within ~20 ticks (one enemy attack interval of 2.0s at 0.1s/tick); trimmed the bound to 40 for a comfortable 2x margin.Found via
/test-audit. The three-agent audit also surfaced a larger set of redundant/duplicate test coverage acrossdeep_tests/,game_tick_tests/, andachievement_tests/, plus a known-tracked ~40-instance brute-force RNG-search category — left untouched as those need human judgment on consolidation, not mechanical fixes.Test plan
cargo fmt --checkcargo clippy --all-targets -- -D warningscargo test(full suite, 0 failures)QUEST_ACT2=1 cargo test flag_oncargo run --release --bin simulator -- --check-progressioncargo run --release --bin voyage_simulatorcargo testx10 consecutive runs — 0 failures (flakiness check)Generated by Claude Code