mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-10 15:07:24 +00:00
29 lines
405 B
Go
29 lines
405 B
Go
package sync_test
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
tmsync "github.com/tendermint/tendermint/libs/sync"
|
|
)
|
|
|
|
func TestCloser(t *testing.T) {
|
|
closer := tmsync.NewCloser()
|
|
|
|
var timeout bool
|
|
|
|
select {
|
|
case <-closer.Done():
|
|
case <-time.After(time.Second):
|
|
timeout = true
|
|
}
|
|
|
|
for i := 0; i < 10; i++ {
|
|
closer.Close()
|
|
}
|
|
|
|
require.True(t, timeout)
|
|
<-closer.Done()
|
|
}
|