You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
414 B

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