Skip to content

Commit 1c5f302

Browse files
committed
crypto: Test for plain JSON and typed deserialization
1 parent 46b4d00 commit 1c5f302

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ 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;
292+
use serde_json::{self, Value};
293293
use vodozemac::olm::{OlmMessage, SessionConfig};
294294

295295
use crate::{
@@ -352,9 +352,16 @@ mod tests {
352352
)
353353
.unwrap();
354354

355-
// Also ensure that the encrypted payload has the device keys.
356-
let plaintext: DecryptedOlmV1Event<DummyEventContent> =
355+
// Also ensure that the encrypted payload has the device keys under the unstable prefix
356+
let plaintext: Value = serde_json::from_str(&bob_session_result.plaintext).unwrap();
357+
assert_eq!(
358+
plaintext["org.matrix.msc4147.device_keys"]["user_id"].as_str(),
359+
Some("@alice:localhost")
360+
);
361+
362+
// And the serialized object matches the format as specified in DecryptedOlmV1Event
363+
let event: DecryptedOlmV1Event<DummyEventContent> =
357364
serde_json::from_str(&bob_session_result.plaintext).unwrap();
358-
assert_eq!(plaintext.device_keys.unwrap(), alice.device_keys());
365+
assert_eq!(event.device_keys.unwrap(), alice.device_keys());
359366
}
360367
}

0 commit comments

Comments
 (0)