From 778dc5d9741b5d8e6d1ae672fbd3d66ad4c0f216 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 29 Nov 2024 10:30:07 +0000 Subject: [PATCH] refactor(crypto) Fix test that will fail when we handle backups correctly 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. --- crates/matrix-sdk-crypto/src/types/events/utd_cause.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/matrix-sdk-crypto/src/types/events/utd_cause.rs b/crates/matrix-sdk-crypto/src/types/events/utd_cause.rs index 55ca4e0f22a..b88a7898cda 100644 --- a/crates/matrix-sdk-crypto/src/types/events/utd_cause.rs +++ b/crates/matrix-sdk-crypto/src/types/events/utd_cause.rs @@ -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 @@ -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()),