Skip to content

Commit 4dfcce5

Browse files
Better assert when TestDelayedEvents/delayed_state_events_are_kept_on_server_restart take too long to run for our assumptions to be correct (#829)
1 parent f86dadb commit 4dfcce5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/msc4140/delayed_event_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ func TestDelayedEvents(t *testing.T) {
453453
client.WithJSONBody(t, map[string]interface{}{}),
454454
getDelayQueryParam("900"),
455455
)
456+
beforeScheduleStateTimestamp2 := time.Now()
456457
user.MustDo(
457458
t,
458459
"PUT",
@@ -466,6 +467,15 @@ func TestDelayedEvents(t *testing.T) {
466467
time.Sleep(1 * time.Second)
467468
deployment.StartServer(t, hsName)
468469

470+
// The rest of the test assumes the second delayed event (10 second delay) still
471+
// hasn't been sent yet.
472+
if time.Now().Sub(beforeScheduleStateTimestamp2) > 10*time.Second {
473+
t.Fatalf(
474+
"Test took too long to run, cannot guarantee delayed event timings. " +
475+
"More than 10 seconds elapsed between scheduling the delayed event and now when we're about to check for it.",
476+
)
477+
}
478+
469479
matchDelayedEvents(t, user, 1)
470480
user.MustDo(t, "GET", getPathForState(roomID, eventType, stateKey1))
471481

0 commit comments

Comments
 (0)