From 248fff370ab3778042aee63bc63a7acdcd0cb9bf Mon Sep 17 00:00:00 2001 From: Amanda Graven Date: Mon, 16 May 2022 10:04:10 +0200 Subject: [PATCH] test(base): Remove invalid sync event from json The test json used for mocking a sync response contained an ill-formed event with a room_id key present in the event. Since the deserialization ignores the room_id key, this resulted in the client's membership state evaluating to left going by the contents of the state events, despite the room being in the "joined" section of the sync response. This is a violation of the spec. --- crates/matrix-sdk-test/src/test_json/sync.rs | 24 -------------------- crates/matrix-sdk/src/client/mod.rs | 2 +- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/crates/matrix-sdk-test/src/test_json/sync.rs b/crates/matrix-sdk-test/src/test_json/sync.rs index 842f6ac01..265534359 100644 --- a/crates/matrix-sdk-test/src/test_json/sync.rs +++ b/crates/matrix-sdk-test/src/test_json/sync.rs @@ -210,30 +210,6 @@ pub static SYNC: Lazy = Lazy::new(|| { "replaces_state": "$152034819067QWJxM:localhost" } }, - { - "content": { - "membership": "leave", - "reason": "offline", - "avatar_url": "mxc://avatar.com/d0dV9jLpe", - "displayname": "example" - }, - "event_id": "$1585345508297748AIUBh:matrix.org", - "origin_server_ts": 158534550, - "sender": "@example:localhost", - "state_key": "@example:localhost", - "type": "m.room.member", - "unsigned": { - "replaces_state": "$1585345354296486IGZfp:localhost", - "prev_content": { - "avatar_url": "mxc://avatar.com/d0dV9jLpe", - "displayname": "example", - "membership": "join" - }, - "prev_sender": "@example2:localhost", - "age": 6992 - }, - "room_id": "!roomid:room.com" - } ] }, "timeline": { diff --git a/crates/matrix-sdk/src/client/mod.rs b/crates/matrix-sdk/src/client/mod.rs index 06125ad5d..4fd1a8fe9 100644 --- a/crates/matrix-sdk/src/client/mod.rs +++ b/crates/matrix-sdk/src/client/mod.rs @@ -3362,7 +3362,7 @@ pub(crate) mod tests { let room = client.get_joined_room(room_id!("!SVkFJHzfwvuaIEawgC:localhost")).unwrap(); let members: Vec = room.active_members().await.unwrap(); - assert_eq!(1, members.len()); + assert_eq!(2, members.len()); // assert!(room.power_levels.is_some()) }