Skip to content

test(desktop): make passphrase word-count test deterministic - #6358

Open
SomSamantray wants to merge 3 commits into
block:mainfrom
SomSamantray:fix/flaky-passphrase-test
Open

test(desktop): make passphrase word-count test deterministic#6358
SomSamantray wants to merge 3 commits into
block:mainfrom
SomSamantray:fix/flaky-passphrase-test

Conversation

@SomSamantray

Copy link
Copy Markdown
Contributor

Summary

The generated_passphrase_respects_word_count_and_separator test was flaky: the EFF short wordlist 2.0 contains the hyphenated word yo-yo, so a --joined passphrase that draws it split into four parts instead of three and failed the assertion roughly 1 in 186 runs.

The test now splits passphrases with a word-aware helper that reconstructs hyphenated wordlist words, and a new deterministic fixture (yo-yo-aardvark-fanfare) exercises the yo-yo case on every run, independent of the OS entropy draw. No production code changes.

Related issue

Fixes #6249

Testing

  • cargo test --manifest-path desktop/src-tauri/Cargo.toml key_backup — all 31 tests pass.
  • The previously-flaky test passed 50/50 repeated runs; the new hyphenated-word fixture passed 30/30.
  • cargo clippy --lib --tests — no warnings on the changed code.

@SomSamantray
SomSamantray requested a review from a team as a code owner August 19, 2026 21:53
SomSamantray and others added 2 commits August 20, 2026 07:52
The EFF short wordlist 2.0 contains the hyphenated word `yo-yo`. The
`generated_passphrase_respects_word_count_and_separator` test joined
three words with `-` and asserted that splitting on `-` yields exactly
three parts; drawing `yo-yo` produced four parts and failed ~1 in 186
runs.

Replace the naive split with a word-aware helper that reconstructs
hyphenated wordlist words, and add a deterministic fixture
(`yo-yo-aardvark-fanfare`) that exercises the hyphenated case on every
run, independent of the OS entropy draw.

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
Signed-off-by: Som Samantray <som.samantray@gmail.com>
Extract the shared wordlist-set builder, use a peekable split iterator
instead of an index over a materialized fragment Vec (removing a latent
out-of-bounds panic path), drop WHAT-narration comments, and rename the
hyphenated-word test to match the helper it exercises.

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
Signed-off-by: Som Samantray <som.samantray@gmail.com>
@SomSamantray
SomSamantray force-pushed the fix/flaky-passphrase-test branch from 50d1833 to 2578cb6 Compare August 20, 2026 02:22
SomSamantray added a commit to SomSamantray/buzz that referenced this pull request Aug 20, 2026
Records the plan for adding Signed-off-by trailers to the two commits
on PR block#6358 so the DCO Check passes.

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
Records the plan for adding Signed-off-by trailers to the two commits
on PR block#6358 so the DCO Check passes.

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
Signed-off-by: Som Samantray <som.samantray@gmail.com>
@SomSamantray
SomSamantray force-pushed the fix/flaky-passphrase-test branch from 89689fa to a641111 Compare August 20, 2026 02:25
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.

Flaky test: generated_passphrase_respects_word_count_and_separator fails ~1 in 186 runs when 'yo-yo' is drawn into a hyphen-joined passphrase

1 participant