Skip to content

Commit

Permalink
fix unstable test (ssvlabs#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
amirylm authored Dec 21, 2022
1 parent d6e3d4c commit e82b9c7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions utils/async/interval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package async
import (
"context"
"github.com/stretchr/testify/require"
"runtime"
"sync/atomic"
"testing"
"time"
Expand All @@ -18,6 +19,7 @@ func TestInterval(t *testing.T) {
<-time.After(time.Millisecond * 25)
require.Greater(t, atomic.LoadInt32(&i), int32(1))
cancel()
runtime.Gosched() // let the goroutine within Interval() to finish
val := atomic.LoadInt32(&i)
<-time.After(time.Millisecond * 25)
require.Equal(t, val, atomic.LoadInt32(&i))
Expand Down

0 comments on commit e82b9c7

Please sign in to comment.