Skip to content

Commit

Permalink
limit test runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Inphi committed Apr 20, 2023
1 parent 7ee7e28 commit 236875d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions op-program/preimage/hints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"sync"
"testing"
"time"

"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -35,7 +36,6 @@ func TestHints(t *testing.T) {

got := make(chan string, len(hints))
go func() {
println("MENA")
defer wg.Done()
hr := NewHintReader(b)
for i := 0; i < len(hints); i++ {
Expand All @@ -49,7 +49,17 @@ func TestHints(t *testing.T) {
require.NoError(t, err)
}
}()
wg.Wait()

done := make(chan struct{})
go func() {
wg.Wait()
close(done)
}()
select {
case <-time.After(time.Second * 20):
t.Error("reader/writer stuck")
case <-done:
}

require.Equal(t, len(hints), len(got), "got all hints")
for _, h := range hints {
Expand Down

0 comments on commit 236875d

Please sign in to comment.