mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-09-19 05:04:39 -04:00
Refactor MSC3030 /timestamp_to_event
to move away from our snowflake pull from destination
pattern (#14096)
1. `federation_client.timestamp_to_event(...)` now handles all `destination` looping and uses our generic `_try_destination_list(...)` helper. 2. Consistently handling `NotRetryingDestination` and `FederationDeniedError` across `get_pdu` , backfill, and the generic `_try_destination_list` which is used for many places we use this pattern. 3. `get_pdu(...)` now returns `PulledPduInfo` so we know which `destination` we ended up pulling the PDU from
This commit is contained in:
parent
0d59ae706a
commit
40fa8294e3
7 changed files with 192 additions and 127 deletions
|
@ -142,14 +142,14 @@ class FederationClientTest(FederatingHomeserverTestCase):
|
|||
|
||||
def test_get_pdu_returns_nothing_when_event_does_not_exist(self):
|
||||
"""No event should be returned when the event does not exist"""
|
||||
remote_pdu = self.get_success(
|
||||
pulled_pdu_info = self.get_success(
|
||||
self.hs.get_federation_client().get_pdu(
|
||||
["yet.another.server"],
|
||||
"event_should_not_exist",
|
||||
RoomVersions.V9,
|
||||
)
|
||||
)
|
||||
self.assertEqual(remote_pdu, None)
|
||||
self.assertEqual(pulled_pdu_info, None)
|
||||
|
||||
def test_get_pdu(self):
|
||||
"""Test to make sure an event is returned by `get_pdu()`"""
|
||||
|
@ -169,13 +169,15 @@ class FederationClientTest(FederatingHomeserverTestCase):
|
|||
remote_pdu.internal_metadata.outlier = True
|
||||
|
||||
# Get the event again. This time it should read it from cache.
|
||||
remote_pdu2 = self.get_success(
|
||||
pulled_pdu_info2 = self.get_success(
|
||||
self.hs.get_federation_client().get_pdu(
|
||||
["yet.another.server"],
|
||||
remote_pdu.event_id,
|
||||
RoomVersions.V9,
|
||||
)
|
||||
)
|
||||
self.assertIsNotNone(pulled_pdu_info2)
|
||||
remote_pdu2 = pulled_pdu_info2.pdu
|
||||
|
||||
# Sanity check that we are working against the same event
|
||||
self.assertEqual(remote_pdu.event_id, remote_pdu2.event_id)
|
||||
|
@ -215,13 +217,15 @@ class FederationClientTest(FederatingHomeserverTestCase):
|
|||
)
|
||||
)
|
||||
|
||||
remote_pdu = self.get_success(
|
||||
pulled_pdu_info = self.get_success(
|
||||
self.hs.get_federation_client().get_pdu(
|
||||
["yet.another.server"],
|
||||
"event_id",
|
||||
RoomVersions.V9,
|
||||
)
|
||||
)
|
||||
self.assertIsNotNone(pulled_pdu_info)
|
||||
remote_pdu = pulled_pdu_info.pdu
|
||||
|
||||
# check the right call got made to the agent
|
||||
self._mock_agent.request.assert_called_once_with(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue