Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 2d9ae2d

Browse files
committed
Update tests further.
1 parent 1151859 commit 2d9ae2d

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

synapse/federation/sender/per_destination_queue.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -560,10 +560,10 @@ def _get_rr_edus(self, force_flush: bool) -> Iterable[Edu]:
560560
# Build the EDUs needed to send these receipts. This is a bit complicated
561561
# since we can share one for each unique (room, receipt type, user), but
562562
# need additional ones for different threads. The result is that we will
563-
# send N EDUs where N is the maximum number of threads in a room.
563+
# send N EDUs where N is the number of unique threads across rooms.
564564
#
565-
# This could be slightly more efficient by bundling users who have only
566-
# send receipts for different threads.
565+
# This could be more efficient by bundling users who have sent receipts
566+
# for different threads.
567567
while self._pending_rrs:
568568
# The next EDU's content.
569569
content: JsonDict = {}

tests/federation/test_federation_sender.py

+24-23
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,23 @@ def test_send_receipts_thread(self):
9090
)
9191
mock_send_transaction.return_value = make_awaitable({})
9292

93-
# Create receipts for the same room and user, but on two different threads,
93+
# Create receipts for:
94+
#
95+
# * The same room / user on multiple threads.
96+
# * A different user in the same room.
9497
sender = self.hs.get_federation_sender()
95-
receipt = ReadReceipt(
96-
"room_id",
97-
"m.read",
98-
"user_id",
99-
["event_id"],
100-
thread_id=None,
101-
data={"ts": 1234},
102-
)
103-
self.successResultOf(defer.ensureDeferred(sender.send_read_receipt(receipt)))
104-
receipt = ReadReceipt(
105-
"room_id",
106-
"m.read",
107-
"user_id",
108-
["event_id"],
109-
thread_id="thread_id",
110-
data={"ts": 1234},
111-
)
112-
self.successResultOf(defer.ensureDeferred(sender.send_read_receipt(receipt)))
98+
for user, thread in (("alice", None), ("alice", "thread"), ("bob", None)):
99+
receipt = ReadReceipt(
100+
"room_id",
101+
"m.read",
102+
user,
103+
["event_id"],
104+
thread_id=thread,
105+
data={"ts": 1234},
106+
)
107+
self.successResultOf(
108+
defer.ensureDeferred(sender.send_read_receipt(receipt))
109+
)
113110

114111
self.pump()
115112

@@ -126,9 +123,9 @@ def test_send_receipts_thread(self):
126123
"content": {
127124
"room_id": {
128125
"m.read": {
129-
"user_id": {
126+
"alice": {
130127
"event_ids": ["event_id"],
131-
"data": {"ts": 1234, "thread_id": "thread_id"},
128+
"data": {"ts": 1234, "thread_id": "thread"},
132129
}
133130
}
134131
}
@@ -139,10 +136,14 @@ def test_send_receipts_thread(self):
139136
"content": {
140137
"room_id": {
141138
"m.read": {
142-
"user_id": {
139+
"alice": {
143140
"event_ids": ["event_id"],
144141
"data": {"ts": 1234},
145-
}
142+
},
143+
"bob": {
144+
"event_ids": ["event_id"],
145+
"data": {"ts": 1234},
146+
},
146147
}
147148
}
148149
},

0 commit comments

Comments
 (0)