only send new events to RS; add tests for /state_ids and /event (#1011)

* only send new events to RS; add tests for /state_ids and /event

* Review comments: send in auth event order

* Ignore order of state events for this test as RespState.Events is non-deterministic
This commit is contained in:
Kegsay 2020-05-06 18:03:25 +01:00 committed by GitHub
parent 1294852270
commit 3b98535dc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 183 additions and 23 deletions

View file

@ -52,9 +52,10 @@ func (c *RoomserverProducer) SendEvents(
}
// SendEventWithState writes an event with KindNew to the roomserver input log
// with the state at the event as KindOutlier before it.
// with the state at the event as KindOutlier before it. Will not send any event that is
// marked as `true` in haveEventIDs
func (c *RoomserverProducer) SendEventWithState(
ctx context.Context, state *gomatrixserverlib.RespState, event gomatrixserverlib.HeaderedEvent,
ctx context.Context, state *gomatrixserverlib.RespState, event gomatrixserverlib.HeaderedEvent, haveEventIDs map[string]bool,
) error {
outliers, err := state.Events()
if err != nil {
@ -63,6 +64,9 @@ func (c *RoomserverProducer) SendEventWithState(
var ires []api.InputRoomEvent
for _, outlier := range outliers {
if haveEventIDs[outlier.EventID()] {
continue
}
ires = append(ires, api.InputRoomEvent{
Kind: api.KindOutlier,
Event: outlier.Headered(event.RoomVersion),