diff --git a/op-challenger/game/monitor.go b/op-challenger/game/monitor.go index b6ddc64adcea..a8c9c694b20c 100644 --- a/op-challenger/game/monitor.go +++ b/op-challenger/game/monitor.go @@ -141,6 +141,7 @@ func (m *gameMonitor) MonitorGames(ctx context.Context) error { for { select { case <-ctx.Done(): + m.l1HeadsSub.Unsubscribe() return nil case err, ok := <-m.l1HeadsSub.Err(): if !ok { diff --git a/op-challenger/game/monitor_test.go b/op-challenger/game/monitor_test.go index b869dad350f6..7295fdb74a3d 100644 --- a/op-challenger/game/monitor_test.go +++ b/op-challenger/game/monitor_test.go @@ -100,7 +100,8 @@ func TestMonitorGames(t *testing.T) { defer cancel() go func() { - waitErr := wait.For(context.Background(), 100*time.Millisecond, func() (bool, error) { + // Wait for the subscription to be created + waitErr := wait.For(context.Background(), 5*time.Second, func() (bool, error) { return mockHeadSource.sub != nil, nil }) require.NoError(t, waitErr)