prysm-pulse/slasher/rpc/service_test.go
Radosław Kapka 47fdb3b99a
Revert "Rename NewService to New (#8337)" (#8440)
* Revert "Rename `NewService` to `New` (#8337)"

This reverts commit d121b19145.

# Conflicts:
#	beacon-chain/sync/initial-sync/round_robin_test.go

* fix name in test

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
2021-02-12 17:45:22 +00:00

45 lines
1012 B
Go

package rpc
import (
"context"
"errors"
"testing"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
logTest "github.com/sirupsen/logrus/hooks/test"
)
func TestLifecycle_OK(t *testing.T) {
hook := logTest.NewGlobal()
rpcService := NewService(context.Background(), &Config{
Port: "7348",
CertFlag: "alice.crt",
KeyFlag: "alice.key",
})
rpcService.Start()
require.LogsContain(t, hook, "listening on port")
require.NoError(t, rpcService.Stop())
}
func TestStatus_CredentialError(t *testing.T) {
credentialErr := errors.New("credentialError")
s := &Service{credentialError: credentialErr}
assert.ErrorContains(t, s.credentialError.Error(), s.Status())
}
func TestRPC_InsecureEndpoint(t *testing.T) {
hook := logTest.NewGlobal()
rpcService := NewService(context.Background(), &Config{
Port: "7777",
})
rpcService.Start()
require.LogsContain(t, hook, "listening on port")
require.NoError(t, rpcService.Stop())
}