Commit 20fa6c57 authored by Adrian Sutton's avatar Adrian Sutton

op-challenger: Unsubscribe from l1 heads on shutdown

Avoids leaving a background function running that could trigger logging.
parent 48a01dac
...@@ -141,6 +141,7 @@ func (m *gameMonitor) MonitorGames(ctx context.Context) error { ...@@ -141,6 +141,7 @@ func (m *gameMonitor) MonitorGames(ctx context.Context) error {
for { for {
select { select {
case <-ctx.Done(): case <-ctx.Done():
m.l1HeadsSub.Unsubscribe()
return nil return nil
case err, ok := <-m.l1HeadsSub.Err(): case err, ok := <-m.l1HeadsSub.Err():
if !ok { if !ok {
......
...@@ -100,7 +100,8 @@ func TestMonitorGames(t *testing.T) { ...@@ -100,7 +100,8 @@ func TestMonitorGames(t *testing.T) {
defer cancel() defer cancel()
go func() { 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 return mockHeadSource.sub != nil, nil
}) })
require.NoError(t, waitErr) require.NoError(t, waitErr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment