Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Small Issue in Validator RPC Health Endpoint #7195

Merged
merged 7 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions validator/rpc/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,19 @@ import (

ptypes "github.com/gogo/protobuf/types"
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

// GetBeaconNodeConnection retrieves the current beacon node connection
// information, as well as its sync status.
func (s *Server) GetBeaconNodeConnection(ctx context.Context, _ *ptypes.Empty) (*pb.NodeConnectionResponse, error) {
genesis, err := s.genesisFetcher.GenesisInfo(ctx)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not retrieve genesis information: %v", err)
}
syncStatus, err := s.syncChecker.Syncing(ctx)
if err != nil || s.validatorService.Status() != nil {
return &pb.NodeConnectionResponse{
GenesisTime: uint64(time.Unix(genesis.GenesisTime.Seconds, 0).Unix()),
DepositContractAddress: genesis.DepositContractAddress,
BeaconNodeEndpoint: s.nodeGatewayEndpoint,
Connected: false,
Syncing: false,
GenesisTime: 0,
BeaconNodeEndpoint: s.nodeGatewayEndpoint,
Connected: false,
Syncing: false,
}, nil
}
return &pb.NodeConnectionResponse{
Expand Down
13 changes: 6 additions & 7 deletions validator/rpc/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ type mockGenesisFetcher struct{}
func (m *mockGenesisFetcher) GenesisInfo(ctx context.Context) (*ethpb.Genesis, error) {
genesis, err := ptypes.TimestampProto(time.Unix(0, 0))
if err != nil {
log.Info(err)
return nil, err
}
return &ethpb.Genesis{
GenesisTime: genesis,
DepositContractAddress: []byte("hello"),
GenesisTime: genesis,
}, nil
}

Expand All @@ -48,11 +48,10 @@ func TestServer_GetBeaconNodeConnection(t *testing.T) {
got, err := s.GetBeaconNodeConnection(ctx, &ptypes.Empty{})
require.NoError(t, err)
want := &pb.NodeConnectionResponse{
BeaconNodeEndpoint: endpoint,
Connected: false,
Syncing: false,
GenesisTime: uint64(time.Unix(0, 0).Unix()),
DepositContractAddress: []byte("hello"),
BeaconNodeEndpoint: endpoint,
Connected: false,
Syncing: false,
GenesisTime: uint64(time.Unix(0, 0).Unix()),
}
require.DeepEqual(t, want, got)
}