Skip to content

Commit 52a0c8f

Browse files
author
David Robertson
authored
Rename test case method to add_hashes_and_signatures_from_other_server (matrix-org#13255)
1 parent fa71bb1 commit 52a0c8f

File tree

7 files changed

+14
-18
lines changed

7 files changed

+14
-18
lines changed

changelog.d/13255.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Preparatory work for a per-room rate limiter on joins.

tests/federation/test_federation_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_get_room_state(self):
4545
# mock up some events to use in the response.
4646
# In real life, these would have things in `prev_events` and `auth_events`, but that's
4747
# a bit annoying to mock up, and the code under test doesn't care, so we don't bother.
48-
create_event_dict = self.add_hashes_and_signatures(
48+
create_event_dict = self.add_hashes_and_signatures_from_other_server(
4949
{
5050
"room_id": test_room_id,
5151
"type": "m.room.create",
@@ -57,7 +57,7 @@ def test_get_room_state(self):
5757
"origin_server_ts": 500,
5858
}
5959
)
60-
member_event_dict = self.add_hashes_and_signatures(
60+
member_event_dict = self.add_hashes_and_signatures_from_other_server(
6161
{
6262
"room_id": test_room_id,
6363
"type": "m.room.member",
@@ -69,7 +69,7 @@ def test_get_room_state(self):
6969
"origin_server_ts": 600,
7070
}
7171
)
72-
pl_event_dict = self.add_hashes_and_signatures(
72+
pl_event_dict = self.add_hashes_and_signatures_from_other_server(
7373
{
7474
"room_id": test_room_id,
7575
"type": "m.room.power_levels",

tests/federation/test_federation_server.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS
2222
from synapse.config.server import DEFAULT_ROOM_VERSION
23-
from synapse.crypto.event_signing import add_hashes_and_signatures
2423
from synapse.events import make_event_from_dict
2524
from synapse.federation.federation_server import server_matches_acl_event
2625
from synapse.rest import admin
@@ -163,11 +162,9 @@ def test_send_join(self):
163162
join_result = self._make_join(joining_user)
164163

165164
join_event_dict = join_result["event"]
166-
add_hashes_and_signatures(
167-
KNOWN_ROOM_VERSIONS[DEFAULT_ROOM_VERSION],
165+
self.add_hashes_and_signatures_from_other_server(
168166
join_event_dict,
169-
signature_name=self.OTHER_SERVER_NAME,
170-
signing_key=self.OTHER_SERVER_SIGNATURE_KEY,
167+
KNOWN_ROOM_VERSIONS[DEFAULT_ROOM_VERSION],
171168
)
172169
channel = self.make_signed_federation_request(
173170
"PUT",
@@ -220,11 +217,9 @@ def test_send_join_partial_state(self):
220217
join_result = self._make_join(joining_user)
221218

222219
join_event_dict = join_result["event"]
223-
add_hashes_and_signatures(
224-
KNOWN_ROOM_VERSIONS[DEFAULT_ROOM_VERSION],
220+
self.add_hashes_and_signatures_from_other_server(
225221
join_event_dict,
226-
signature_name=self.OTHER_SERVER_NAME,
227-
signing_key=self.OTHER_SERVER_SIGNATURE_KEY,
222+
KNOWN_ROOM_VERSIONS[DEFAULT_ROOM_VERSION],
228223
)
229224
channel = self.make_signed_federation_request(
230225
"PUT",

tests/handlers/test_federation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def test_backfill_with_many_backward_extremities(self) -> None:
256256
]
257257
for _ in range(0, 8):
258258
event = make_event_from_dict(
259-
self.add_hashes_and_signatures(
259+
self.add_hashes_and_signatures_from_other_server(
260260
{
261261
"origin_server_ts": 1,
262262
"type": "m.room.message",

tests/handlers/test_federation_event.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _test_process_pulled_event_with_missing_state(
104104
# mock up a load of state events which we are missing
105105
state_events = [
106106
make_event_from_dict(
107-
self.add_hashes_and_signatures(
107+
self.add_hashes_and_signatures_from_other_server(
108108
{
109109
"type": "test_state_type",
110110
"state_key": f"state_{i}",
@@ -131,7 +131,7 @@ def _test_process_pulled_event_with_missing_state(
131131
# Depending on the test, we either persist this upfront (as an outlier),
132132
# or let the server request it.
133133
prev_event = make_event_from_dict(
134-
self.add_hashes_and_signatures(
134+
self.add_hashes_and_signatures_from_other_server(
135135
{
136136
"type": "test_regular_type",
137137
"room_id": room_id,
@@ -165,7 +165,7 @@ async def get_event(destination: str, event_id: str, timeout=None):
165165

166166
# mock up a regular event to pass into _process_pulled_event
167167
pulled_event = make_event_from_dict(
168-
self.add_hashes_and_signatures(
168+
self.add_hashes_and_signatures_from_other_server(
169169
{
170170
"type": "test_regular_type",
171171
"room_id": room_id,

tests/test_visibility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def test_out_of_band_invite_rejection(self):
272272
"state_key": "@user:test",
273273
"content": {"membership": "invite"},
274274
}
275-
self.add_hashes_and_signatures(invite_pdu)
275+
self.add_hashes_and_signatures_from_other_server(invite_pdu)
276276
invite_event_id = make_event_from_dict(invite_pdu, RoomVersions.V9).event_id
277277

278278
self.get_success(

tests/unittest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ def make_signed_federation_request(
838838
client_ip=client_ip,
839839
)
840840

841-
def add_hashes_and_signatures(
841+
def add_hashes_and_signatures_from_other_server(
842842
self,
843843
event_dict: JsonDict,
844844
room_version: RoomVersion = KNOWN_ROOM_VERSIONS[DEFAULT_ROOM_VERSION],

0 commit comments

Comments
 (0)