prysm-pulse/shared/p2p/service_norace_test.go
Federico Gimenez dd29481abe Fix beacon-chain/sync Test Race (#390)
* fix beacon-chain/sync test race

* address review comments

* remove unused file

* gazelle

* disable race for client/contracts

* address review comments

* fix conflict

* remove duplicated deps, embed

* remove unneeded file
2018-08-12 16:27:21 -04:00

36 lines
664 B
Go

package p2p
import (
"testing"
logTest "github.com/sirupsen/logrus/hooks/test"
)
func TestLifecycle(t *testing.T) {
hook := logTest.NewGlobal()
s, err := NewServer()
if err != nil {
t.Fatalf("Could not start a new server: %v", err)
}
s.Start()
msg := hook.Entries[0].Message
want := "Starting service"
if msg != want {
t.Errorf("incorrect log. wanted: %s. got: %v", want, msg)
}
s.Stop()
msg = hook.LastEntry().Message
want = "Stopping service"
if msg != want {
t.Errorf("incorrect log. wanted: %s. got: %v", want, msg)
}
// The context should have been cancelled.
if s.ctx.Err() == nil {
t.Error("Context was not cancelled")
}
}