Skip to content

Commit 7778cca

Browse files
author
Mathieu Velten
committed
Add receipt test
1 parent d99b9ac commit 7778cca

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tests/federation_room_join_partial_state_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,55 @@ func TestPartialStateJoin(t *testing.T) {
324324
)
325325
})
326326

327+
// we should be able to receipt typing EDU over federation during the resync
328+
t.Run("CanReceiveReceiptDuringPartialStateJoin", func(t *testing.T) {
329+
deployment := Deploy(t, b.BlueprintAlice)
330+
defer deployment.Destroy(t)
331+
alice := deployment.Client(t, "hs1", "@alice:hs1")
332+
333+
server := createTestServer(t, deployment)
334+
cancel := server.Listen()
335+
defer cancel()
336+
serverRoom := createTestRoom(t, server, alice.GetDefaultRoomVersion(t))
337+
psjResult := beginPartialStateJoin(t, server, serverRoom, alice)
338+
defer psjResult.Destroy()
339+
340+
derekUserId := psjResult.Server.UserID("derek")
341+
342+
content, _ := json.Marshal(map[string]interface{}{
343+
serverRoom.RoomID: map[string]interface{}{
344+
"m.read": map[string]interface{}{
345+
derekUserId: map[string]interface{}{
346+
"data": map[string]interface{}{
347+
"ts": 1436451550453,
348+
},
349+
"event_ids": []string{"mytesteventid"},
350+
},
351+
},
352+
},
353+
})
354+
edu := gomatrixserverlib.EDU{
355+
Type: "m.receipt",
356+
Content: content,
357+
}
358+
psjResult.Server.MustSendTransaction(t, deployment, "hs1", []json.RawMessage{}, []gomatrixserverlib.EDU{edu})
359+
360+
psjResult.FinishStateRequest()
361+
alice.MustSyncUntil(t,
362+
client.SyncReq{},
363+
client.SyncEphemeralHas(serverRoom.RoomID, func(result gjson.Result) bool {
364+
if result.Get("type").Str != "m.receipt" {
365+
return false
366+
}
367+
368+
if result.Get("content").Get("mytesteventid").Get("m\\.read").Get(strings.Replace(derekUserId, ".", "\\.", -1)).Get("ts").Int() == 1436451550453 {
369+
return true
370+
}
371+
return false
372+
}),
373+
)
374+
})
375+
327376
// we should be able to receive events over federation during the resync
328377
t.Run("CanReceiveEventsDuringPartialStateJoin", func(t *testing.T) {
329378
deployment := Deploy(t, b.BlueprintAlice)

0 commit comments

Comments
 (0)