Skip to content

Commit

Permalink
More hardening
Browse files Browse the repository at this point in the history
  • Loading branch information
MadLittleMods committed Jan 16, 2025
1 parent 33ac6c9 commit 0d871b6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/federation/test_federation_out_of_band_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ async def get_json(

self.federation_http_client.get_json.side_effect = get_json

# PDU's that hs1 sent to hs2
collected_pdus_from_hs1_federation_send: Set[str] = set()

async def put_json(
destination: str,
path: str,
Expand Down Expand Up @@ -396,6 +399,10 @@ async def put_json(
)

if path.startswith("/_matrix/federation/v1/send/") and data is not None:
for pdu in data.get("pdus", []):
event = event_from_pdu_json(pdu, room_version)
collected_pdus_from_hs1_federation_send.add(event.event_id)

# Just acknowledge everything hs1 is trying to send hs2
return {
event_from_pdu_json(pdu, room_version).event_id: {}
Expand Down Expand Up @@ -436,6 +443,15 @@ async def put_json(
# Prevent tight-looping to allow the `test_timeout` to work
time.sleep(0.1)

# Nothing needs to be sent from hs1 to hs2 since we already let the other
# homeserver know by doing the `/make_join` and `/send_join` dance.
self.assertIncludes(
collected_pdus_from_hs1_federation_send,
set(),
exact=True,
message="Didn't expect any events to be sent from hs1 over federation to hs2",
)

return RemoteRoomJoinResult(
remote_room_id=remote_room_id,
room_version=room_version,
Expand Down Expand Up @@ -500,7 +516,6 @@ async def put_json(
backoff_on_all_error_codes: bool = False,
) -> Union[JsonDict, T]:
if path.startswith("/_matrix/federation/v1/send/") and data is not None:
logger.info("asdf data: %s", data)
for pdu in data.get("pdus", []):
event = event_from_pdu_json(pdu, room_version)
collected_pdus_from_hs1_federation_send.add(event.event_id)
Expand Down

0 comments on commit 0d871b6

Please sign in to comment.