diff --git a/crates/matrix-sdk-common/src/deserialized_responses.rs b/crates/matrix-sdk-common/src/deserialized_responses.rs index 0e40127944..890f1645fc 100644 --- a/crates/matrix-sdk-common/src/deserialized_responses.rs +++ b/crates/matrix-sdk-common/src/deserialized_responses.rs @@ -1443,4 +1443,47 @@ mod tests { } }); } + + #[test] + fn snapshot_test_sync_timeline_event() { + let room_event = SyncTimelineEvent { + kind: TimelineEventKind::Decrypted(DecryptedRoomEvent { + event: Raw::new(&example_event()).unwrap().cast(), + encryption_info: EncryptionInfo { + sender: user_id!("@sender:example.com").to_owned(), + sender_device: Some(device_id!("ABCDEFGHIJ").to_owned()), + algorithm_info: AlgorithmInfo::MegolmV1AesSha2 { + curve25519_key: "xxx".to_owned(), + sender_claimed_keys: BTreeMap::from([ + ( + DeviceKeyAlgorithm::Ed25519, + "I3YsPwqMZQXHkSQbjFNEs7b529uac2xBpI83eN3LUXo".to_owned(), + ), + ( + DeviceKeyAlgorithm::Curve25519, + "qzdW3F5IMPFl0HQgz5w/L5Oi/npKUFn8Um84acIHfPY".to_owned(), + ), + ]), + }, + verification_state: VerificationState::Verified, + }, + unsigned_encryption_info: Some(BTreeMap::from([( + UnsignedEventLocation::RelationsThreadLatestEvent, + UnsignedDecryptionResult::UnableToDecrypt(UnableToDecryptInfo { + session_id: Some("xyz".to_owned()), + reason: UnableToDecryptReason::MissingMegolmSession { + withheld_code: Some(WithheldCode::Unverified), + }, + }), + )])), + }), + push_actions: Default::default(), + }; + + with_settings!({sort_maps =>true}, { + assert_json_snapshot! { + serde_json::to_value(&room_event).unwrap(), + } + }); + } } diff --git a/crates/matrix-sdk-common/src/snapshots/matrix_sdk_common__deserialized_responses__tests__snapshot_test_sync_timeline_event.snap b/crates/matrix-sdk-common/src/snapshots/matrix_sdk_common__deserialized_responses__tests__snapshot_test_sync_timeline_event.snap new file mode 100644 index 0000000000..f40882141c --- /dev/null +++ b/crates/matrix-sdk-common/src/snapshots/matrix_sdk_common__deserialized_responses__tests__snapshot_test_sync_timeline_event.snap @@ -0,0 +1,47 @@ +--- +source: crates/matrix-sdk-common/src/deserialized_responses.rs +expression: "serde_json::to_value(&room_event).unwrap()" +--- +{ + "kind": { + "Decrypted": { + "encryption_info": { + "algorithm_info": { + "MegolmV1AesSha2": { + "curve25519_key": "xxx", + "sender_claimed_keys": { + "curve25519": "qzdW3F5IMPFl0HQgz5w/L5Oi/npKUFn8Um84acIHfPY", + "ed25519": "I3YsPwqMZQXHkSQbjFNEs7b529uac2xBpI83eN3LUXo" + } + } + }, + "sender": "@sender:example.com", + "sender_device": "ABCDEFGHIJ", + "verification_state": "Verified" + }, + "event": { + "content": { + "body": "secret", + "msgtype": "m.text" + }, + "event_id": "$xxxxx:example.org", + "origin_server_ts": 2189, + "room_id": "!someroom:example.com", + "sender": "@carl:example.com", + "type": "m.room.message" + }, + "unsigned_encryption_info": { + "RelationsThreadLatestEvent": { + "UnableToDecrypt": { + "reason": { + "MissingMegolmSession": { + "withheld_code": "m.unverified" + } + }, + "session_id": "xyz" + } + } + } + } + } +}