matrix-org / matrix-org/matrix-rust-sdk
Integration tests assume single-`sync_once()` state transitions causing flakes against any homeserver that batches differently than Synapse
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 500
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 106
Description
`test_mutual_sas_verification` and `test_mutual_qrcode_verification` (in `testing/matrix-sdk-integration-testing/src/tests/e2ee/mod.rs`) assert that each step of the SAS/QR verification dance becomes observable after exactly one call to `SyncTokenAwareClient::sync_once()`. That helper uses a 1-second long-poll timeout (`testing/matrix-sdk-integration-testing/src/helpers.rs:228`). The assertion pattern looks like:
```rust
bob_sas.accept().await?;
assert_matches!(bob_sas.state(), SasState::Accepted { .. });
alice.sync_once().await?;
assert_matches!(alice_sas.state(), SasState::Accepted { .. });
```
There is no retry loop and no `wait_until_some`. A single sync round-trip is expected to deliver every state transition.
This bakes a Synapse-specific timing assumption into the test contract: that whenever a peer commits a verification event, the receiver's very next `/sync` (within a 1s long-poll) will return that event AND any to-device prerequisites (e.g. `m.room_key`) needed to decrypt it AND the SDK will have time to process them and emit the state transition before `sync_once()` returns.
Whether they land in the same `/sync` response on the receiver depends on commit ordering, watcher/notify semantics, and whether the receiver's long-poll happens to wake between the two writes. The Matrix spec does not require atomicity between these.
The contract that should be tested is: "after the peer sends action X and we drive the client (sync, process events, send replies, etc.) for some bounded time, the verification state machine reaches state Y."
The contract that should *not* be tested is: "exactly one sync round-trip suffices."
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with test_mutual_sas_verification and test_mutual_qrcode_verification in testing/matrix-sdk-integration-testing/src/tests/e2ee/mod.rs, then inspect SyncTokenAwareClient::sync_once in testing/matrix-sdk-integration-testing/src/helpers.rs:228. Run the integration tests and trace the verification state transitions across sync processing. Done means both tests tolerate bounded asynchronous delivery and reliably reach their expected states without requiring exactly one sync round-trip.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100