mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
0559d01261
* Preliminary support for relay nodes * lint * Add comment, remove TODO * work on relay address factory * dial relay node, if available * forgot new files * fix service registry breakage * added logging * Added a peer count with prometheus * always start mDNS * fix lint
36 lines
679 B
Go
36 lines
679 B
Go
package p2p
|
|
|
|
import (
|
|
"testing"
|
|
|
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
|
)
|
|
|
|
func TestLifecycle(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
|
|
s, err := NewServer(&ServerConfig{})
|
|
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")
|
|
}
|
|
}
|