synapse/tests/handlers
Richard van der Hoff 85551b7a85
Factor out common code for persisting fetched auth events (#10896)
* Factor more stuff out of `_get_events_and_persist`

It turns out that the event-sorting algorithm in `_get_events_and_persist` is
also useful in other circumstances. Here we move the current
`_auth_and_persist_fetched_events` to `_auth_and_persist_fetched_events_inner`,
and then factor the sorting part out to `_auth_and_persist_fetched_events`.

* `_get_remote_auth_chain_for_event`: remove redundant `outlier` assignment

`get_event_auth` returns events with the outlier flag already set, so this is
redundant (though we need to update a test where `get_event_auth` is mocked).

* `_get_remote_auth_chain_for_event`: move existing-event tests earlier

Move a couple of tests outside the loop. This is a bit inefficient for now, but
a future commit will make it better. It should be functionally identical.

* `_get_remote_auth_chain_for_event`: use `_auth_and_persist_fetched_events`

We can use the same codepath for persisting the events fetched as part of an
auth chain as for those fetched individually by `_get_events_and_persist` for
building the state at a backwards extremity.

* `_get_remote_auth_chain_for_event`: use a dict for efficiency

`_auth_and_persist_fetched_events` sorts the events itself, so we no longer
need to care about maintaining the ordering from `get_event_auth` (and no
longer need to sort by depth in `get_event_auth`).

That means that we can use a map, making it easier to filter out events we
already have, etc.

* changelog

* `_auth_and_persist_fetched_events`: improve docstring
2021-09-24 11:56:33 +01:00
..
__init__.py Reference Matrix Home Server 2014-08-12 15:10:52 +01:00
oidc_test_key.p8 JWT OIDC secrets for Sign in with Apple (#9549) 2021-03-09 15:03:37 +00:00
oidc_test_key.pub.pem JWT OIDC secrets for Sign in with Apple (#9549) 2021-03-09 15:03:37 +00:00
test_admin.py Flatten the synapse.rest.client package (#10600) 2021-08-17 11:57:58 +00:00
test_appservice.py Only return an appservice protocol if it has a service providing it. (#10532) 2021-08-05 08:22:14 -04:00
test_auth.py Use direct references for configuration variables (part 4). (#10893) 2021-09-23 12:03:01 -04:00
test_cas.py Rename handler and config modules which end in handler/config. (#9816) 2021-04-20 14:55:20 -04:00
test_device.py MSC2918 Refresh tokens implementation (#9450) 2021-06-24 14:33:20 +01:00
test_directory.py Flatten the synapse.rest.client package (#10600) 2021-08-17 11:57:58 +00:00
test_e2e_keys.py Always communicate device OTK counts to clients (#10485) 2021-07-27 14:36:38 +01:00
test_e2e_room_keys.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
test_federation.py Factor out common code for persisting fetched auth events (#10896) 2021-09-24 11:56:33 +01:00
test_message.py Flatten the synapse.rest.client package (#10600) 2021-08-17 11:57:58 +00:00
test_oidc.py Rename handler and config modules which end in handler/config. (#9816) 2021-04-20 14:55:20 -04:00
test_password_providers.py Flatten the synapse.rest.client package (#10600) 2021-08-17 11:57:58 +00:00
test_presence.py Split FederationHandler in half (#10692) 2021-08-26 21:41:44 +01:00
test_profile.py Always add local users to the user directory (#10796) 2021-09-21 12:02:34 +00:00
test_receipts.py Add type hints for event streams. (#10856) 2021-09-21 13:34:26 -04:00
test_register.py Synapse 1.37.0rc1 (2021-06-24) 2021-06-24 11:20:28 +01:00
test_room.py Pull out encrypted_by_default tests from user_directory tests (#10752) 2021-09-06 11:37:54 +01:00
test_room_summary.py Ignore rooms with unknown room versions in the spaces summary. (#10727) 2021-09-01 17:01:08 +00:00
test_saml.py Use mock from the stdlib. (#9772) 2021-04-09 13:44:38 -04:00
test_send_email.py Fix incompatibility with Twisted < 21. (#10713) 2021-08-27 16:33:41 +01:00
test_stats.py Flatten the synapse.rest.client package (#10600) 2021-08-17 11:57:58 +00:00
test_sync.py Do not include rooms with an unknown room version in a sync response. (#10644) 2021-08-19 11:12:55 -04:00
test_typing.py Add type hints for event streams. (#10856) 2021-09-21 13:34:26 -04:00
test_user_directory.py Improve typing in user_directory files (#10891) 2021-09-24 10:38:22 +01:00