Skip to content

Commit

Permalink
test(cipher): Add mutation tests
Browse files Browse the repository at this point in the history
Relates to: matrix-org#78

Signed-off-by: Johannes Marbach <[email protected]>
  • Loading branch information
Johennes committed Apr 9, 2024
1 parent 7d51bd6 commit 80db8f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .cargo/mutants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ exclude_re = [
# These cause olm/account tests to hang
"RemoteChainKey::chain_index",
"RemoteChainKey::advance",
# Intentionally returns Ok(()) in all cases
"replace Cipher::verify_truncated_mac -> Result<\\(\\), MacError> with Ok\\(\\(\\)\\)",
# The constant value can't really be tested
"src/olm/account/one_time_keys\\.rs.*replace \\* with \\+$",
]
15 changes: 15 additions & 0 deletions src/cipher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,18 @@ impl Cipher {
Ok(())
}
}

#[cfg(test)]
mod test {
use super::{Cipher, Mac};
use crate::cipher::DecryptionError;

#[test]
fn decrypt_pickle_mac_missing() {
let cipher = Cipher::new(&[1u8; 32]);
assert!(matches!(
cipher.decrypt_pickle(&[2u8; Mac::TRUNCATED_LEN]),
Err(DecryptionError::MacMissing)
));
}
}

0 comments on commit 80db8f0

Please sign in to comment.