2021-01-05 21:06:51 +00:00
|
|
|
package nodev1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"runtime"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
ptypes "github.com/gogo/protobuf/types"
|
2021-01-06 20:11:20 +00:00
|
|
|
syncmock "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
|
2021-01-05 21:06:51 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/version"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetVersion(t *testing.T) {
|
|
|
|
semVer := version.GetSemanticVersion()
|
|
|
|
os := runtime.GOOS
|
|
|
|
arch := runtime.GOARCH
|
|
|
|
res, err := (&Server{}).GetVersion(context.Background(), &ptypes.Empty{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
v := res.Data.Version
|
|
|
|
assert.Equal(t, true, strings.Contains(v, semVer))
|
|
|
|
assert.Equal(t, true, strings.Contains(v, os))
|
|
|
|
assert.Equal(t, true, strings.Contains(v, arch))
|
|
|
|
}
|
2021-01-06 20:11:20 +00:00
|
|
|
|
|
|
|
func TestGetHealth(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
checker := &syncmock.Sync{}
|
|
|
|
s := &Server{
|
|
|
|
SyncChecker: checker,
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := s.GetHealth(ctx, &ptypes.Empty{})
|
|
|
|
require.ErrorContains(t, "node not initialized or having issues", err)
|
|
|
|
checker.IsInitialized = true
|
|
|
|
_, err = s.GetHealth(ctx, &ptypes.Empty{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
checker.IsInitialized = false
|
|
|
|
checker.IsSyncing = true
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|