From 412fcab4dca6d9834c7285ddbe0d93d906059fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 7 Jan 2025 09:08:58 +0100 Subject: [PATCH] test: Await the device creation in the notification client redecryption test --- .../src/tests/timeline.rs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/testing/matrix-sdk-integration-testing/src/tests/timeline.rs b/testing/matrix-sdk-integration-testing/src/tests/timeline.rs index ebc049be64..70d11ddc8a 100644 --- a/testing/matrix-sdk-integration-testing/src/tests/timeline.rs +++ b/testing/matrix-sdk-integration-testing/src/tests/timeline.rs @@ -526,6 +526,13 @@ async fn test_room_keys_received_on_notification_client_trigger_redecryption() { .await .expect("We should be able to check that the room is encrypted")); + // Create stream listening for devices. + let devices_stream = alice + .encryption() + .devices_stream() + .await + .expect("We should be able to listen to the devices stream"); + // Now here comes bob. let bob = TestClientBuilder::new("bob").use_sqlite().build().await.unwrap(); bob.encryption().wait_for_e2ee_initialization_tasks().await; @@ -569,6 +576,21 @@ async fn test_room_keys_received_on_notification_client_trigger_redecryption() { assert_eq!(bob_room.state(), RoomState::Joined); assert!(bob_room.is_encrypted().await.unwrap()); + // Now we need to wait for Bob's device to turn up. + let wait_for_bob_device = async { + pin_mut!(devices_stream); + + while let Some(devices) = devices_stream.next().await { + if devices.new.contains_key(bob.user_id().unwrap()) { + break; + } + } + }; + + timeout(Duration::from_secs(5), wait_for_bob_device) + .await + .expect("We should be able to load the room list"); + // Let's stop the sync so we don't receive the room key using the usual channel. sync_service.stop().await.expect("We should be able to stop the sync service");