diff --git a/testing/matrix-sdk-test/src/lib.rs b/testing/matrix-sdk-test/src/lib.rs index 25c2d7244..938cbea2e 100644 --- a/testing/matrix-sdk-test/src/lib.rs +++ b/testing/matrix-sdk-test/src/lib.rs @@ -5,12 +5,9 @@ pub use matrix_sdk_test_macros::async_test; use once_cell::sync::Lazy; use ruma::{ RoomId, UserId, - api::{ - IncomingResponse, OutgoingResponse, client::sync::sync_events::v3::Response as SyncResponse, - }, + api::{IncomingResponse, OutgoingResponse}, room_id, user_id, }; -use serde_json::Value as JsonValue; /// Create a `Raw` from arbitrary JSON. /// @@ -94,30 +91,6 @@ pub static CAROL: Lazy<&UserId> = Lazy::new(|| user_id!("@carol:other.server")); pub static DEFAULT_TEST_ROOM_ID: Lazy<&RoomId> = Lazy::new(|| room_id!("!SVkFJHzfwvuaIEawgC:localhost")); -/// Embedded sync response files -pub enum SyncResponseFile { - All, - Default, - DefaultWithSummary, - Invite, - Leave, - Voip, -} - -/// Get specific API responses for testing -pub fn sync_response(kind: SyncResponseFile) -> SyncResponse { - let data: &JsonValue = match kind { - SyncResponseFile::All => &test_json::MORE_SYNC, - SyncResponseFile::Default => &test_json::SYNC, - SyncResponseFile::DefaultWithSummary => &test_json::DEFAULT_SYNC_SUMMARY, - SyncResponseFile::Invite => &test_json::INVITE_SYNC, - SyncResponseFile::Leave => &test_json::LEAVE_SYNC, - SyncResponseFile::Voip => &test_json::VOIP_SYNC, - }; - - ruma_response_from_json(data) -} - /// Build a typed Ruma [`IncomingResponse`] object from a json body. pub fn ruma_response_from_json( json: &serde_json::Value, diff --git a/testing/matrix-sdk-test/src/test_json/mod.rs b/testing/matrix-sdk-test/src/test_json/mod.rs index 116af4334..dceac3683 100644 --- a/testing/matrix-sdk-test/src/test_json/mod.rs +++ b/testing/matrix-sdk-test/src/test_json/mod.rs @@ -25,8 +25,7 @@ pub use api_responses::{ }; pub use members::MEMBERS; pub use sync::{ - DEFAULT_SYNC_SUMMARY, INVITE_SYNC, JOIN_SPACE_SYNC, LEAVE_SYNC, LEAVE_SYNC_EVENT, MORE_SYNC, - MORE_SYNC_2, SYNC, VOIP_SYNC, + DEFAULT_SYNC_SUMMARY, INVITE_SYNC, JOIN_SPACE_SYNC, LEAVE_SYNC, LEAVE_SYNC_EVENT, SYNC, }; pub use sync_events::{ ALIAS, ALIASES, ENCRYPTION, MEMBER, MEMBER_ADDITIONAL, MEMBER_BAN, MEMBER_INVITE, MEMBER_LEAVE, diff --git a/testing/matrix-sdk-test/src/test_json/sync.rs b/testing/matrix-sdk-test/src/test_json/sync.rs index 312b2962b..014a855c3 100644 --- a/testing/matrix-sdk-test/src/test_json/sync.rs +++ b/testing/matrix-sdk-test/src/test_json/sync.rs @@ -525,303 +525,6 @@ pub static DEFAULT_SYNC_SUMMARY: Lazy = Lazy::new(|| { }) }); -pub static MORE_SYNC: Lazy = Lazy::new(|| { - json!({ - "device_one_time_keys_count": {}, - "next_batch": "s526_47314_0_7_1_1_1_11444_2", - "device_lists": { - "changed": [ - "@example:example.org" - ], - "left": [] - }, - "rooms": { - "invite": {}, - "join": { - *DEFAULT_TEST_ROOM_ID: { - "summary": {}, - "account_data": { - "events": [] - }, - "ephemeral": { - "events": [ - { - "content": { - "$151680659217152dPKjd:localhost": { - "m.read": { - "@example:localhost": { - "ts": 151680989 - } - } - } - }, - "room_id": "!jEsUZKDJdhlrceRyVU:example.org", - "type": "m.receipt" - }, - { - "content": { - "user_ids": [ - "@alice:matrix.org", - "@bob:example.com" - ] - }, - "room_id": "!jEsUZKDJdhlrceRyVU:example.org", - "type": "m.typing" - } - ] - }, - "state": { - "events": [] - }, - "timeline": { - "events": [ - { - "content": { - "body": "baba", - "format": "org.matrix.custom.html", - "formatted_body": "baba", - "msgtype": "m.text" - }, - "event_id": "$152037280074GZeOm:localhost", - "origin_server_ts": 152037280000000_u64, - "sender": "@example:localhost", - "type": "m.room.message", - "unsigned": { - "age": 598971425 - } - }, - { - "content": { - "body": " * edited message", - "m.new_content": { - "body": "edited message", - "msgtype": "m.text" - }, - "m.relates_to": { - "event_id": "$someeventid:localhost", - "rel_type": "m.replace" - }, - "msgtype": "m.text" - }, - "event_id": "$editevid:localhost", - "origin_server_ts": 159026265000000_u64, - "sender": "@alice:matrix.org", - "type": "m.room.message", - "unsigned": { - "age": 85 - } - }, - { - "content": { - "reason": "😀" - }, - "event_id": "$151957878228ssqrJ:localhost", - "origin_server_ts": 151957878000000_u64, - "sender": "@example:localhost", - "type": "m.room.redaction", - "redacts": "$151957878228ssqrj:localhost", - "unsigned": { - "age": 85 - } - }, - { - "content": {}, - "event_id": "$15275046980maRLj:localhost", - "origin_server_ts": 152750469000000_u64, - "sender": "@example:localhost", - "type": "m.room.message", - "unsigned": { - "age": 19334, - "redacted_because": { - "content": {}, - "event_id": "$15275047031IXQRi:localhost", - "origin_server_ts": 152750470000000_u64, - "redacts": "$15275046980maRLj:localhost", - "sender": "@example:localhost", - "type": "m.room.redaction", - "unsigned": { - "age": 14523 - } - }, - "redacted_by": "$15275047031IXQRi:localhost" - } - }, - { - "content": { - "m.relates_to": { - "event_id": "$15275047031IXQRi:localhost", - "key": "👍", - "rel_type": "m.annotation" - } - }, - "event_id": "$15275047031IXQRi:localhost", - "origin_server_ts": 159027581000000_u64, - "sender": "@alice:matrix.org", - "type": "m.reaction", - "unsigned": { - "age": 85 - } - }, - { - "content": { - "body": "This is a notice", - "format": "org.matrix.custom.html", - "formatted_body": "This is a notice", - "msgtype": "m.notice" - }, - "event_id": "$098237280074GZeOm:localhost", - "origin_server_ts": 162037280000000_u64, - "sender": "@bot:localhost", - "type": "m.room.message", - "unsigned": { - "age": 25 - } - }, - ], - "limited": false, - "prev_batch": "t392-516_47314_0_7_1_1_1_11444_1" - }, - "unread_notifications": { - "highlight_count": 0, - "notification_count": 11 - } - } - }, - "leave": {} - }, - "to_device": { - "events": [] - }, - "presence": { - "events": [] - } - }) -}); - -pub static MORE_SYNC_2: Lazy = Lazy::new(|| { - json!({ - "next_batch": "s526_47314_0_7_1_1_1_11444_3", - "rooms": { - "join": { - *DEFAULT_TEST_ROOM_ID: { - "timeline": { - "events": [ - { - "content": { - "body": "baba", - "format": "org.matrix.custom.html", - "formatted_body": "baba", - "msgtype": "m.text" - }, - "event_id": "$152037280074GZeOm2:localhost", - "origin_server_ts": 152037280000000_u64, - "sender": "@example:localhost", - "type": "m.room.message", - "unsigned": { - "age": 598971425 - } - }, - { - "content": { - "body": " * edited message", - "m.new_content": { - "body": "edited message", - "msgtype": "m.text" - }, - "m.relates_to": { - "event_id": "$someeventid:localhost", - "rel_type": "m.replace" - }, - "msgtype": "m.text" - }, - "event_id": "$editevid2:localhost", - "origin_server_ts": 159026265000000_u64, - "sender": "@alice:matrix.org", - "type": "m.room.message", - "unsigned": { - "age": 85 - } - }, - { - "content": { - "reason": "😀" - }, - "event_id": "$151957878228ssqrJ2:localhost", - "origin_server_ts": 151957878000000_u64, - "sender": "@example:localhost", - "type": "m.room.redaction", - "redacts": "$151957878228ssqrj:localhost", - "unsigned": { - "age": 85 - } - }, - { - "content": {}, - "event_id": "$15275046980maRLj2:localhost", - "origin_server_ts": 152750469000000_u64, - "sender": "@example:localhost", - "type": "m.room.message", - "unsigned": { - "age": 19334, - "redacted_because": { - "content": {}, - "event_id": "$15275047031IXQRi:localhost", - "origin_server_ts": 152750470000000_u64, - "redacts": "$15275046980maRLj:localhost", - "sender": "@example:localhost", - "type": "m.room.redaction", - "unsigned": { - "age": 14523 - } - }, - "redacted_by": "$15275047031IXQRi:localhost" - } - }, - { - "content": { - "m.relates_to": { - "event_id": "$15275047031IXQRi:localhost", - "key": "👍", - "rel_type": "m.annotation" - } - }, - "event_id": "$15275047031IXQRi2:localhost", - "origin_server_ts": 159027581000000_u64, - "sender": "@alice:matrix.org", - "type": "m.reaction", - "unsigned": { - "age": 85 - } - }, - { - "content": { - "body": "This is a notice", - "format": "org.matrix.custom.html", - "formatted_body": "This is a notice", - "msgtype": "m.notice" - }, - "event_id": "$098237280074GZeOm2:localhost", - "origin_server_ts": 162037280000000_u64, - "sender": "@bot:localhost", - "type": "m.room.message", - "unsigned": { - "age": 25 - } - }, - ], - "limited": false, - "prev_batch": "s526_47314_0_7_1_1_1_11444_2" - }, - "unread_notifications": { - "highlight_count": 0, - "notification_count": 11 - } - } - }, - }, - }) -}); - pub static INVITE_SYNC: Lazy = Lazy::new(|| { json!({ "device_one_time_keys_count": {}, @@ -1695,126 +1398,6 @@ pub static MIXED_SYNC: Lazy = Lazy::new(|| { }) }); -pub static VOIP_SYNC: Lazy = Lazy::new(|| { - json!({ - "device_one_time_keys_count": {}, - "next_batch": "s526_47314_0_7_1_1_1_11444_1", - "device_lists": { - "changed": [ - "@example:example.org" - ], - "left": [] - }, - "rooms": { - "invite": {}, - "join": { - *DEFAULT_TEST_ROOM_ID: { - "summary": {}, - "account_data": { - "events": [] - }, - "ephemeral": { - "events": [ ] - }, - "state": { - "events": [] - }, - "timeline": { - "events": [ - { - "content": { - "call_id": "12345", - "lifetime": 60000, - "offer": { - "sdp": "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]", - "type": "offer" - }, - "version": 0 - }, - "event_id": "$143273582443PhrSn:example.org", - "origin_server_ts": 143273582000000_u64, - "room_id": "!jEsUZKDJdhlrceRyVU:example.org", - "sender": "@example:example.org", - "type": "m.call.invite", - "unsigned": { - "age": 1234 - } - }, - { - "content": { - "answer": { - "sdp": "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]", - "type": "answer" - }, - "call_id": "12345", - "lifetime": 60000, - "version": 0 - }, - "event_id": "$143273582443PhrSn:example.org", - "origin_server_ts": 143273582000000_u64, - "room_id": "!jEsUZKDJdhlrceRyVU:example.org", - "sender": "@example:example.org", - "type": "m.call.answer", - "unsigned": { - "age": 1234 - } - }, - { - "content": { - "call_id": "12345", - "candidates": [ - { - "candidate": "candidate:863018703 1 udp 2122260223 10.9.64.156 43670 type host generation 0", - "sdpMLineIndex": 0, - "sdpMid": "audio" - } - ], - "version": 0 - }, - "event_id": "$143273582443PhrSn:example.org", - "origin_server_ts": 143273582000000_u64, - "room_id": "!jEsUZKDJdhlrceRyVU:example.org", - "sender": "@example:example.org", - "type": "m.call.candidates", - "unsigned": { - "age": 1234 - } - }, - { - "content": { - "call_id": "12345", - "version": 0 - }, - "event_id": "$143273582443PhrSn:example.org", - "origin_server_ts": 143273582000000_u64, - "room_id": "!jEsUZKDJdhlrceRyVU:example.org", - "sender": "@example:example.org", - "type": "m.call.hangup", - "unsigned": { - "age": 1234 - } - } - ], - "limited": true, - "prev_batch": "t392-516_47314_0_7_1_1_1_11444_1" - }, - "unread_notifications": { - "highlight_count": 0, - "notification_count": 11 - } - } - }, - "leave": {} - }, - "to_device": { - "events": [] - }, - "presence": { - "events": [] - } - }) -}); - pub static SYNC_ADMIN_AND_MOD: Lazy = Lazy::new(|| { json!({ "device_one_time_keys_count": {},