Skip to content

Commit

Permalink
review_comment: Use named constants for event and device times
Browse files Browse the repository at this point in the history
  • Loading branch information
andybalaam committed Dec 2, 2024
1 parent 94d60a0 commit 5db4563
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions crates/matrix-sdk-crypto/src/types/events/utd_cause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ mod tests {

use crate::types::events::{utd_cause::CryptoContextInfo, UtdCause};

const EVENT_TIME: usize = 5555;
const BEFORE_EVENT_TIME: usize = 1111;
const AFTER_EVENT_TIME: usize = 9999;

#[test]
fn test_if_there_is_no_membership_info_we_guess_unknown() {
// If our JSON contains no membership info, then we guess the UTD is unknown.
Expand Down Expand Up @@ -380,7 +384,7 @@ mod tests {
"session_id": "A0",
},
"sender": "@bob:localhost",
"origin_server_ts": 5555,
"origin_server_ts": EVENT_TIME,
"unsigned": { "membership": "join" }
}))
}
Expand All @@ -391,28 +395,28 @@ mod tests {

fn device_old_no_backup() -> CryptoContextInfo {
CryptoContextInfo {
device_creation_ts: MilliSecondsSinceUnixEpoch((1111).try_into().unwrap()),
device_creation_ts: MilliSecondsSinceUnixEpoch((BEFORE_EVENT_TIME).try_into().unwrap()),
is_backup_configured: false,
}
}

fn device_old_with_backup() -> CryptoContextInfo {
CryptoContextInfo {
device_creation_ts: MilliSecondsSinceUnixEpoch((1111).try_into().unwrap()),
device_creation_ts: MilliSecondsSinceUnixEpoch((BEFORE_EVENT_TIME).try_into().unwrap()),
is_backup_configured: true,
}
}

fn device_new_no_backup() -> CryptoContextInfo {
CryptoContextInfo {
device_creation_ts: MilliSecondsSinceUnixEpoch((9999).try_into().unwrap()),
device_creation_ts: MilliSecondsSinceUnixEpoch((AFTER_EVENT_TIME).try_into().unwrap()),
is_backup_configured: false,
}
}

fn device_new_with_backup() -> CryptoContextInfo {
CryptoContextInfo {
device_creation_ts: MilliSecondsSinceUnixEpoch((9999).try_into().unwrap()),
device_creation_ts: MilliSecondsSinceUnixEpoch((AFTER_EVENT_TIME).try_into().unwrap()),
is_backup_configured: true,
}
}
Expand Down

0 comments on commit 5db4563

Please sign in to comment.