From 7679e69405e40af79bc6efaf1ac7344c18381fb5 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 1 Dec 2021 18:13:20 -0600 Subject: [PATCH] Send marker events in all federation tests The marker event is important to let the remote homeservers know there are historical messages at the given insertion event it points to. It's just a lucky happen-stance that the tests passed before without the need for the marker event. Marker events are required/expected in order for the history to be properly visible on remote homservers. --- tests/msc2716_test.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/msc2716_test.go b/tests/msc2716_test.go index db5317f6..75beab9f 100644 --- a/tests/msc2716_test.go +++ b/tests/msc2716_test.go @@ -575,6 +575,11 @@ func TestImportHistoricalMessages(t *testing.T) { ) batchSendResBody := client.ParseJSON(t, batchSendRes) historicalEventIDs := client.GetJSONFieldStringArray(t, batchSendResBody, "event_ids") + baseInsertionEventID := client.GetJSONFieldStr(t, batchSendResBody, "base_insertion_event_id") + + // Send the marker event which lets remote homeservers know there are + // some historical messages back at the given insertion event. + sendMarkerAndEnsureBackfilled(t, as, alice, roomID, baseInsertionEventID) // Join the room from a remote homeserver after the historical messages were sent remoteCharlie.JoinRoom(t, roomID, []string{"hs1"}) @@ -654,6 +659,10 @@ func TestImportHistoricalMessages(t *testing.T) { batchSendResBody := client.ParseJSON(t, batchSendRes) historicalEventIDs := client.GetJSONFieldStringArray(t, batchSendResBody, "event_ids") + // Send the marker event which lets remote homeservers know there are + // some historical messages back at the given insertion event. + sendMarkerAndEnsureBackfilled(t, as, alice, roomID, insertionEventID) + // Join the room from a remote homeserver after the historical messages were sent remoteCharlie.JoinRoom(t, roomID, []string{"hs1"}) @@ -756,7 +765,8 @@ func TestImportHistoricalMessages(t *testing.T) { }, }) - // Send the marker event + // Send the marker event which lets remote homeservers know there are + // some historical messages back at the given insertion event. sendMarkerAndEnsureBackfilled(t, as, remoteCharlie, roomID, baseInsertionEventID) // FIXME: In the future, we should probably replace the following logic @@ -849,7 +859,8 @@ func TestImportHistoricalMessages(t *testing.T) { }, }) - // Send the marker event + // Send the marker event which lets remote homeservers know there are + // some historical messages back at the given insertion event. sendMarkerAndEnsureBackfilled(t, as, remoteCharlie, roomID, baseInsertionEventID) // FIXME: In the future, we should probably replace the following logic @@ -959,7 +970,8 @@ func TestImportHistoricalMessages(t *testing.T) { batchEventID := client.GetJSONFieldStr(t, batchSendResBody, "batch_event_id") baseInsertionEventID := client.GetJSONFieldStr(t, batchSendResBody, "base_insertion_event_id") - // Send the marker event + // Send the marker event which lets remote homeservers know there are + // some historical messages back at the given insertion event. markerEventID := sendMarkerAndEnsureBackfilled(t, as, alice, roomID, baseInsertionEventID) redactEventID(t, alice, roomID, insertionEventID, 403) @@ -1110,11 +1122,11 @@ func ensureVirtualUserRegistered(t *testing.T, c *client.CSAPI, virtualUserLocal } } +// Send the marker event which lets remote homeservers know there are +// some historical messages back at the given insertion event. func sendMarkerAndEnsureBackfilled(t *testing.T, as *client.CSAPI, c *client.CSAPI, roomID, insertionEventID string) (markerEventID string) { t.Helper() - // Send a marker event to let all of the homeservers know about the - // insertion point where all of the historical messages are at markerEvent := b.Event{ Type: markerEventType, Content: map[string]interface{}{