Skip to content

Commit

Permalink
refactor(crypto) Fix test that will fail when we handle backups corre…
Browse files Browse the repository at this point in the history
…ctly

This test was checking that a new device which has access to backups
returned an unknown UTD when it was given empty JSON for the event. It
was only passing because we currently have incorrect behaviour when
backups are enabled.

The fix is to make the device old and without access to backups, so that
we still consider this UTD unexpected.
  • Loading branch information
andybalaam committed Nov 29, 2024
1 parent 16fa3cd commit 778dc5d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/matrix-sdk-crypto/src/types/events/utd_cause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ mod tests {
assert_eq!(
UtdCause::determine(
&raw_event(json!({})),
device_new_with_backup(),
device_old_no_backup(),
&missing_megolm_session()
),
UtdCause::Unknown
Expand Down Expand Up @@ -393,6 +393,13 @@ mod tests {
Raw::from_json(to_raw_value(&value).unwrap())
}

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

fn device_old_with_backup() -> CryptoContextInfo {
CryptoContextInfo {
device_creation_ts: MilliSecondsSinceUnixEpoch((1111).try_into().unwrap()),
Expand Down

0 comments on commit 778dc5d

Please sign in to comment.