Skip to content

Commit

Permalink
add simple sync timeline event snapshot test
Browse files Browse the repository at this point in the history
  • Loading branch information
BillCarsonFr committed Dec 18, 2024
1 parent 172d4ab commit d331c7b
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
43 changes: 43 additions & 0 deletions crates/matrix-sdk-common/src/deserialized_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
});
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
}
}

0 comments on commit d331c7b

Please sign in to comment.