Skip to content

Commit 46b4d00

Browse files
committed
crypto: Test device_keys can be deserialized from a to-device message
1 parent 6f80c45 commit 46b4d00

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

crates/matrix-sdk-crypto/src/olm/session.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,16 @@ mod tests {
289289
use assert_matches2::assert_let;
290290
use matrix_sdk_test::async_test;
291291
use ruma::{device_id, user_id};
292-
use serde_json::{self, Value};
292+
use serde_json;
293293
use vodozemac::olm::{OlmMessage, SessionConfig};
294294

295295
use crate::{
296-
identities::ReadOnlyDevice, olm::Account,
297-
types::events::room::encrypted::ToDeviceEncryptedEventContent,
296+
identities::ReadOnlyDevice,
297+
olm::Account,
298+
types::events::{
299+
dummy::DummyEventContent, olm_v1::DecryptedOlmV1Event,
300+
room::encrypted::ToDeviceEncryptedEventContent,
301+
},
298302
};
299303

300304
#[async_test]
@@ -349,10 +353,8 @@ mod tests {
349353
.unwrap();
350354

351355
// Also ensure that the encrypted payload has the device keys.
352-
let plaintext: Value = serde_json::from_str(&bob_session_result.plaintext).unwrap();
353-
assert_eq!(
354-
plaintext["org.matrix.msc4147.device_keys"]["user_id"].as_str(),
355-
Some("@alice:localhost")
356-
);
356+
let plaintext: DecryptedOlmV1Event<DummyEventContent> =
357+
serde_json::from_str(&bob_session_result.plaintext).unwrap();
358+
assert_eq!(plaintext.device_keys.unwrap(), alice.device_keys());
357359
}
358360
}

0 commit comments

Comments
 (0)