github.com/number571/tendermint@v0.34.11-gost/internal/libs/sync/closer_test.go (about) 1 package sync_test 2 3 import ( 4 "testing" 5 "time" 6 7 tmsync "github.com/number571/tendermint/internal/libs/sync" 8 "github.com/stretchr/testify/require" 9 ) 10 11 func TestCloser(t *testing.T) { 12 closer := tmsync.NewCloser() 13 14 var timeout bool 15 16 select { 17 case <-closer.Done(): 18 case <-time.After(time.Second): 19 timeout = true 20 } 21 22 for i := 0; i < 10; i++ { 23 closer.Close() 24 } 25 26 require.True(t, timeout) 27 <-closer.Done() 28 }