Skip to content

Commit

Permalink
Update with semantics of MSC4102
Browse files Browse the repository at this point in the history
  • Loading branch information
kegsay committed Feb 16, 2024
1 parent 0296c1c commit 4540e0f
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions tests/csapi/thread_notifications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ func TestThreadedReceipts(t *testing.T) {
}

// Regression test for https://github.com/matrix-org/matrix-spec/issues/1727
// Servers need to send 2x EDUs to represent these 2 receipts, but do they?
func TestThreadReceiptsInSync(t *testing.T) {
// Servers should always prefer the unthreaded receipt when there is a clash of receipts
func TestThreadReceiptsInSyncMSC4102(t *testing.T) {
runtime.SkipIf(t, runtime.Dendrite) // not supported
deployment := complement.Deploy(t, 1)
defer deployment.Destroy(t)
Expand All @@ -330,38 +330,15 @@ func TestThreadReceiptsInSync(t *testing.T) {
},
},
})
// now send an unthreaded RR for event B and a threaded RR for event B and ensure we see both receipts
// now send an unthreaded RR for event B and a threaded RR for event B and ensure we see the unthreaded RR
// down /sync. Non-compliant servers will typically send the last one only.
alice.MustDo(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "receipt", "m.read", eventB}, client.WithJSONBody(t, struct{}{}))
alice.MustDo(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "receipt", "m.read", eventB}, client.WithJSONBody(t, map[string]interface{}{"thread_id": eventA}))

seenThreaded := false
seenUnthreaded := false

alice.MustSyncUntil(
t,
client.SyncReq{},
// we need to allow multiple /sync responses to gradually show us both receipts, hence the weird shape here.
func(clientUserID string, topLevelSyncJSON gjson.Result) error {
var lastErr error
if err := syncHasUnthreadedReadReceipt(roomID, alice.UserID, eventB)(clientUserID, topLevelSyncJSON); err == nil {
seenUnthreaded = true
t.Logf("seen unthreaded read receipt")
} else {
lastErr = err
}
if err := syncHasThreadedReadReceipt(roomID, alice.UserID, eventB, eventA)(clientUserID, topLevelSyncJSON); err == nil {
seenThreaded = true
t.Logf("seen threaded read receipt")
} else {
lastErr = err
}
if seenThreaded && seenUnthreaded {
t.Logf("seen both read receipts, returning")
return nil
}
return lastErr
},
syncHasUnthreadedReadReceipt(roomID, alice.UserID, eventB),
)

}

0 comments on commit 4540e0f

Please sign in to comment.