Files
synapse/tests
Erik Johnston b552143b61 Port EventBase hierarchy to the Rust Event class
Replace the abstract `synapse.events.EventBase` and the concrete
`FrozenEvent`, `FrozenEventV2`, `FrozenEventV3`, `FrozenEventV4`, and
`FrozenEventVMSC4242` Python classes with a single Rust-backed
`Event`, exposed via `synapse.synapse_rust.events.Event`. `EventBase`
becomes a `TypeAlias` for `Event` so that the existing type annotations
across the codebase keep working.

Notable behavioural notes:

- `make_event_from_dict()` now constructs the Rust class. Event IDs for
  v3+ formats are computed in the constructor (instead of lazily on
  first access).
- `clone_event()` is now a single `event.deep_copy()` call. The old
  shallow copy of `unsigned` was effectively a deep copy in practice;
  `deep_copy()` matches that.
- `event.content` returns a Rust-backed `JsonObject` which is
  immutable and shared; callers that mutate the returned mapping must
  now first wrap it in `dict(...)`.
- The federation client gets a fresh `Event` per call site via
  `deep_copy()` instead of the old `copy.copy()` plus
  `internal_metadata.copy()` dance.
- The third-party event-rules callback no longer needs to call
  `event.freeze()` — Events are immutable from Python by construction.
- `assert isinstance(event, FrozenEventVMSC4242)` and the corresponding
  `cast`s introduced in the previous commit are dropped: the new
  `Event` exposes `prev_state_events` natively.
- A small `assert_never` is added in `events_worker.py` to make the
  `redact_behaviour` switch exhaustive now that the type checker can
  see all branches.

All test fixtures that constructed `FrozenEventV3` etc. directly are
updated to construct `Event` instead.
2026-05-12 13:08:44 +01:00
..
2026-05-08 14:19:03 +01:00
2026-05-08 14:19:03 +01:00