Skip to content

Commit

Permalink
Add failure test for Mnemonic::from_entropy()
Browse files Browse the repository at this point in the history
  • Loading branch information
steveatinfincia committed Sep 20, 2017
1 parent becd7b1 commit 4be7216
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/generate.rs
Expand Up @@ -94,3 +94,14 @@ fn generate_24_english() {
let seed_bytes: &[u8] = seed.as_bytes();
assert!(seed_bytes.len() == 64);
}

#[test]
#[should_panic]
fn generate_12_english_from_invalid_entropy() {
let mnemonic_type = MnemonicType::for_word_count(12).unwrap();

// only 15 bytes
let entropy = &[0x33, 0xE4, 0x6B, 0xB1, 0x3A, 0x74, 0x6E, 0xA4, 0x1C, 0xDD, 0xE4, 0x5C, 0x90, 0x84, 0x6A];

Mnemonic::from_entropy(entropy, mnemonic_type, Language::English, "").unwrap();
}

0 comments on commit 4be7216

Please sign in to comment.