mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-04-24 17:18:23 -04:00
This patch rewrites the `test_delayed_decryption_latest_event` test a little bit. It does exactly the same things, but in a simpler way: it removes multiple `sleep` and remove 2 sliding sync loops. First off, the `SyncService` already starts the `RoomListService and the `EncryptionSync` service. Both of them have their own sliding sync loop. The test doesn't need other sliding sync loops in their own tasks, this is not necessary at all: it's just pretty confusing and doesn't reflect the reality, i.e. how these API are supposed to be used. Second, it also tests the room for Bob is seen as encrypted. Third, the `VectorDiff::Reset` is tested before the event from Bob is sent. It's not only for clarity: it makes the test more robust for future modifications. Fourth, instead of waiting with a `sleep` for the event from Bob to be received by Alice, we instead wait on the room list's stream of Alice to receive an update. It's more robust this way and reflects the real usage of this API. It also helps to remove an intermediate `assert_pending!` that is no longer necessary because we are waiting on the stream just after. Finally, just like for the previous modification, this patch removes another `sleep` for the to-device event from Bob to be received by Alice, and instead wait on the room list's stream to receive an update. It's again more robust and reflects the real usage of this API. Plus, it makes the last `assert_pending!` macro to not be flaky.