Skip to content

Commit

Permalink
test: Await the device creation in the notification client redecrypti…
Browse files Browse the repository at this point in the history
…on test
  • Loading branch information
poljar committed Jan 7, 2025
1 parent 8e75a94 commit 412fcab
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions testing/matrix-sdk-integration-testing/src/tests/timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit 412fcab

Please sign in to comment.