Skip to content

Commit

Permalink
moar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajjon committed Feb 21, 2024
1 parent 43e257c commit f606f4c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/hierarchical_deterministic/bip39/bip39_word_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ mod tests {
);
}

#[test]
fn invalid_word_count_error() {
assert_eq!(
BIP39WordCount::from_count(23),
Err(CommonError::InvalidBIP39WordCount { bad_value: 23 })
)
}

#[test]
fn ord() {
assert!(BIP39WordCount::Twelve < BIP39WordCount::TwentyFour);
Expand Down
12 changes: 12 additions & 0 deletions src/hierarchical_deterministic/bip44/bip44_like_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,18 @@ mod tests {
);
}

#[test]
fn invalid_depth_3_via_hdpath() {
let hdpath: HDPath = "m/44H/1022H/0H".parse().unwrap();
assert_eq!(
BIP44LikePath::try_from(&hdpath),
Err(CommonError::InvalidDepthOfBIP44Path {
expected: BIP44LikePath::PATH_DEPTH as u64,
found: 3
})
);
}

#[test]
fn invalid_account_not_hardened() {
assert_eq!(
Expand Down
4 changes: 3 additions & 1 deletion src/profile/logic/profile_next_derivation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ impl Profile {
factor_source_id: FactorSourceIDFromHash,
) -> HDPathValue {
match kind {
EntityKind::Persona => panic!("Personas are not supported yet"),
EntityKind::Persona => {
unreachable!("Personas are not supported yet")
}
EntityKind::Accounts => {}
};
let index = self
Expand Down
24 changes: 18 additions & 6 deletions src/profile/v100/header/profile_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,28 @@ impl HasPlaceholder for ProfileID {
#[cfg(test)]
mod tests {
use crate::prelude::*;

#[allow(clippy::upper_case_acronyms)]
type SUT = ProfileID;

#[test]
fn equality() {
assert_eq!(ProfileID::placeholder(), ProfileID::placeholder());
assert_eq!(
ProfileID::placeholder_other(),
ProfileID::placeholder_other()
);
assert_eq!(SUT::placeholder(), SUT::placeholder());
assert_eq!(SUT::placeholder_other(), SUT::placeholder_other());
}

#[test]
fn inequality() {
assert_ne!(ProfileID::placeholder(), ProfileID::placeholder_other());
assert_ne!(SUT::placeholder(), SUT::placeholder_other());
}

#[test]
fn from_str_invalid() {
assert_eq!(
"bad".parse::<SUT>(),
Err(CommonError::InvalidProfileID {
bad_value: "bad".to_owned()
})
);
}
}

0 comments on commit f606f4c

Please sign in to comment.