mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Fix Small Issue in Validator RPC Health Endpoint (#7195)
* amend node connection response * imports * fix err * fix conf * err * test fix * Merge branch 'master' into fix-health-endpoint
This commit is contained in:
@@ -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{
|
||||
|
||||
@@ -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 ðpb.Genesis{
|
||||
GenesisTime: genesis,
|
||||
DepositContractAddress: []byte("hello"),
|
||||
GenesisTime: genesis,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user