Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(olm): Add mutation tests for account #138

Merged

Conversation

Johennes
Copy link
Contributor

@Johennes Johennes commented Mar 25, 2024

This fixes:

MISSED   src/olm/account/one_time_keys.rs:126:9: replace OneTimeKeys::is_secret_key_published -> bool with false in 0.9s build + 3.5s test
MISSED   src/olm/account/one_time_keys.rs:126:9: replace OneTimeKeys::is_secret_key_published -> bool with true in 0.9s build + 3.4s test
MISSED   src/olm/account/fallback_keys.rs:53:9: replace FallbackKey::published -> bool with false in 0.8s build + 3.0s test
MISSED   src/olm/account/fallback_keys.rs:70:9: replace FallbackKeys::mark_as_published with () in 0.8s build + 3.3s test
MISSED   src/olm/account/fallback_keys.rs:77:21: replace += with *= in FallbackKeys::generate_fallback_key in 0.8s build + 3.1s test
MISSED   src/olm/account/fallback_keys.rs:49:9: replace FallbackKey::mark_as_published with () in 0.8s build + 3.1s test
MISSED   src/olm/account/mod.rs:289:9: replace Account::stored_one_time_key_count -> usize with 1 in 1.0s build + 3.0s test
MISSED   src/olm/account/mod.rs:334:9: replace Account::forget_fallback_key -> bool with true in 0.8s build + 3.3s test
MISSED   src/olm/account/mod.rs:334:9: replace Account::forget_fallback_key -> bool with false in 1.0s build + 3.0s test
MISSED   src/olm/account/mod.rs:289:9: replace Account::stored_one_time_key_count -> usize with 0 in 0.8s build + 2.9s test
MISSED   src/olm/account/mod.rs:339:9: replace Account::mark_keys_as_published with () in 1.0s build + 3.9s test
MISSED   src/olm/account/mod.rs:551:25: replace += with *= in libolm::<impl Encode for FallbackKeysArray>::encode in 1.1s build + 3.2s test
MISSED   src/olm/account/mod.rs:552:25: replace += with -= in libolm::<impl Encode for FallbackKeysArray>::encode in 0.9s build + 3.1s test
MISSED   src/olm/account/mod.rs:201:9: replace Account::remove_one_time_key -> Option<Curve25519SecretKey> with None in 1.0s build + 3.1s test
MISSED   src/olm/account/mod.rs:152:9: replace Account::max_number_of_one_time_keys -> usize with 0 in 0.8s build + 2.9s test
MISSED   src/olm/account/mod.rs:201:9: replace Account::remove_one_time_key -> Option<Curve25519SecretKey> with Some(Default::default()) in 0.9s build + 2.9s test
MISSED   src/olm/account/mod.rs:152:9: replace Account::max_number_of_one_time_keys -> usize with 1 in 0.8s build + 3.0s test
MISSED   src/olm/account/mod.rs:545:25: replace += with *= in libolm::<impl Encode for FallbackKeysArray>::encode in 1.0s build + 3.1s test
MISSED   src/olm/account/mod.rs:552:25: replace += with *= in libolm::<impl Encode for FallbackKeysArray>::encode in 0.9s build + 3.0s test
MISSED   src/olm/account/mod.rs:419:9: replace Account::from_decrypted_libolm_pickle -> Result<Self, crate::LibolmPickleError> with Ok(Default::default()) in 1.1s build + 2.6s test
MISSED   src/olm/account/mod.rs:551:25: replace += with -= in libolm::<impl Encode for FallbackKeysArray>::encode in 1.0s build + 3.2s test

Relates to: #78

@@ -690,6 +694,49 @@ mod test {

const PICKLE_KEY: [u8; 32] = [0u8; 32];

#[test]
fn max_number_of_one_time_keys_matches_global_constant() {
assert_eq!(Account::new().max_number_of_one_time_keys(), PUBLIC_MAX_ONE_TIME_KEYS);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is slightly silly but I'm not sure how else to fix this miss:

MISSED   src/olm/account/mod.rs:152:9: replace Account::max_number_of_one_time_keys -> usize with 0 in 0.8s build + 2.9s test

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that's fine, it's a simple getter, those will always require kinda dumb tests.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.35%. Comparing base (cefd49c) to head (cda3528).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #138      +/-   ##
==========================================
+ Coverage   87.68%   88.35%   +0.67%     
==========================================
  Files          32       32              
  Lines        1786     1786              
==========================================
+ Hits         1566     1578      +12     
+ Misses        220      208      -12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Johennes Johennes marked this pull request as draft March 25, 2024 13:54
Relates to: matrix-org#78

Signed-off-by: Johannes Marbach <[email protected]>
@Johennes Johennes force-pushed the johannes/olm-account-mutation-tests branch from cda3528 to 9aa9e47 Compare March 25, 2024 14:05
@Johennes Johennes marked this pull request as ready for review March 25, 2024 14:06
@Johennes Johennes mentioned this pull request Mar 25, 2024
2 tasks
Copy link
Collaborator

@poljar poljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Looking good.

@@ -690,6 +694,49 @@ mod test {

const PICKLE_KEY: [u8; 32] = [0u8; 32];

#[test]
fn max_number_of_one_time_keys_matches_global_constant() {
assert_eq!(Account::new().max_number_of_one_time_keys(), PUBLIC_MAX_ONE_TIME_KEYS);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that's fine, it's a simple getter, those will always require kinda dumb tests.

@poljar poljar merged commit 4e51951 into matrix-org:main Mar 26, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants