Skip to content

Commit

Permalink
Merge pull request #7859 from ethereum-optimism/aj/monitor-unsubscribe
Browse files Browse the repository at this point in the history
op-challenger: Unsubscribe from l1 heads on shutdown
  • Loading branch information
ajsutton authored Oct 26, 2023
2 parents 2372c98 + 20fa6c5 commit c46093b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions op-challenger/game/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion op-challenger/game/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c46093b

Please sign in to comment.