@@ -5,18 +5,16 @@ import (
55 "github.com/matrix-org/complement/internal/docker"
66 "github.com/matrix-org/complement/internal/federation"
77 "github.com/matrix-org/gomatrixserverlib"
8- "os"
98 "testing"
109 "time"
1110)
1211
1312// test that a redaction is sent out over federation even if we don't have the original event
1413func TestFederationRedactSendsWithoutEvent (t * testing.T ) {
15- os .Setenv ("COMPLEMENT_DEBUG" , "1" )
1614 deployment := Deploy (t , b .BlueprintAlice )
1715 defer deployment .Destroy (t )
1816
19- roxy := deployment .RegisterUser (t , "hs1" , "roxy" , "verygoodpass" , true )
17+ alice := deployment .Client (t , "hs1" , "@alice:hs1" )
2018
2119 waiter := NewWaiter ()
2220 wantEventType := "m.room.redaction"
@@ -43,17 +41,17 @@ func TestFederationRedactSendsWithoutEvent(t *testing.T) {
4341 // create username
4442 charlie := srv .UserID ("charlie" )
4543
46- ver := roxy .GetDefaultRoomVersion (t )
44+ ver := alice .GetDefaultRoomVersion (t )
4745
48- // the remote homeserver creates a public room
46+ // the remote homeserver creates a public room allowing anyone to redact
4947 initalEvents := federation .InitialRoomEvents (ver , charlie )
5048 plEvent := initalEvents [2 ]
5149 plEvent .Content ["redact" ] = 0
5250 serverRoom := srv .MustMakeRoom (t , ver , initalEvents )
5351 roomAlias := srv .MakeAliasMapping ("flibble" , serverRoom .RoomID )
5452
5553 // the local homeserver joins the room
56- roxy .JoinRoom (t , roomAlias , []string {docker .HostnameRunningComplement })
54+ alice .JoinRoom (t , roomAlias , []string {docker .HostnameRunningComplement })
5755
5856 // inject event to redact in the room
5957 badEvent := srv .MustCreateEvent (t , serverRoom , b.Event {
@@ -70,7 +68,7 @@ func TestFederationRedactSendsWithoutEvent(t *testing.T) {
7068 eventToRedact := eventID + ":" + fullServerName
7169
7270 // the client sends a request to the local homeserver to send the redaction
73- roxy .SendRedaction (t , serverRoom .RoomID , b.Event {Type : wantEventType , Content : map [string ]interface {}{
71+ res := alice .SendRedaction (t , serverRoom .RoomID , b.Event {Type : wantEventType , Content : map [string ]interface {}{
7472 "msgtype" : "m.room.redaction" },
7573 Redacts : eventToRedact }, eventToRedact )
7674
@@ -82,6 +80,12 @@ func TestFederationRedactSendsWithoutEvent(t *testing.T) {
8280 lastEventType := lastEvent .Type ()
8381 wantedType := "m.room.redaction"
8482 if lastEventType != wantedType {
85- t .Fatalf ("Incorrent event type, wanted m.room.redaction." )
83+ t .Fatalf ("Incorrent event type %s , wanted m.room.redaction." , lastEventType )
8684 }
85+
86+ // check that the event id of the redaction sent by alice is the same as the redaction event in the room
87+ if res != lastEvent .EventID () {
88+ t .Fatalf ("Incorrent event id %s, wanted %s." , res , lastEvent .EventID ())
89+ }
90+
8791}
0 commit comments