mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
5aac06f04e
* begin move * use same import path * imports * regen protos * regen * no rename * generate ssz * gaz * fmt * edit build file * imports * modify * remove generated files * remove protos * edit imports in prysm * beacon chain all builds * edit script * add generated pbs * add replace rules * license for ethereumapis protos * change visibility * fmt * update build files to gaz ignore * use proper form * edit imports * wrap block * revert scripts * revert go mod
55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package rpc
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/golang/protobuf/ptypes/empty"
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
|
|
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
"github.com/prysmaticlabs/prysm/validator/client"
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
)
|
|
|
|
type mockSyncChecker struct {
|
|
syncing bool
|
|
}
|
|
|
|
func (m *mockSyncChecker) Syncing(_ context.Context) (bool, error) {
|
|
return m.syncing, nil
|
|
}
|
|
|
|
type mockGenesisFetcher struct{}
|
|
|
|
func (m *mockGenesisFetcher) GenesisInfo(_ context.Context) (*ethpb.Genesis, error) {
|
|
genesis := timestamppb.New(time.Unix(0, 0))
|
|
return ðpb.Genesis{
|
|
GenesisTime: genesis,
|
|
}, nil
|
|
}
|
|
|
|
func TestServer_GetBeaconNodeConnection(t *testing.T) {
|
|
ctx := context.Background()
|
|
endpoint := "localhost:90210"
|
|
vs, err := client.NewValidatorService(ctx, &client.Config{})
|
|
require.NoError(t, err)
|
|
s := &Server{
|
|
walletInitialized: true,
|
|
validatorService: vs,
|
|
syncChecker: &mockSyncChecker{syncing: false},
|
|
genesisFetcher: &mockGenesisFetcher{},
|
|
nodeGatewayEndpoint: endpoint,
|
|
}
|
|
got, err := s.GetBeaconNodeConnection(ctx, &empty.Empty{})
|
|
require.NoError(t, err)
|
|
want := &pb.NodeConnectionResponse{
|
|
BeaconNodeEndpoint: endpoint,
|
|
Connected: false,
|
|
Syncing: false,
|
|
GenesisTime: uint64(time.Unix(0, 0).Unix()),
|
|
}
|
|
require.DeepEqual(t, want, got)
|
|
}
|