Commit Graph

8554 Commits

Author SHA1 Message Date
Ivan Enderlin
a623215257 chore(sdk): Make Clippy happy. 2024-03-27 09:32:33 +01:00
Ivan Enderlin
f61de718b8 fix(sdk): Fix a race-condition in EventCache.
This patch ensures that operations on `RoomEvents` happen in one block,
by sharing the same lock.

2 new methods are created: `replace_all_events_by` and
`append_new_events`.
2024-03-27 09:32:33 +01:00
Ivan Enderlin
fa5bbadf57 doc(sdk): Just highlight how important this lock is. 2024-03-27 09:32:15 +01:00
Ivan Enderlin
9319f4fcff test(sdk): Fix test_reset_while_backpaginating.
The test `test_reset_while_backpaginating` was expecting a
race-condition, which no longer exists. It first initially tried to
assert a workaround about this race-condition. It doesn't hold anymore.
Rewrite the test to assert the (correct) new behaviour.
2024-03-27 09:32:15 +01:00
Ivan Enderlin
25fb9ee47d feat(sdk): Update RoomEvents::replace_gap_at to return a &Chunk. 2024-03-27 09:32:15 +01:00
Ivan Enderlin
85538dc3ed feat(sdk): Remove EventCacheStore, TimelineEntry, RoomInfo and MemoryStore. 2024-03-27 09:23:51 +01:00
Ivan Enderlin
5bb2511914 test(sdk): Tests of EventCache uses RoomEvents. 2024-03-27 09:23:25 +01:00
Ivan Enderlin
667ada88e6 feat(sdk): RoomEventCache::subscribe uses RoomEvents. 2024-03-27 09:23:05 +01:00
Ivan Enderlin
022b8a0f38 feat(sdk): EventCache::listen_task uses RoomEvents. 2024-03-27 09:22:43 +01:00
Ivan Enderlin
29caa02ef0 feat(sdk): EventCache::add_initial_events uses RoomEvents. 2024-03-27 09:22:13 +01:00
Ivan Enderlin
9102a9c841 feat(sdk): RoomEventCachecacherInner::oldest_backpagination_token uses RoomEvents. 2024-03-27 09:21:05 +01:00
Ivan Enderlin
54729ce32b feat(sdk): Start disabling the global store in EventCache. 2024-03-27 09:11:15 +01:00
Ivan Enderlin
36e199c31e feat(sdk): Implement RoomEvents::reset, push_gap, replace_gap_at and events.
This patch implements the following wrapper methods (over
`LinkedChunk`): `push_gap`, `replace_gap_at` and `events`. This patch
also implements the `reset` method that clears/drops all chunks in the
`LinkedChunk`.
2024-03-27 09:07:52 +01:00
Richard van der Hoff
ab9e4f73b1 crypto: Add OlmMachine::device_creation_time (#3275)
Turns out this is useful for https://github.com/element-hq/element-meta/issues/2313.
2024-03-26 15:13:55 +00:00
Benjamin Bouvier
ce7143b833 integration tests: rewrite test_toggling_reaction so it syncs in the background 2024-03-25 18:03:18 +01:00
Benjamin Bouvier
9480450410 integration tests: attempt to fix test_toggling_reaction
There was a message sent, *then* an attempt to wait for the remote echo later. It's not ideal, because if the time setting up the waiting is high enough, and the server is fast
enough, the remote echo could come *before* we started waiting for it, resulting in timeouts. This fixes it by spawning the waiting task first, and then only sending the message.
Let's see how this helps with this test.
2024-03-25 18:03:18 +01:00
Benjamin Bouvier
4744a994b4 integration tests: enhance testing of test_room_notification_count
This adds additional checks for each room updates, and works around a few race conditions, notably one where the server would send a remote echo for a message, but not update the
computed unread_notification_counts immediately. This tends to make the test more stable, in that each response is well known and now properly tested.
2024-03-25 18:03:18 +01:00
Benjamin Bouvier
1fd5b34fd0 ci: add more logs for test_toggling_reaction 2024-03-25 18:03:18 +01:00
Benjamin Bouvier
1255027d6e git: ignore the code coverage report from the output 2024-03-25 18:03:18 +01:00
Benjamin Bouvier
baac38fec5 day dividers: add test for redundant day divider before a read marker 2024-03-25 14:48:07 +01:00
Benjamin Bouvier
94c0322fbe day dividers: soften assertions
It's not worth panic'ing the whole timeline because we removed the wrong item; worst case, users will complain and can send a rageshake that contains all the information that's
needed to debug what went wrong.
2024-03-25 14:48:07 +01:00
Benjamin Bouvier
e9a4389a12 day dividers: don't assume the previous item is at the immediate previous position
There could be situations where we have a day divider, then a read marker, then an event. In that case, when looking at the event, if the previous day divider is wrong and needs
to be removed, we would assume the "previous item" (= the day divider) was at position i-1, which could be that of the read marker, and we'd remove the read marker instead of the
day divider.
2024-03-25 14:48:07 +01:00
Andy Balaam
67615fec3a Merge pull request #3252 from matrix-org/andybalaam/run-integration-tests-for-memorystore
crypto: Run the crypto integration tests against MemoryStore
2024-03-25 12:23:52 +00:00
Thomas
95a471b0d2 ffi: Expose discovered sliding sync proxy URL (#3266)
Closes #3265.

There is currently no way to get the URL of a homeserver's sliding sync proxy before logging in on the homeserver.

I suggest exposing the URL via the `HomeserverLoginDetail` struct after configuring the homeserver (through `configure_homeserver`).

Since the homeserver may not declare a corresponding sliding sync proxy, this value is an `Optional`. It is used later in `configure_homeserver` to check if a sliding sync proxy exists and throws an error otherwise. Previously, this check was done against the client's `discovered_sliding_sync_proxy` function.

- [ ] Public API changes documented in changelogs (optional)

Signed-off-by: Thomas Völkl <thomas@vollkorntomate.de>
Signed-off-by: Benjamin Bouvier <public@benj.me>
Co-authored-by: Benjamin Bouvier <public@benj.me>
2024-03-22 17:21:24 +00:00
Benjamin Bouvier
56f4b3e70e day divider: don't assume events have event id
Local echoes (which haven't received a remote echo yet) can have no event id, so when computing the report, don't unwrap the event id but use a sensible
default instead.

Also tweaks comments from a previous version of another PR. And rename `DayDividerAdjuster::maybe_adjust_day_dividers` to `run`.
2024-03-22 17:00:33 +01:00
Benjamin Bouvier
6aee1f62bd day divider: make it impossible to handle an event without adjusting day dividers (#3267)
The previous API relied on the callers not forgetting about adjusting day dividers after handling an event.

This makes it statically impossible, by requiring that `TimelineEventHandler` takes a `&mut DayDividerAdjuster` when operating, that it marks as not "consumed". Later, the caller must call `DayDividerAdjuster::maybe_adjust_day_dividers()`, to mark it as consumed. When dropping, we check that it's been consumed, otherwise we panic — as it's a developer error to not call `maybe_adjust_day_dividers()`.
2024-03-22 12:14:28 +00:00
Hubert Chathi
8d968604e9 chore: Update Ruma to version that uses web-time crate (#3264) 2024-03-22 12:30:19 +01:00
Andy Balaam
3a7b8fc6a5 crypto: Run the crypto integration tests against MemoryStore 2024-03-22 09:58:13 +00:00
Andy Balaam
7de5d295b6 crypto: Enable testing module in test mode 2024-03-22 09:58:13 +00:00
Andy Balaam
6b394d96bd crypto: Formatting for integration_tests 2024-03-22 09:58:13 +00:00
Richard van der Hoff
97959bbcd0 crypto: Log details about olm session after encryption/decryption (#3242) 2024-03-22 09:43:35 +00:00
Benjamin Bouvier
2883685bcc day divider: adjust instrument macro
also fix two "date dividers" instances
2024-03-22 10:24:57 +01:00
Benjamin Bouvier
eef61f87c1 day divider: move code to a new file
Only code motion, no changes in functionality.
2024-03-22 10:24:57 +01:00
Benjamin Bouvier
2c9a088a36 day divider: add test for duplicate date header after matching two local echoes
I checked that the test failed on main, by causing a final state of [DD First DD Second].

Fixes #2590.
2024-03-22 10:24:57 +01:00
Benjamin Bouvier
8912761eb7 day divider algorithm: address review comments
Notably, split the code into smaller functions, and revamp the high-level signatures so the individual handle_ functions don't take a bazillion arguments.
2024-03-22 10:24:57 +01:00
Benjamin Bouvier
3323f37efc day divider: beef up the reports
The reports now include the final state as well as the set of operations to run, so we can really debug all the steps just from looking at a rageshake.
2024-03-22 10:24:57 +01:00
Benjamin Bouvier
515aaf0a8a day divider: fix offset computation
When we're removing or inserting any day divider, we're also updating the offset, so that subsequent operations happen at the right positions.
The previous code made the error to clamp the offset when assigning it, instead of letting it be "out of bounds" and clamping the uses, which is
the correct way to implement this.
2024-03-22 10:24:57 +01:00
Benjamin Bouvier
c172ad9191 day divider: only warn if some invariants are broken, in non-debug mode 2024-03-22 10:24:57 +01:00
Benjamin Bouvier
601dce76ef timeline: add instrumentation for the maybe_adjust_day_dividers function 2024-03-22 10:24:57 +01:00
Benjamin Bouvier
f704066fbe timeline: group updates of the day dividers when multiple events are added at the same time 2024-03-22 10:24:57 +01:00
Benjamin Bouvier
b8174c437f timeline: move the day divider adjusting code into its own data structure 2024-03-22 10:24:57 +01:00
Benjamin Bouvier
a7cda30f6a timeline: use push_{front,back} semantics for both messages and day dividers 2024-03-22 10:24:57 +01:00
Benjamin Bouvier
88cd2557f3 timeline: rework the day divider separation as a post-processing algorithm 2024-03-22 10:24:57 +01:00
Benjamin Bouvier
bd33c336e7 tests: try bumping the timeout duration in test_room_notification_count
The test has been failing with a timeout recently, several time. Let's see if it was a fluke caused by the low threshold (because the server might be
busy handling other requests from other tests), or an actual issue.
2024-03-21 20:15:05 +01:00
Richard van der Hoff
82bcf48c88 Enable debuginfo for tarpaulin builds
It appears that tarpaulin complains if the symbol information is stripped from
the binary, and as of Rust 1.77, `debug=0` causes Cargo to strip all debug
info.

To fix this, set `debug=1`.
2024-03-21 17:46:30 +01:00
Ivan Enderlin
daaf17198c Merge pull request #3257 from Hywan/fix-issue-3213
doc(crypto-ffi): `Device::first_time_seen_ts` has an incorrect unit
2024-03-21 16:24:03 +01:00
Andy Balaam
fe39ca47d6 Merge pull request #3223 from matrix-org/andybalaam/adjust-integration-tests
crypto: Refactor integration tests in preparation for them running against MemoryStore
2024-03-21 13:15:45 +00:00
Ivan Enderlin
f42c8937da feat(sdk): Improve ChunkIdentifierGenerator
feat(sdk): Improve `ChunkIdentifierGenerator`
2024-03-21 12:56:16 +01:00
Ivan Enderlin
199275ff89 feat(sdk): Rename ChunkIdentifierGenerator::generate_next to next.
This patch renames `ChunkIdentifierGenerator::generate_next` to `next.

This patch also simplifies a `.saturating_add(1)` to a simple `+ 1`,
which is fine because we have checked for overflow just before.
2024-03-21 12:39:18 +01:00
Ivan Enderlin
7df31406dc feat(bindings): added join room by id to ffi
feat(bindings): added join room by id to ffi
2024-03-21 12:18:33 +01:00