mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 12:27:18 +00:00
43 lines
1009 B
Go
43 lines
1009 B
Go
|
package rpc
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"testing"
|
||
|
|
||
|
ptypes "github.com/gogo/protobuf/types"
|
||
|
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
|
||
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||
|
"github.com/prysmaticlabs/prysm/validator/client"
|
||
|
)
|
||
|
|
||
|
type mockSyncChecker struct {
|
||
|
syncing bool
|
||
|
}
|
||
|
|
||
|
func (m *mockSyncChecker) Syncing(ctx context.Context) (bool, error) {
|
||
|
return m.syncing, nil
|
||
|
}
|
||
|
|
||
|
func TestServer_GetBeaconNodeConnection(t *testing.T) {
|
||
|
ctx := context.Background()
|
||
|
endpoint := "localhost:90210"
|
||
|
vs, err := client.NewValidatorService(ctx, &client.Config{
|
||
|
Endpoint: endpoint,
|
||
|
})
|
||
|
require.NoError(t, err)
|
||
|
s := &Server{
|
||
|
walletInitialized: true,
|
||
|
validatorService: vs,
|
||
|
syncChecker: &mockSyncChecker{syncing: true},
|
||
|
}
|
||
|
got, err := s.GetBeaconNodeConnection(ctx, &ptypes.Empty{})
|
||
|
require.NoError(t, err)
|
||
|
|
||
|
want := &pb.NodeConnectionResponse{
|
||
|
BeaconNodeEndpoint: endpoint,
|
||
|
Connected: false,
|
||
|
Syncing: true,
|
||
|
}
|
||
|
require.DeepEqual(t, want, got)
|
||
|
}
|