mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 12:51:22 +00:00
prefer tickers to time.Sleep (Refs #790)
This commit is contained in:
@ -20,19 +20,23 @@ func TestNodeStartStop(t *testing.T) {
|
||||
n.Start()
|
||||
t.Logf("Started node %v", n.sw.NodeInfo())
|
||||
|
||||
// Wait a bit to initialize
|
||||
// TODO remove time.Sleep(), make asynchronous.
|
||||
time.Sleep(time.Second * 2)
|
||||
ticker := time.NewTicker(10 * time.Millisecond)
|
||||
select {
|
||||
case <-ticker.C:
|
||||
if n.IsRunning() {
|
||||
return
|
||||
}
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("timed out waiting for start")
|
||||
}
|
||||
|
||||
ch := make(chan struct{}, 1)
|
||||
go func() {
|
||||
n.Stop()
|
||||
ch <- struct{}{}
|
||||
}()
|
||||
ticker := time.NewTicker(time.Second * 5)
|
||||
|
||||
select {
|
||||
case <-ch:
|
||||
case <-ticker.C:
|
||||
case <-n.Quit:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("timed out waiting for shutdown")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user