Skip to content

Commit

Permalink
test: make `test_room_keys_received_on_notification_client_trigger_re…
Browse files Browse the repository at this point in the history
…decryption` more stable

When starting to back-paginate, in this test, we:

- either have a previous-batch token, that points to the first event
*before* the message was sent,
- or have no previous-batch token, because we stopped sync before
receiving the first sync result.

Because of the behavior introduced in 944a922, we don't restart
back-paginating from the end, if we've reached the start. Now, if we are
in the case described by the first bullet item, then we may backpaginate
until the start of the room, and stop then, because we've back-paginated
all events. And so we'll never see the message sent by Alice after we
stopped sync'ing.

One solution to get to the desired state is to clear the internal state
of the room event cache, thus deleting the previous-batch token, thus
causing the situation described in the second bullet item. This achieves
what we want, that is, back-paginating from the end of the timeline.
  • Loading branch information
bnjbvr committed Dec 18, 2024
1 parent abb657c commit 47193f1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions testing/matrix-sdk-integration-testing/src/tests/timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,12 +558,18 @@ async fn test_room_keys_received_on_notification_client_trigger_redecryption() {
alice_sync.abort();

// Let's get the timeline and backpaginate to load the event.
let mut timeline =
let timeline =
bob_room.timeline().await.expect("We should be able to get a timeline for our room");

let mut item = None;

for _ in 0..10 {
{
// Clear any previously received previous-batch token.
let (room_event_cache, _drop_handles) = bob_room.event_cache().await.unwrap();
room_event_cache.clear().await.unwrap();
}

timeline
.paginate_backwards(50)
.await
Expand All @@ -572,10 +578,9 @@ async fn test_room_keys_received_on_notification_client_trigger_redecryption() {
if let Some(timeline_item) = timeline.item_by_event_id(&event_id).await {
item = Some(timeline_item);
break;
} else {
timeline = bob_room.timeline().await.expect("We should be able to reset our timeline");
sleep(Duration::from_millis(100)).await
}

sleep(Duration::from_millis(100)).await
}

let item = item.expect("The event should be in the timeline by now");
Expand Down

0 comments on commit 47193f1

Please sign in to comment.