diff options
author | Erik Johnston <erik@matrix.org> | 2023-07-05 10:43:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-05 09:43:19 +0000 |
commit | 95a96b21eb98c638ae36814ec74ba468226e373c (patch) | |
tree | 96dd63eb54af01b3ced5a3611fa4600f4788d202 /tests/storage/test_event_federation.py | |
parent | use Image.LANCZOS instead of Image.ANTIALIAS for thumbnail resize (#15876) (diff) | |
download | synapse-95a96b21eb98c638ae36814ec74ba468226e373c.tar.xz |
Add foreign key constraint to `event_forward_extremities`. (#15751)
Diffstat (limited to 'tests/storage/test_event_federation.py')
-rw-r--r-- | tests/storage/test_event_federation.py | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/tests/storage/test_event_federation.py b/tests/storage/test_event_federation.py index 0f3b0744f1..9c151a5e62 100644 --- a/tests/storage/test_event_federation.py +++ b/tests/storage/test_event_federation.py @@ -20,6 +20,7 @@ from parameterized import parameterized from twisted.test.proto_helpers import MemoryReactor +from synapse.api.constants import EventTypes from synapse.api.room_versions import ( KNOWN_ROOM_VERSIONS, EventFormatVersions, @@ -98,8 +99,32 @@ class EventFederationWorkerStoreTestCase(tests.unittest.HomeserverTestCase): room2 = "#room2" room3 = "#room3" - def insert_event(txn: Cursor, i: int, room_id: str) -> None: + def insert_event(txn: LoggingTransaction, i: int, room_id: str) -> None: event_id = "$event_%i:local" % i + + # We need to insert into events table to get around the foreign key constraint. + self.store.db_pool.simple_insert_txn( + txn, + table="events", + values={ + "instance_name": "master", + "stream_ordering": self.store._stream_id_gen.get_next_txn(txn), + "topological_ordering": 1, + "depth": 1, + "event_id": event_id, + "room_id": room_id, + "type": EventTypes.Message, + "processed": True, + "outlier": False, + "origin_server_ts": 0, + "received_ts": 0, + "sender": "@user:local", + "contains_url": False, + "state_key": None, + "rejection_reason": None, + }, + ) + txn.execute( ( "INSERT INTO event_forward_extremities (room_id, event_id) " @@ -113,10 +138,14 @@ class EventFederationWorkerStoreTestCase(tests.unittest.HomeserverTestCase): self.store.db_pool.runInteraction("insert", insert_event, i, room1) ) self.get_success( - self.store.db_pool.runInteraction("insert", insert_event, i, room2) + self.store.db_pool.runInteraction( + "insert", insert_event, i + 100, room2 + ) ) self.get_success( - self.store.db_pool.runInteraction("insert", insert_event, i, room3) + self.store.db_pool.runInteraction( + "insert", insert_event, i + 200, room3 + ) ) # Test simple case |