Use PDU not *Event in HeaderedEvent (#3073)

Requires https://github.com/matrix-org/gomatrixserverlib/pull/376

This has numerous upsides:
 - Less type casting to `*Event` is required.
- Making Dendrite work with `PDU` interfaces means we can swap out Event
impls more easily.
 - Tests which represent weird event shapes are easier to write.

Part of a series of refactors on GMSL.
This commit is contained in:
kegsay 2023-05-02 15:03:16 +01:00 committed by GitHub
parent 696cbb70b8
commit f5b3144dc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 296 additions and 284 deletions

View file

@ -18,21 +18,21 @@ func Test_EventAuth(t *testing.T) {
room2 := test.NewRoom(t, alice, test.RoomPreset(test.PresetPublicChat))
authEventIDs := make([]string, 0, 4)
authEvents := []*gomatrixserverlib.Event{}
authEvents := []gomatrixserverlib.PDU{}
// Add the legal auth events from room2
for _, x := range room2.Events() {
if x.Type() == spec.MRoomCreate {
authEventIDs = append(authEventIDs, x.EventID())
authEvents = append(authEvents, x.Event)
authEvents = append(authEvents, x.PDU)
}
if x.Type() == spec.MRoomPowerLevels {
authEventIDs = append(authEventIDs, x.EventID())
authEvents = append(authEvents, x.Event)
authEvents = append(authEvents, x.PDU)
}
if x.Type() == spec.MRoomJoinRules {
authEventIDs = append(authEventIDs, x.EventID())
authEvents = append(authEvents, x.Event)
authEvents = append(authEvents, x.PDU)
}
}
@ -40,7 +40,7 @@ func Test_EventAuth(t *testing.T) {
for _, x := range room1.Events() {
if x.Type() == spec.MRoomMember {
authEventIDs = append(authEventIDs, x.EventID())
authEvents = append(authEvents, x.Event)
authEvents = append(authEvents, x.PDU)
}
}
@ -58,7 +58,7 @@ func Test_EventAuth(t *testing.T) {
}
// Finally check that the event is NOT allowed
if err := gomatrixserverlib.Allowed(ev.Event, &allower); err == nil {
if err := gomatrixserverlib.Allowed(ev.PDU, &allower); err == nil {
t.Fatalf("event should not be allowed, but it was")
}
}