From 42df759bf04e1d2a153efc3a4ee231fc483fab70 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 17 Dec 2025 13:59:12 -0600 Subject: [PATCH 1/2] Better assert when the test takes too long to run --- tests/msc4140/delayed_event_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/msc4140/delayed_event_test.go b/tests/msc4140/delayed_event_test.go index 8def039e..7cbee7a2 100644 --- a/tests/msc4140/delayed_event_test.go +++ b/tests/msc4140/delayed_event_test.go @@ -453,6 +453,7 @@ func TestDelayedEvents(t *testing.T) { client.WithJSONBody(t, map[string]interface{}{}), getDelayQueryParam("900"), ) + beforeScheduleStateTimestamp2 := time.Now() user.MustDo( t, "PUT", @@ -466,6 +467,15 @@ func TestDelayedEvents(t *testing.T) { time.Sleep(1 * time.Second) deployment.StartServer(t, hsName) + // The rest of the test assumes the second delayed event (10 second delay) still has + // hasn't been sent yet. + if time.Now().Sub(beforeScheduleStateTimestamp2) > 10*time.Second { + t.Fatalf( + "Test took too long to run, cannot guarantee delayed event timings. " + + "More than 10 seconds elapsed between scheduling the delayed event and now when we're about to check for it.", + ) + } + matchDelayedEvents(t, user, 1) user.MustDo(t, "GET", getPathForState(roomID, eventType, stateKey1)) From f21e3df215f00b3444f579250471c54099ecff34 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 19 Dec 2025 14:23:27 -0600 Subject: [PATCH 2/2] Remove extra `has` Co-authored-by: Devon Hudson --- tests/msc4140/delayed_event_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/msc4140/delayed_event_test.go b/tests/msc4140/delayed_event_test.go index 7cbee7a2..42856120 100644 --- a/tests/msc4140/delayed_event_test.go +++ b/tests/msc4140/delayed_event_test.go @@ -467,7 +467,7 @@ func TestDelayedEvents(t *testing.T) { time.Sleep(1 * time.Second) deployment.StartServer(t, hsName) - // The rest of the test assumes the second delayed event (10 second delay) still has + // The rest of the test assumes the second delayed event (10 second delay) still // hasn't been sent yet. if time.Now().Sub(beforeScheduleStateTimestamp2) > 10*time.Second { t.Fatalf(