Add ServerRoomImpl to allow tests to reuse helpers with custom code#766
Merged
Add ServerRoomImpl to allow tests to reuse helpers with custom code#766
Conversation
This allows tests to replace how we map Complement Events to PDUs. This does not yet do everything as the mapping of /send_join to Rooms isn't factored out.
devonh
approved these changes
Feb 28, 2025
Contributor
devonh
left a comment
There was a problem hiding this comment.
New API functions should ideally have doc comments to explain their usage.
Even though they are pretty clear just from name & impl alone.
Otherwise these changes look promising and will make it much easier to mess around with future event changes without having to break into complement's internals.
| Type: "m.room.member", | ||
| StateKey: &userID, | ||
| Content: map[string]interface{}{ | ||
| "membership": spec.Join, // XXX this feels wrong? |
Member
Author
There was a problem hiding this comment.
It's MakeRespMakeKnock so surely should be knock not join.
Co-authored-by: Devon Hudson <devon.dmytro@gmail.com>
Member
Author
|
Will chuck some comments in then merge, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the addition of #765 it's now possible for tests to add a range of good/bad/broken rooms to Complement's internal federation server. However, these rooms cannot reuse any of the existing helper functions. To aid this, logic which was once part of the federation server itself (e.g mapping
/send_joinresponses to internalServerRoomstate) is now transferred to a newServerRoomImplinterface. The federation server's helper functions call this interface, allowing tests to swap out functions for their broken rooms.For example, we may want to reuse the very convenient
HandleMakeSendJoinRequestsbut modify the join proto event to include malformed fields. Before this PR this simply wasn't possible as we hard-coded the happy case. Tests can now do: