Skip to content

Commit

Permalink
Add more tests for receiving events while resyncing for a partial join (
Browse files Browse the repository at this point in the history
#419)

And add some helper functions along the way:
* Factor out a `CreateMessageEvent()` helper.
* Add `testReceiveEventDuringPartialStateJoin()`, which sends an event
  over federation, checks that a client can see it and checks the state
  at the event.
* Add `handleGetMissingEventsRequests()` to respond to
  `/get_missing_events` requests.
* Add a `Context` parameter to `SendFederationRequest()`, to allow
  custom timeouts to be specified.

Co-authored-by: Richard van der Hoff <[email protected]>
  • Loading branch information
squahtx and richvdh authored Jul 26, 2022
1 parent 6d5c75f commit 3d09f94
Show file tree
Hide file tree
Showing 3 changed files with 285 additions and 69 deletions.
4 changes: 2 additions & 2 deletions internal/federation/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (s *Server) MustSendTransaction(t *testing.T, deployment *docker.Deployment
// SendFederationRequest signs and sends an arbitrary federation request from this server.
//
// The requests will be routed according to the deployment map in `deployment`.
func (s *Server) SendFederationRequest(deployment *docker.Deployment, req gomatrixserverlib.FederationRequest, resBody interface{}) error {
func (s *Server) SendFederationRequest(ctx context.Context, deployment *docker.Deployment, req gomatrixserverlib.FederationRequest, resBody interface{}) error {
if err := req.Sign(gomatrixserverlib.ServerName(s.serverName), s.KeyID, s.Priv); err != nil {
return err
}
Expand All @@ -224,7 +224,7 @@ func (s *Server) SendFederationRequest(deployment *docker.Deployment, req gomatr
}

httpClient := gomatrixserverlib.NewClient(gomatrixserverlib.WithTransport(&docker.RoundTripper{Deployment: deployment}))
return httpClient.DoRequestAndParseResponse(context.Background(), httpReq, resBody)
return httpClient.DoRequestAndParseResponse(ctx, httpReq, resBody)
}

// MustCreateEvent will create and sign a new latest event for the given room.
Expand Down
Loading

0 comments on commit 3d09f94

Please sign in to comment.