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.
This commit is contained in:
Erik Johnston
2026-05-14 11:36:18 +01:00
parent b1a5a24487
commit ed2418df99
5 changed files with 20 additions and 1 deletions
+4
View File
@@ -36,6 +36,10 @@ class FederationBaseTestCase(unittest.HomeserverTestCase):
"type": "m.room.message",
"room_id": "!r:domain",
"sender": f"@u:{self.hs.config.server.server_name}",
"auth_events": [],
"prev_events": [],
"depth": 1,
"hashes": {"sha256": ""},
"signatures": {},
"unsigned": {"age_ts": 1000000},
}
+4 -1
View File
@@ -73,6 +73,7 @@ class FederationClientTest(FederatingHomeserverTestCase):
"content": {"creator": self.creator},
"prev_events": [],
"auth_events": [],
"depth": 1,
"origin_server_ts": 500,
}
)
@@ -85,6 +86,7 @@ class FederationClientTest(FederatingHomeserverTestCase):
"content": {"membership": "join"},
"prev_events": [],
"auth_events": [],
"depth": 2,
"origin_server_ts": 600,
}
)
@@ -97,6 +99,7 @@ class FederationClientTest(FederatingHomeserverTestCase):
"content": {},
"prev_events": [],
"auth_events": [],
"depth": 3,
"origin_server_ts": 700,
}
)
@@ -208,8 +211,8 @@ class FederationClientTest(FederatingHomeserverTestCase):
"content": {},
"prev_events": [],
"auth_events": [],
"depth": 3,
"origin_server_ts": 700,
"depth": 10,
}
)
+10
View File
@@ -36,7 +36,16 @@ class SendJoinParserTestCase(TestCase):
def test_two_writes(self) -> None:
"""Test that the parser can sensibly deserialise an input given in two slices."""
parser = SendJoinParser(RoomVersions.V1, True)
common_event_fields = {
"sender": "@user:example.org",
"depth": 1,
"origin_server_ts": 1,
"hashes": {"sha256": ""},
"auth_events": [],
"prev_events": [],
}
parent_event = {
**common_event_fields,
"content": {
"see_room_version_spec": "The event format changes depending on the room version."
},
@@ -45,6 +54,7 @@ class SendJoinParserTestCase(TestCase):
"type": "m.room.minimal_pdu",
}
state = {
**common_event_fields,
"content": {
"see_room_version_spec": "The event format changes depending on the room version."
},
@@ -532,6 +532,7 @@ class ThirdPartyRulesTestCase(unittest.FederatingHomeserverTestCase):
"origin_server_ts": self.clock.time_msec(),
"prev_events": [],
"auth_events": [],
"hashes": {"sha256": ""},
"signatures": {},
"unsigned": {},
}
+1
View File
@@ -495,6 +495,7 @@ class StateResV21TestCase(unittest.HomeserverTestCase):
"prev_events": prev_events,
"auth_events": auth_events,
"origin_server_ts": monotonic_timestamp(),
"hashes": {"sha256": ""},
}
if event_type != EventTypes.Create:
if room_id is None: