Skip to content

feat(test-rng): deterministic_rng(seed) helper (#344)#381

Merged
joaquinbejar merged 1 commit into
mainfrom
issue-344-deterministic-rng
Apr 19, 2026
Merged

feat(test-rng): deterministic_rng(seed) helper (#344)#381
joaquinbejar merged 1 commit into
mainfrom
issue-344-deterministic-rng

Conversation

@joaquinbejar
Copy link
Copy Markdown
Owner

Summary

  • Add `utils::others::deterministic_rng(seed: u64) -> StdRng` plus `DETERMINISTIC_RNG_DEFAULT_SEED` constant.
  • Re-export both from `utils::` so test authors have one documented entry point for reproducible sample streams in Monte-Carlo / simulation tests per `rules/global_rules.md` §Numerical Discipline.
  • Three unit tests cover: same seed → identical stream, different seeds diverge, default seed stable across calls.
  • This is the primitive; per-module threading of the helper into existing tests is tracked as follow-up work.

Closes #344.

Test plan

  • `cargo test --lib --all-features` — 3756 pass; 4 pre-existing `chains::chain` failures unrelated.
  • `cargo clippy --lib --all-features --all-targets -- -D warnings` clean.
  • `cargo fmt --all --check`.

Per rules/global_rules.md §Numerical Discipline, Monte-Carlo and
simulation tests must seed deterministically. Introduce
`utils::others::deterministic_rng(seed: u64) -> StdRng` plus a
`DETERMINISTIC_RNG_DEFAULT_SEED` constant so test authors have one
obvious, documented entry point for reproducible sample streams.

The helper is re-exported from `utils::` and covered by three unit
tests: same seed → identical stream, different seeds diverge, default
seed is stable across calls.

This PR adds the primitive; the follow-up threading work (removing
`rand::random()` and `thread_rng()` from existing tests) is tracked
per-module on top of this helper.

Closes #344
@joaquinbejar joaquinbejar merged commit e6e2707 into main Apr 19, 2026
10 of 11 checks passed
@joaquinbejar joaquinbejar deleted the issue-344-deterministic-rng branch April 19, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seed deterministic RNG in all Monte-Carlo and simulation tests

1 participant