Skip to content

[Tests]: add test coverage for generate_mnemonic_from_coin_flips and get_partial_final_word#918

Open
S1DDHEY wants to merge 2 commits into
SeedSigner:devfrom
S1DDHEY:feat/test-mnemonic-gen
Open

[Tests]: add test coverage for generate_mnemonic_from_coin_flips and get_partial_final_word#918
S1DDHEY wants to merge 2 commits into
SeedSigner:devfrom
S1DDHEY:feat/test-mnemonic-gen

Conversation

@S1DDHEY
Copy link
Copy Markdown

@S1DDHEY S1DDHEY commented Apr 14, 2026

Description

Problem or Issue being addressed

generate_mnemonic_from_coin_flips() and get_partial_final_word() in helpers/mnemonic_generation.py had zero test coverage despite being user-facing seed generation paths.

Solution

Added 7 new tests to test_mnemonic_generation.py covering:

  1. generate_mnemonic_from_coin_flips():

    • 128 flips - valid 12-word mnemonic
    • 256 flips - valid 24-word mnemonic
    • 4 additional known vectors (all-zeros, all-ones, alternating for both lengths)
    • Random flips always produce valid mnemonics of the correct length
    • Different inputs produce different mnemonics
  2. get_partial_final_word():

    • boundary values tested for 7-flip inputs for 12-word mnemonic
    • same for 3-flip inputs for 24-word mnemonic

Additional Information

All tests were cross-verified using emulator with the Tools --> Calc 12th/24th word --> Coin flip entropy flow.
Part of Summer of Bitcoin

Screenshots

N/A, no UI changes.


This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Documentation
  • Other

Checklist

I ran pytest locally

  • All tests passed before submitting the PR
  • I couldn't run the tests
  • N/A

I included screenshots of any new or modified screens

Should be part of the PR description above.

  • Yes
  • No
  • N/A

I added or updated tests

Any new or altered functionality should be covered in a unit test. Any new or updated sequences require FlowTests.

  • Yes
  • No, I’m a fool
  • N/A

I tested this PR hands-on on the following platform(s):


I have reviewed these notes:

  • Keep your changes limited in scope.
  • If you uncover other issues or improvements along the way, ideally submit those as a separate PR.
  • The more complicated the PR, the harder it is to review, test, and merge.
  • We appreciate your efforts, but we're a small team of volunteers so PR review can be a very slow process.
  • Please only "@" mention a contributor if their input is truly needed to enable further progress.
  • I understand

Thank you! Please join our Devs' Telegram group to get more involved.

Copy link
Copy Markdown

@aphrodoe aphrodoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests verified correct. I independently recomputed expected mnemonics and partial words against embit.
ACK as it is tests only, no production code changes.

@newtonick
Copy link
Copy Markdown
Collaborator

Does this PR increase code coverage (https://github.com/SeedSigner/seedsigner/tree/dev/tests#generate-coverage-manually) ? If so, can the diff of percentage increase or line number increase be posted?

@S1DDHEY
Copy link
Copy Markdown
Author

S1DDHEY commented Apr 17, 2026

Yes, this PR increases code coverage for mnemonic_generation.py.

Before

image

After

image

This was already addressed earlier, the latest commit adds a bit more edge cases

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.

3 participants