From 5dcd877dcdf60bd48ee45a8c73e3adf4130d407d Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 7 Jan 2026 10:56:29 +0100 Subject: [PATCH] test(ui): Sticky parameters have been removed. --- .../integration/encryption_sync_service.rs | 71 +++++++++++-------- .../tests/integration/room_list_service.rs | 27 +++++-- .../tests/integration/sliding_sync.rs | 5 +- crates/matrix-sdk/src/sliding_sync/mod.rs | 9 +-- 4 files changed, 72 insertions(+), 40 deletions(-) diff --git a/crates/matrix-sdk-ui/tests/integration/encryption_sync_service.rs b/crates/matrix-sdk-ui/tests/integration/encryption_sync_service.rs index c0a698245..30af36bc7 100644 --- a/crates/matrix-sdk-ui/tests/integration/encryption_sync_service.rs +++ b/crates/matrix-sdk-ui/tests/integration/encryption_sync_service.rs @@ -47,14 +47,14 @@ async fn test_smoke_encryption_sync_works() -> anyhow::Result<()> { // Requests enable the e2ee and to_device extensions on the first run. sliding_sync_then_assert_request_and_fake_response! { [server, stream] - assert request = { + assert request >= { "conn_id": "encryption", "extensions": { "e2ee": { - "enabled": true + "enabled": true, }, "to_device": { - "enabled": true + "enabled": true, } } }, @@ -64,33 +64,39 @@ async fn test_smoke_encryption_sync_works() -> anyhow::Result<()> { }; // The request then passes the `pos`ition marker to the next request, as usual - // in sliding sync. The extensions haven't changed, so they're not updated - // (sticky parameters ftw). + // in sliding sync. sliding_sync_then_assert_request_and_fake_response! { [server, stream] - assert request = { + assert request >= { "conn_id": "encryption", + "extensions": { + "e2ee": { + "enabled": true, + }, + "to_device": { + "enabled": true, + } + } }, respond with = { "pos": "1", "extensions": { "to_device": { - "next_batch": "nb0" + "next_batch": "nb0", } } }, }; // The to-device since token is passed from the previous request. - // The extensions haven't changed, so they're not updated (sticky parameters - // ftw). sliding_sync_then_assert_request_and_fake_response! { [server, stream] - assert request = { + assert request >= { "conn_id": "encryption", "extensions": { "to_device": { - "since": "nb0" + "enabled": true, + "since": "nb0", } } }, @@ -105,18 +111,15 @@ async fn test_smoke_encryption_sync_works() -> anyhow::Result<()> { }; // The to-device since token is passed from the previous request. - // The extensions haven't changed, so they're not updated (sticky parameters - // ftw)... in the first request. Then, the sliding sync instance will retry - // those requests, so it will include them again; as a matter of fact, the - // last request that we assert against will contain those. sliding_sync_then_assert_request_and_fake_response! { [server, stream] sync matches Some(Err(_)), - assert request = { + assert request >= { "conn_id": "encryption", "extensions": { "to_device": { - "since": "nb1" + "enabled": true, + "since": "nb1", } } }, @@ -134,15 +137,12 @@ async fn test_smoke_encryption_sync_works() -> anyhow::Result<()> { let stream = encryption_sync.sync(sync_permit_guard); pin_mut!(stream); - // The next request will contain sticky parameters again. + // The next request will contain extensions again. sliding_sync_then_assert_request_and_fake_response! { [server, stream] - assert request = { + assert request >= { "conn_id": "encryption", "extensions": { - "e2ee": { - "enabled": true - }, "to_device": { "enabled": true, "since": "nb1" @@ -219,8 +219,6 @@ async fn test_encryption_sync_two_fixed_iterations() -> anyhow::Result<()> { encryption_sync.run_fixed_iterations(2, sync_permit_guard).await?; - // First iteration fills the whole request. - // Second iteration only sends non-sticky parameters. let expected_requests = [ json!({ "conn_id": "encryption", @@ -235,6 +233,14 @@ async fn test_encryption_sync_two_fixed_iterations() -> anyhow::Result<()> { }), json!({ "conn_id": "encryption", + "extensions": { + "e2ee": { + "enabled": true + }, + "to_device": { + "enabled": true + } + } }), ]; @@ -280,14 +286,17 @@ async fn test_encryption_sync_always_reloads_todevice_token() -> anyhow::Result< }, }; - // Second iteration only sends non-sticky parameters, plus the to-device token - // from the previous request. + // Second iteration contains the to-device token from the previous request. sliding_sync_then_assert_request_and_fake_response! { [server, stream] assert request = { "conn_id": "encryption", "extensions": { + "e2ee": { + "enabled": true + }, "to_device": { + "enabled": true, "since": "nb0", }, } @@ -321,7 +330,11 @@ async fn test_encryption_sync_always_reloads_todevice_token() -> anyhow::Result< assert request = { "conn_id": "encryption", "extensions": { + "e2ee": { + "enabled": true + }, "to_device": { + "enabled": true, "since": "nb2", }, } @@ -453,7 +466,7 @@ async fn test_notification_client_does_not_upload_duplicate_one_time_keys() -> a sliding_sync_then_assert_request_and_fake_response! { [server, stream] - assert request = { + assert request >= { "conn_id": "encryption", "extensions": { "to_device": { @@ -504,7 +517,7 @@ async fn test_notification_client_does_not_upload_duplicate_one_time_keys() -> a sliding_sync_then_assert_request_and_fake_response! { [server, stream] - assert request = { + assert request >= { "conn_id": "encryption", "extensions": { "to_device": { @@ -529,7 +542,7 @@ async fn test_notification_client_does_not_upload_duplicate_one_time_keys() -> a sliding_sync_then_assert_request_and_fake_response! { [server, stream] - assert request = { + assert request >= { "conn_id": "encryption", "extensions": { "to_device": { diff --git a/crates/matrix-sdk-ui/tests/integration/room_list_service.rs b/crates/matrix-sdk-ui/tests/integration/room_list_service.rs index 82d0eeb95..7dddc47e7 100644 --- a/crates/matrix-sdk-ui/tests/integration/room_list_service.rs +++ b/crates/matrix-sdk-ui/tests/integration/room_list_service.rs @@ -417,7 +417,7 @@ async fn test_sync_all_states() -> Result<(), Error> { assert pos Some("0"), // Still no long-polling because the list isn't fully-loaded. assert timeout None, - assert request = { + assert request >= { "conn_id": "room-list", "lists": { ALL_ROOMS: { @@ -445,7 +445,7 @@ async fn test_sync_all_states() -> Result<(), Error> { assert pos Some("1"), // Still no long-polling because the list isn't fully-loaded. assert timeout None, - assert request = { + assert request >= { "conn_id": "room-list", "lists": { ALL_ROOMS: { @@ -474,7 +474,7 @@ async fn test_sync_all_states() -> Result<(), Error> { // Still no long-polling because the list isn't fully-loaded, // but it's about to be! assert timeout None, - assert request = { + assert request >= { "conn_id": "room-list", "lists": { ALL_ROOMS: { @@ -502,7 +502,7 @@ async fn test_sync_all_states() -> Result<(), Error> { assert pos Some("3"), // The list is fully-loaded, we can start long-polling. assert timeout Some(30000), - assert request = { + assert request >= { "conn_id": "room-list", "lists": { ALL_ROOMS: { @@ -2414,6 +2414,25 @@ async fn test_room_subscription() -> Result<(), Error> { "lists": { ALL_ROOMS: { "ranges": [[0, 2]], + "required_state": [ + ["m.room.name", ""], + ["m.room.encryption", ""], + ["m.room.member", "$LAZY"], + ["m.room.member", "$ME"], + ["m.room.topic", ""], + ["m.room.avatar", ""], + ["m.room.canonical_alias", ""], + ["m.room.power_levels", ""], + ["org.matrix.msc3401.call.member", "*"], + ["m.room.join_rules", ""], + ["m.room.tombstone", ""], + ["m.room.create", ""], + ["m.room.history_visibility", ""], + ["io.element.functional_members", ""], + ["m.space.parent", "*"], + ["m.space.child", "*"], + ], + "filters": {}, "timeline_limit": 1, }, }, diff --git a/crates/matrix-sdk-ui/tests/integration/sliding_sync.rs b/crates/matrix-sdk-ui/tests/integration/sliding_sync.rs index e31ccf3d7..81a10f989 100644 --- a/crates/matrix-sdk-ui/tests/integration/sliding_sync.rs +++ b/crates/matrix-sdk-ui/tests/integration/sliding_sync.rs @@ -27,7 +27,10 @@ pub(crate) async fn check_requests(server: MockServer, expected_requests: &[serd &expected_requests[num_requests], assert_json_diff::Config::new(assert_json_diff::CompareMode::Strict), ) { - panic!("{error}\n\njson_value = {json_value:?}"); + panic!( + "{error}\n\nexpected_requests[{num_requests}] = {expected_request}\n\njson_value = {json_value:?}", + expected_request = expected_requests[num_requests], + ); } num_requests += 1; diff --git a/crates/matrix-sdk/src/sliding_sync/mod.rs b/crates/matrix-sdk/src/sliding_sync/mod.rs index 44b90925b..866eeb6ca 100644 --- a/crates/matrix-sdk/src/sliding_sync/mod.rs +++ b/crates/matrix-sdk/src/sliding_sync/mod.rs @@ -498,8 +498,6 @@ impl SlidingSync { // Add extensions. request.extensions = self.inner.extensions.clone(); - // Extensions are now applied (via sticky parameters). - // // Override the to-device token if the extension is enabled. if to_device_enabled { request.extensions.to_device.since = @@ -723,7 +721,7 @@ impl SlidingSync { // Here, errors we **cannot** ignore, and that must stop the sync loop. Err(error) => { if error.client_api_error_kind() == Some(&ErrorKind::UnknownPos) { - // The Sliding Sync session has expired. Let's reset `pos` and sticky parameters. + // The Sliding Sync session has expired. Let's reset `pos`. self.expire_session().await; } @@ -755,8 +753,7 @@ impl SlidingSync { /// Expire the current Sliding Sync session on the client-side. /// - /// Expiring a Sliding Sync session means: resetting `pos`. It also resets - /// sticky parameters. + /// Expiring a Sliding Sync session means: resetting `pos`. /// /// This should only be used when it's clear that this session was about to /// expire anyways, and should be used only in very specific cases (e.g. @@ -766,7 +763,7 @@ impl SlidingSync { /// This method **MUST** be called when the sync loop is stopped. #[doc(hidden)] pub async fn expire_session(&self) { - info!("Session expired; resetting `pos` and sticky parameters"); + info!("Session expired; resetting `pos`"); { let lists = self.inner.lists.read().await;