Skip to content

Conversation

@benma
Copy link
Collaborator

@benma benma commented Dec 26, 2025

No description provided.

@benma benma requested a review from cedwies December 26, 2025 17:55
So unit tests don't have to perform intricate mocks to enter a
mneomnic using enter_string, menu, etc.

Same mnemonic as in mnemonic_c_unit_tests.rs, as it will be used in
the unit tests of api::restore.
Since a1c553b, the mnemonic module
was not compiled during testing by accident, as a specific
implementation was compiled in for c-unit-testing.

This means that the unit tests and clippy were not running for mnemonic.rs.
Copy link
Collaborator

@cedwies cedwies left a comment

Choose a reason for hiding this comment

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

Good PR, did not spot major issues. Apart from the comments I have another question:

The test mnemonic boring mistake dish oyster... appears in both testing.rs and mnemonic_c_unit_tests.rs. If someone updates one but forgets the other, tests could silently pass with different data. Would a shared constant be better, or is the duplication intentional to keep the Rust tests and C tests completely isolated?

}
}

/// Retrieve a BIP39 mnemonic sentence of 12, 18 or 24 words from the user.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just so I am not missing anything: The comment was wrong anyway, right?. Did we even support 18 words?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We used to until recently.

pub mod confirm;
pub mod menu;
#[cfg_attr(feature = "c-unit-testing", path = "workflow/mnemonic_c_unit_tests.rs")]
#[cfg_attr(
Copy link
Collaborator

Choose a reason for hiding this comment

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

With cfg_attr(all(feature = "c-unit-testing", not(feature = "testing")), ...), if someone (accidentally) enables both c-unit-testing and testing at the same time, the code silently uses the "real" mnemonic.rs. Would it be safer to add a compile_error! to catch this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In Rust unit tests, both features are active (all features are active in Rust unit tests), and the "real" mnemonic.rs should be used. That's why I did this change. Or am I missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah no I was missing something, thanks for clarifying

@benma
Copy link
Collaborator Author

benma commented Jan 4, 2026

The test mnemonic boring mistake dish oyster... appears in both testing.rs and mnemonic_c_unit_tests.rs. If someone updates one but forgets the other, tests could silently pass with different data. Would a shared constant be better, or is the duplication intentional to keep the Rust tests and C tests completely isolated?

The mnemonic in mnemonic_c_unit_tests.rs is used by the (non-graphical) simulator and shouldn't change, as probably integration tests in various repos depend on it. (The same mnemonic also exists once more in graphical simulator main.rs).

The new one in testing.rs is merely for Rust unit tests, and could be a different one, or be replaced by some sort of mocking facility later, so I don't think there should be a shared constant.

Copy link
Collaborator

@cedwies cedwies left a comment

Choose a reason for hiding this comment

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

Thanks for clarifying, utACK

@benma benma merged commit 0b8b1e4 into BitBoxSwiss:master Jan 5, 2026
37 checks passed
@benma benma deleted the restore-test branch January 5, 2026 08:32
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.

2 participants