Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for transactions containing a V1 event into a V10 room #743

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

morguldir
Copy link

Pull Request Checklist

Signed-off-by: morguldir <morguldir@protonmail.com>
Copy link
Contributor

@S7evinK S7evinK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments below.

}

for eventID, e := range resp.PDUs {
if eventID != "$meow" && eventID != event.EventID() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does $meow come from?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, i think that was the bad event id i used originally, but ended up just calculating it instead, fixed

if eventID != "$meow" && eventID != event.EventID() {
ct.Fatalf(t, "Server responded with bogus event ID %s", eventID)
} else if e.Error == "" {
ct.Fatalf(t, "Server accepted event sent into a V10 room using V1 format")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least for Dendrite, this is fine. When it receives a transaction, it extracts the room ID, asks the DB about the version and then executes NewEventFromUntrustedJSON (link), which for a V10 room (not specified in the test) runs newEventFromUntrustedJSONV2 (link), which strips out the event_id.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a bogus prev_event too, now it will get the INFO log about not including the event id in the error dict instead

nexy := srv.UserID("nexy")

room := alice.MustCreateRoom(t, map[string]interface{}{
"preset": "public_chat",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the log below wants room version 10, specify it, as it otherwise defaults to the server implementations default (which might be unknown).

Suggested change
"preset": "public_chat",
"preset": "public_chat",
"room_version": "10",

Type: "m.room.message",
Content: map[string]interface{}{"body": "hello i am nexy and i somehow broke the room into a v1 room"},
})
//event.EventID()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//event.EventID()

t.Log("invalid json bwuh", err)
t.FailNow()
}
data, err = sjson.SetBytes(data, "event_id", event.EventID())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error check.

Co-authored-by: Till <2353100+S7evinK@users.noreply.github.com>
Signed-off-by: morguldir <morguldir@protonmail.com>
Co-authored-by: Till <2353100+S7evinK@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants