Skip to content

Commit b24e9c3

Browse files
committed
tests: add missing required event fields in tests that build dicts directly
Some test fixtures construct event/PDU dicts inline rather than via make_test_event — typically because they then run them through add_hashes_and_signatures or otherwise depend on the exact dict shape. Add the format-required fields (depth, hashes, auth_events, prev_events, ...) inline in those cases so they keep working under the strict (Rust-bound) constructor.
1 parent 34eea0a commit b24e9c3

5 files changed

Lines changed: 20 additions & 1 deletion

File tree

tests/federation/test_federation_base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def test_events_signed_by_banned_key_are_refused(self) -> None:
3636
"type": "m.room.message",
3737
"room_id": "!r:domain",
3838
"sender": f"@u:{self.hs.config.server.server_name}",
39+
"auth_events": [],
40+
"prev_events": [],
41+
"depth": 1,
42+
"hashes": {"sha256": ""},
3943
"signatures": {},
4044
"unsigned": {"age_ts": 1000000},
4145
}

tests/federation/test_federation_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def test_get_room_state(self) -> None:
7373
"content": {"creator": self.creator},
7474
"prev_events": [],
7575
"auth_events": [],
76+
"depth": 1,
7677
"origin_server_ts": 500,
7778
}
7879
)
@@ -85,6 +86,7 @@ def test_get_room_state(self) -> None:
8586
"content": {"membership": "join"},
8687
"prev_events": [],
8788
"auth_events": [],
89+
"depth": 2,
8890
"origin_server_ts": 600,
8991
}
9092
)
@@ -97,6 +99,7 @@ def test_get_room_state(self) -> None:
9799
"content": {},
98100
"prev_events": [],
99101
"auth_events": [],
102+
"depth": 3,
100103
"origin_server_ts": 700,
101104
}
102105
)
@@ -208,8 +211,8 @@ def _get_pdu_once(self) -> EventBase:
208211
"content": {},
209212
"prev_events": [],
210213
"auth_events": [],
214+
"depth": 3,
211215
"origin_server_ts": 700,
212-
"depth": 10,
213216
}
214217
)
215218

tests/federation/transport/test_client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,16 @@ class SendJoinParserTestCase(TestCase):
3636
def test_two_writes(self) -> None:
3737
"""Test that the parser can sensibly deserialise an input given in two slices."""
3838
parser = SendJoinParser(RoomVersions.V1, True)
39+
common_event_fields = {
40+
"sender": "@user:example.org",
41+
"depth": 1,
42+
"origin_server_ts": 1,
43+
"hashes": {"sha256": ""},
44+
"auth_events": [],
45+
"prev_events": [],
46+
}
3947
parent_event = {
48+
**common_event_fields,
4049
"content": {
4150
"see_room_version_spec": "The event format changes depending on the room version."
4251
},
@@ -45,6 +54,7 @@ def test_two_writes(self) -> None:
4554
"type": "m.room.minimal_pdu",
4655
}
4756
state = {
57+
**common_event_fields,
4858
"content": {
4959
"see_room_version_spec": "The event format changes depending on the room version."
5060
},

tests/rest/client/test_third_party_rules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ def _send_event_over_federation(self) -> None:
532532
"origin_server_ts": self.clock.time_msec(),
533533
"prev_events": [],
534534
"auth_events": [],
535+
"hashes": {"sha256": ""},
535536
"signatures": {},
536537
"unsigned": {},
537538
}

tests/state/test_v21.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ def create_event(
495495
"prev_events": prev_events,
496496
"auth_events": auth_events,
497497
"origin_server_ts": monotonic_timestamp(),
498+
"hashes": {"sha256": ""},
498499
}
499500
if event_type != EventTypes.Create:
500501
if room_id is None:

0 commit comments

Comments
 (0)