Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mina86 committed Nov 13, 2023
1 parent 2dd60f9 commit 33dc102
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions crates/ibc/src/core/ics24_host/identifier/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,21 @@ mod tests {
assert!(id.is_err())
}

#[test]
fn validate_empty_id() {
// validate_identifier_chars does not check for empty identifiers
validate_identifier_chars("").unwrap();
// validate_identifier_length never allows empty identifiers
validate_identifier_length("", 0, 64).unwrap_err();
}

#[test]
fn validate_bogus_constraints() {
// validate_identifier_length doesn’t assert min_id_length and
// max_id_length make sense. It just rejects the id.
validate_identifier_length("foobar", 5, 3).unwrap_err();
}

#[test]
fn parse_invalid_id_path_separator() {
// invalid id with path separator
Expand All @@ -214,8 +229,10 @@ mod tests {
}

#[rstest]
#[case::zero_min_length("", 0, 64, false)]
#[case::empty_prefix("", 1, 64, false)]
#[case::max_is_low("a", 1, 10, false)]
#[case::bogus_constraints("foobar", 5, 3, false)]
#[case::u64_max_is_too_big("a", 3, 21, false)]
#[case::u64_min_is_too_small("a", 4, 22, false)]
#[case::u64_min_max_boundary("a", 3, 22, true)]
Expand Down

0 comments on commit 33dc102

Please sign in to comment.