mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-01 07:51:21 +00:00
e37c9d1334
* Add version log to slasher * Add slasher version log on startup * Remove duplicate log * Merge refs/heads/master into slasher-commit * Fix tet * Merge branch 'slasher-commit' of github.com:prysmaticlabs/prysm into slasher-commit * Undo * Fix log in rpc * Merge refs/heads/master into slasher-commit * Merge refs/heads/master into slasher-commit * Merge refs/heads/master into slasher-commit * Merge refs/heads/master into slasher-commit
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
package rpc
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
|
"github.com/sirupsen/logrus"
|
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
|
)
|
|
|
|
func init() {
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
logrus.SetOutput(ioutil.Discard)
|
|
}
|
|
|
|
func TestLifecycle_OK(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
rpcService := NewService(context.Background(), &Config{
|
|
Port: "7348",
|
|
CertFlag: "alice.crt",
|
|
KeyFlag: "alice.key",
|
|
})
|
|
|
|
rpcService.Start()
|
|
|
|
testutil.AssertLogsContain(t, hook, "listening on port")
|
|
|
|
if err := rpcService.Stop(); err != nil {
|
|
t.Error(err)
|
|
}
|
|
}
|
|
|
|
func TestStatus_CredentialError(t *testing.T) {
|
|
credentialErr := errors.New("credentialError")
|
|
s := &Service{credentialError: credentialErr}
|
|
|
|
if err := s.Status(); err != s.credentialError {
|
|
t.Errorf("Wanted: %v, got: %v", s.credentialError, s.Status())
|
|
}
|
|
}
|
|
|
|
func TestRPC_InsecureEndpoint(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
rpcService := NewService(context.Background(), &Config{
|
|
Port: "7777",
|
|
})
|
|
|
|
rpcService.Start()
|
|
|
|
testutil.AssertLogsContain(t, hook, fmt.Sprint("listening on port"))
|
|
|
|
if err := rpcService.Stop(); err != nil {
|
|
t.Error(err)
|
|
}
|
|
}
|