Skip to content

Commit 15ba451

Browse files
committed
Add tests for MSC2716 and backfilling history
Work on MSC2716: matrix-org/matrix-spec-proposals#2716
1 parent df15003 commit 15ba451

File tree

3 files changed

+95
-4
lines changed

3 files changed

+95
-4
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
[![Complement Dev](https://img.shields.io/matrix/complement:matrix.org.svg?label=%23complement%3Amatrix.org&logo=matrix&server_fqdn=matrix.org)](https://matrix.to/#/#complement:matrix.org)
2+
13
### Complement
24

35
Complement is a black box integration testing framework for Matrix homeservers.
46

7+
8+
## adsf
9+
10+
To get started developing, see https://github.com/matrix-org/complement/blob/master/ONBOARDING.md
11+
12+
If you're looking to run Complement against a local dev instance of Synapse, see [`matrix-org/synapse` -> `scripts-dev/complement.sh`](https://github.com/matrix-org/synapse/blob/develop/scripts-dev/complement.sh)
13+
14+
If you want to develop Complement tests while working on a local dev instance of Synapse, edit `scripts-dev/complement.sh` to point to your local Complement checkout.
15+
16+
517
#### Running
618

719
You need to have Go and Docker installed. Then:

internal/b/blueprints.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ type Room struct {
6969
}
7070

7171
type Event struct {
72-
Type string
73-
Sender string
74-
StateKey *string
75-
Content map[string]interface{}
72+
Type string
73+
Sender string
74+
StateKey *string
75+
PrevEvents []string
76+
Content map[string]interface{}
7677
// This field is ignored in blueprints as clients are unable to set it. Used with federation.Server
7778
Unsigned map[string]interface{}
7879
}

tests/msc2716_test.go

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// +build msc2716
2+
3+
// This file contains tests for incrementally importing history to an existing room,
4+
// a currently experimental feature defined by MSC2716, which you can read here:
5+
// https://github.com/matrix-org/matrix-doc/pull/2716
6+
7+
package tests
8+
9+
import (
10+
"testing"
11+
12+
"github.com/matrix-org/complement/internal/b"
13+
"github.com/matrix-org/complement/internal/must"
14+
"github.com/tidwall/gjson"
15+
)
16+
17+
// Test that the m.room.create and m.room.member events for a room we created comes down /sync
18+
func TestBackfillingHistory(t *testing.T) {
19+
deployment := Deploy(t, "rooms_state", b.BlueprintAlice)
20+
defer deployment.Destroy(t)
21+
22+
userID := "@alice:hs1"
23+
alice := deployment.Client(t, "hs1", userID)
24+
roomID := alice.CreateRoom(t, struct{}{})
25+
26+
// eventA
27+
eventA := alice.SendEventSynced(t, roomID, b.Event{
28+
Type: "m.room.message",
29+
Content: map[string]interface{}{
30+
"msgtype": "m.text",
31+
"body": "Message A",
32+
},
33+
})
34+
// eventB
35+
alice.SendEventSynced(t, roomID, b.Event{
36+
Type: "m.room.message",
37+
Content: map[string]interface{}{
38+
"msgtype": "m.text",
39+
"body": "Message B",
40+
},
41+
})
42+
// eventC
43+
alice.SendEventSynced(t, roomID, b.Event{
44+
Type: "m.room.message",
45+
Content: map[string]interface{}{
46+
"msgtype": "m.text",
47+
"body": "Message C",
48+
},
49+
})
50+
51+
// event1
52+
alice.SendEventSynced(t, roomID, b.Event{
53+
Type: "m.room.message",
54+
PrevEvents: []string{
55+
eventA,
56+
},
57+
Content: map[string]interface{}{
58+
"msgtype": "m.text",
59+
"body": "Message 1",
60+
},
61+
})
62+
63+
t.Run("parallel", func(t *testing.T) {
64+
// sytest: Room creation reports m.room.create to myself
65+
t.Run("Room creation reports m.room.create to myself", func(t *testing.T) {
66+
t.Parallel()
67+
alice := deployment.Client(t, "hs1", userID)
68+
alice.SyncUntilTimelineHas(t, roomID, func(ev gjson.Result) bool {
69+
if ev.Get("type").Str != "m.room.create" {
70+
return false
71+
}
72+
must.EqualStr(t, ev.Get("sender").Str, userID, "wrong sender")
73+
must.EqualStr(t, ev.Get("content").Get("creator").Str, userID, "wrong content.creator")
74+
return true
75+
})
76+
})
77+
})
78+
}

0 commit comments

Comments
 (0)