What changed, and why it matters
This commit only updates a Rust test file for TON (The Open Network) mnemonic handling. It adjusts an existing test to expect a different error message and adds a second test case for an 11-word mnemonic. There is no change to production code behavior, no security fix, and no vulnerability introduced.
No security action required. Treat as routine test maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies rust/apps/ton/src/mnemonic.rs. The only non-test change is a cosmetic reformatting of an if-condition across multiple lines with identical logic. In the test module, the test_ton_mnemonic_invalid_mnemonic case is rewritten: the original 12-word test now expects a new error string (‘Invalid passwordless mnemonic (first byte: 0x0)’) instead of the previous word-count error, and a new 11-word test case is added to verify the UnexpectedWordCount error path. The words_len variable is declared but unused. These are test-maintenance changes only.
Changed components
rust/apps/ton/src/mnemonic.rs (test module only)Inspect captured patch +39 / −15
diff --git a/rust/apps/ton/src/mnemonic.rs b/rust/apps/ton/src/mnemonic.rs
index c6deb16..13a99cc 100644
--- a/rust/apps/ton/src/mnemonic.rs
+++ b/rust/apps/ton/src/mnemonic.rs
@@ -29,7 +29,9 @@ pub fn ton_mnemonic_validate(
normalized_words: &Vec<String>,
password: &Option<String>,
) -> Result<()> {
- if normalized_words.len() != TON_MNEMONIC_24_WORDS && normalized_words.len() != TON_MNEMONIC_12_WORDS {
+ if normalized_words.len() != TON_MNEMONIC_24_WORDS
+ && normalized_words.len() != TON_MNEMONIC_12_WORDS
+ {
return Err(MnemonicError::UnexpectedWordCount(normalized_words.len()).into());
}
@@ -110,7 +112,7 @@ pub fn ton_master_seed_to_public_key(master_seed: [u8; 64]) -> [u8; 32] {
#[cfg(test)]
mod tests {
- use alloc::{string::ToString, vec};
+ use alloc::{format, string::ToString, vec};
use hex;
@@ -147,18 +149,40 @@ mod tests {
#[test]
fn test_ton_mnemonic_invalid_mnemonic() {
- let words = [
- "dose", "ice", "enrich", "trigger", "test", "dove", "century", "still", "betray",
- "gas", "diet", "dune",
- ]
- .iter()
- .map(|v| v.to_lowercase())
- .collect();
- let result = ton_mnemonic_to_master_seed(words, None);
- assert!(result.is_err());
- assert_eq!(
- result.err().unwrap().to_string(),
- "Invalid TON Mnemonic, Invalid mnemonic word count (count: 12)"
- )
+ {
+ let words: Vec<String> = [
+ "dose", "ice", "enrich", "trigger", "test", "dove", "century", "still", "betray",
+ "gas", "diet", "dune",
+ ]
+ .iter()
+ .map(|v| v.to_lowercase())
+ .collect();
+ let words_len = words.len();
+ let result = ton_mnemonic_to_master_seed(words, None);
+ assert!(result.is_err());
+ assert_eq!(
+ result.err().unwrap().to_string(),
+ "Invalid TON Mnemonic, Invalid passwordless mnemonic (first byte: 0x0)".to_string()
+ )
+ }
+ {
+ let words: Vec<String> = [
+ "dose", "ice", "enrich", "trigger", "test", "dove", "century", "still", "betray",
+ "gas", "diet",
+ ]
+ .iter()
+ .map(|v| v.to_lowercase())
+ .collect();
+ let words_len = words.len();
+ let result = ton_mnemonic_to_master_seed(words, None);
+ assert!(result.is_err());
+ assert_eq!(
+ result.err().unwrap().to_string(),
+ format!(
+ "Invalid TON Mnemonic, Invalid mnemonic word count (count: {})",
+ words_len
+ )
+ )
+ }
}
}
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.