diff --git a/README.md b/README.md index 70f30e67..82e10694 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,19 @@ +[![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) + ### Complement Complement is a black box integration testing framework for Matrix homeservers. + +## adsf + +To get started developing, see https://github.com/matrix-org/complement/blob/master/ONBOARDING.md + +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) + +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. + + #### Running You need to have Go and Docker installed. Then: diff --git a/internal/b/blueprints.go b/internal/b/blueprints.go index ef8424b4..a2ce915b 100644 --- a/internal/b/blueprints.go +++ b/internal/b/blueprints.go @@ -69,10 +69,11 @@ type Room struct { } type Event struct { - Type string - Sender string - StateKey *string - Content map[string]interface{} + Type string + Sender string + StateKey *string + PrevEvents []string + Content map[string]interface{} // This field is ignored in blueprints as clients are unable to set it. Used with federation.Server Unsigned map[string]interface{} } diff --git a/tests/msc2716_test.go b/tests/msc2716_test.go new file mode 100644 index 00000000..7705ab19 --- /dev/null +++ b/tests/msc2716_test.go @@ -0,0 +1,78 @@ +// +build msc2716 + +// This file contains tests for incrementally importing history to an existing room, +// a currently experimental feature defined by MSC2716, which you can read here: +// https://github.com/matrix-org/matrix-doc/pull/2716 + +package tests + +import ( + "testing" + + "github.com/matrix-org/complement/internal/b" + "github.com/matrix-org/complement/internal/must" + "github.com/tidwall/gjson" +) + +// Test that the m.room.create and m.room.member events for a room we created comes down /sync +func TestBackfillingHistory(t *testing.T) { + deployment := Deploy(t, "rooms_state", b.BlueprintAlice) + defer deployment.Destroy(t) + + userID := "@alice:hs1" + alice := deployment.Client(t, "hs1", userID) + roomID := alice.CreateRoom(t, struct{}{}) + + // eventA + eventA := alice.SendEventSynced(t, roomID, b.Event{ + Type: "m.room.message", + Content: map[string]interface{}{ + "msgtype": "m.text", + "body": "Message A", + }, + }) + // eventB + alice.SendEventSynced(t, roomID, b.Event{ + Type: "m.room.message", + Content: map[string]interface{}{ + "msgtype": "m.text", + "body": "Message B", + }, + }) + // eventC + alice.SendEventSynced(t, roomID, b.Event{ + Type: "m.room.message", + Content: map[string]interface{}{ + "msgtype": "m.text", + "body": "Message C", + }, + }) + + // event1 + alice.SendEventSynced(t, roomID, b.Event{ + Type: "m.room.message", + PrevEvents: []string{ + eventA, + }, + Content: map[string]interface{}{ + "msgtype": "m.text", + "body": "Message 1", + }, + }) + + t.Run("parallel", func(t *testing.T) { + // sytest: Room creation reports m.room.create to myself + t.Run("Room creation reports m.room.create to myself", func(t *testing.T) { + t.Parallel() + alice := deployment.Client(t, "hs1", userID) + alice.SyncUntilTimelineHas(t, roomID, func(ev gjson.Result) bool { + if ev.Get("type").Str != "m.room.create" { + return false + } + must.EqualStr(t, ev.Get("sender").Str, userID, "wrong sender") + must.EqualStr(t, ev.Get("content").Get("creator").Str, userID, "wrong content.creator") + return true + }) + }) + }) +}