Skip to content

Commit 5e38528

Browse files
author
Sean Quah
committed
Add a test for receiving an event with a missing prev event, with one missing and one known prev event
1 parent 0643979 commit 5e38528

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/federation_room_join_partial_state_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,43 @@ func TestPartialStateJoin(t *testing.T) {
221221
testReceiveEventDuringPartialStateJoin(t, deployment, alice, psjResult, eventB)
222222
})
223223

224+
// we should be able to receive events with missing prevs over federation during the resync
225+
t.Run("CanReceiveEventsWithMissingPrevWithHalfMissingPrevsDuringPartialStateJoin", func(t *testing.T) {
226+
deployment := Deploy(t, b.BlueprintAlice)
227+
defer deployment.Destroy(t)
228+
alice := deployment.Client(t, "hs1", "@alice:hs1")
229+
230+
psjResult := beginPartialStateJoin(t, deployment, alice)
231+
defer psjResult.Destroy()
232+
233+
// we construct the following event graph:
234+
// +---------+
235+
// v \
236+
// ... <-- M <-- A <-- B <-- C
237+
//
238+
// M is @alice:hs1's join event.
239+
// A, B and C are regular m.room.messsage events sent by @derek from Complement.
240+
//
241+
// initially, hs1 only knows about event M.
242+
// we send only event C to hs1.
243+
eventM := psjResult.ServerRoom.CurrentState("m.room.member", alice.UserID)
244+
eventA := psjResult.CreateMessageEvent(t, "derek", []string{eventM.EventID()})
245+
eventB := psjResult.CreateMessageEvent(t, "derek", []string{eventA.EventID(), eventM.EventID()})
246+
eventC := psjResult.CreateMessageEvent(t, "derek", []string{eventB.EventID()})
247+
t.Logf("%s's m.room.member event is %s", *eventM.StateKey(), eventM.EventID())
248+
t.Logf("Derek sent event A with ID %s", eventA.EventID())
249+
t.Logf("Derek sent event B with ID %s", eventB.EventID())
250+
t.Logf("Derek sent event C with ID %s", eventC.EventID())
251+
psjResult.AllowStateRequestForEvent(eventA.EventID())
252+
253+
// the HS will make a /get_missing_events request for the missing prev event of event C,
254+
// to which we respond with event B only.
255+
handleGetMissingEventsRequests(t, psjResult.Server, psjResult.ServerRoom, []*gomatrixserverlib.Event{eventB})
256+
257+
// send event C to hs1
258+
testReceiveEventDuringPartialStateJoin(t, deployment, alice, psjResult, eventC)
259+
})
260+
224261
// a request to (client-side) /members?at= should block until the (federation) /state request completes
225262
// TODO(faster_joins): also need to test /state, and /members without an `at`, which follow a different path
226263
t.Run("MembersRequestBlocksDuringPartialStateJoin", func(t *testing.T) {

0 commit comments

Comments
 (0)