Skip to content

Commit

Permalink
test(olm): Add mutation tests for message_key
Browse files Browse the repository at this point in the history
Relates to: #78
  • Loading branch information
Johennes authored and poljar committed Mar 15, 2024
1 parent 2deb206 commit 993410b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .cargo/mutants.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
additional_cargo_args = ["--all-features"]
exclude_re = [
# Coverage of debug functions is not relevant
"impl Debug",
# Replacing + with * makes no logical difference here
"src/olm/messages/message\\.rs.*replace \\+ with \\* in <impl TryFrom for Message>::try_from",
# Drop implementations perform zeroisation which cannot be tested in Rust
"impl Drop",
]
18 changes: 18 additions & 0 deletions src/olm/session/message_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,21 @@ impl RemoteMessageKey {
}
}
}

#[cfg(test)]
#[cfg(feature = "low-level-api")]
mod test {
use super::MessageKey;
use crate::olm::RatchetPublicKey;

#[test]
fn low_level_getters() {
let key = b"11111111111111111111111111111111";
let ratchet_key = RatchetPublicKey::from(*b"22222222222222222222222222222222");
let index: u64 = 3;
let message_key = MessageKey::new(Box::new(*key), ratchet_key, index);
assert_eq!(message_key.key(), key);
assert_eq!(message_key.ratchet_key(), ratchet_key);
assert_eq!(message_key.index(), index);
}
}

0 comments on commit 993410b

Please sign in to comment.