aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorkegsay <kegan@matrix.org>2023-05-04 11:17:42 +0100
committerGitHub <noreply@github.com>2023-05-04 11:17:42 +0100
commit2b34f88fde6b3aa633c8f23ff424a5db4951efd3 (patch)
treebbf58904af8499f756fc1965f63a5ca359418c0a /test
parentd5c11a3c86bf1eeb7ae6b1c243ec889432fcd881 (diff)
Use ProtoEvent where needed instead of EventBuilder (#3075)
They are fundamentally different concepts, so should be represented as such. Proto events are exchanged in /make_xxx calls over federation, and made as "fledgling" events in /createRoom and general event sending. *Building* events is a reasonably complex VERSION SPECIFIC process which needs amongst other things, auth event providers, prev events, signing keys, etc. Requires https://github.com/matrix-org/gomatrixserverlib/pull/379
Diffstat (limited to 'test')
-rw-r--r--test/room.go14
1 files changed, 4 insertions, 10 deletions
diff --git a/test/room.go b/test/room.go
index 918123aa..1c0f01e4 100644
--- a/test/room.go
+++ b/test/room.go
@@ -163,14 +163,14 @@ func (r *Room) CreateEvent(t *testing.T, creator *User, eventType string, conten
}
}
- builder := &gomatrixserverlib.EventBuilder{
+ builder := gomatrixserverlib.MustGetRoomVersion(r.Version).NewEventBuilderFromProtoEvent(&gomatrixserverlib.ProtoEvent{
Sender: creator.ID,
RoomID: r.ID,
Type: eventType,
StateKey: mod.stateKey,
Depth: int64(depth),
Unsigned: unsigned,
- }
+ })
err = builder.SetContent(content)
if err != nil {
t.Fatalf("CreateEvent[%s]: failed to SetContent: %s", eventType, err)
@@ -179,16 +179,10 @@ func (r *Room) CreateEvent(t *testing.T, creator *User, eventType string, conten
builder.PrevEvents = []gomatrixserverlib.EventReference{r.events[len(r.events)-1].EventReference()}
}
- eventsNeeded, err := gomatrixserverlib.StateNeededForEventBuilder(builder)
- if err != nil {
- t.Fatalf("CreateEvent[%s]: failed to StateNeededForEventBuilder: %s", eventType, err)
- }
-
- refs, err := eventsNeeded.AuthEventReferences(&r.authEvents)
+ err = builder.AddAuthEvents(&r.authEvents)
if err != nil {
t.Fatalf("CreateEvent[%s]: failed to AuthEventReferences: %s", eventType, err)
}
- builder.AuthEvents = refs
if len(mod.authEvents) > 0 {
builder.AuthEvents = mod.authEvents
@@ -196,7 +190,7 @@ func (r *Room) CreateEvent(t *testing.T, creator *User, eventType string, conten
ev, err := builder.Build(
mod.originServerTS, mod.origin, mod.keyID,
- mod.privKey, r.Version,
+ mod.privKey,
)
if err != nil {
t.Fatalf("CreateEvent[%s]: failed to build event: %s", eventType, err)