Skip to content

Commit 70036ac

Browse files
committed
Switch to fire and forget sending over historical events which we don't expect to sync
1 parent 55c5a8c commit 70036ac

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

internal/client/client.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ func (c *CSAPI) JoinRoom(t *testing.T, roomIDOrAlias string, serverNames []strin
8484
return GetJSONFieldStr(t, body, "room_id")
8585
}
8686

87-
// SendEventSynced sends `e` into the room and waits for its event ID to come down /sync.
88-
// Returns the event ID of the sent event.
89-
func (c *CSAPI) SendEventSynced(t *testing.T, roomID string, e b.Event) string {
87+
func (c *CSAPI) SendEvent(t *testing.T, roomID string, e b.Event) string {
9088
t.Helper()
9189
c.txnID++
9290
paths := []string{"_matrix", "client", "r0", "rooms", roomID, "send", e.Type, strconv.Itoa(c.txnID)}
@@ -107,6 +105,15 @@ func (c *CSAPI) SendEventSynced(t *testing.T, roomID string, e b.Event) string {
107105
res := c.MustDoRaw(t, "PUT", paths, b, "application/json", query)
108106
body := ParseJSON(t, res)
109107
eventID := GetJSONFieldStr(t, body, "event_id")
108+
109+
return eventID
110+
}
111+
112+
// SendEventSynced sends `e` into the room and waits for its event ID to come down /sync.
113+
// Returns the event ID of the sent event.
114+
func (c *CSAPI) SendEventSynced(t *testing.T, roomID string, e b.Event) string {
115+
t.Helper()
116+
eventID := c.SendEvent(t, roomID, e)
110117
t.Logf("SendEventSynced waiting for event ID %s", eventID)
111118
c.SyncUntilTimelineHas(t, roomID, func(r gjson.Result) bool {
112119
return r.Get("event_id").Str == eventID

tests/msc2716_test.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
package tests
88

99
import (
10+
"net/url"
1011
"testing"
1112

1213
"github.com/matrix-org/complement/internal/b"
1314
"github.com/matrix-org/complement/internal/must"
15+
"github.com/sirupsen/logrus"
1416
"github.com/tidwall/gjson"
1517
)
1618

@@ -49,7 +51,7 @@ func TestBackfillingHistory(t *testing.T) {
4951
})
5052

5153
// event1
52-
alice.SendEventSynced(t, roomID, b.Event{
54+
event1 := alice.SendEvent(t, roomID, b.Event{
5355
Type: "m.room.message",
5456
PrevEvents: []string{
5557
eventA,
@@ -60,11 +62,47 @@ func TestBackfillingHistory(t *testing.T) {
6062
},
6163
})
6264

65+
// event2
66+
event2 := alice.SendEvent(t, roomID, b.Event{
67+
Type: "m.room.message",
68+
PrevEvents: []string{
69+
event1,
70+
},
71+
Content: map[string]interface{}{
72+
"msgtype": "m.text",
73+
"body": "Message 2",
74+
},
75+
})
76+
77+
// event3
78+
alice.SendEvent(t, roomID, b.Event{
79+
Type: "m.room.message",
80+
PrevEvents: []string{
81+
event2,
82+
},
83+
Content: map[string]interface{}{
84+
"msgtype": "m.text",
85+
"body": "Message 3",
86+
},
87+
})
88+
89+
res := alice.MustDoRaw(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "messages"}, nil, "application/json", url.Values{
90+
"dir": []string{"b"},
91+
"limit": []string{"100"},
92+
})
93+
94+
t.Logf("aweawfeefwaweafeafw")
95+
logrus.WithFields(logrus.Fields{
96+
"res": res,
97+
}).Error("messages res")
98+
6399
t.Run("parallel", func(t *testing.T) {
64100
// sytest: Room creation reports m.room.create to myself
65101
t.Run("Room creation reports m.room.create to myself", func(t *testing.T) {
66102
t.Parallel()
103+
67104
alice := deployment.Client(t, "hs1", userID)
105+
68106
alice.SyncUntilTimelineHas(t, roomID, func(ev gjson.Result) bool {
69107
if ev.Get("type").Str != "m.room.create" {
70108
return false

0 commit comments

Comments
 (0)