mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 05:17:22 +00:00
f342224410
* deprecate db * fix build * begin integrating new db * gaz * use more of the new db * newest implementation uses head state * remove more deprecated items * setup validators in state helper * fix up some tests with the new db * resolve broken build * gaz * begin ensuring tests pass * optional idx * list validator balances passing * default page size passing * only two failing * fixed most tests, found edge case * allow nil return and add proper tests * pass tests * fix head block root problem * working with the new db * every ethereumapis method now compliant with both dbs * pass in db into server * proposer server all compliant * validator service fully compliant * fix broken build, tests pass * spacing * compute state root and propose block tests passing with new db * complete proposer server tests revamp * validator tests halfway through passing with new db * more validator server tests * more than halfway there * so so close * all validators tests done * attester server tests fixing * use new api * attester server complete * complete
77 lines
1.8 KiB
Go
77 lines
1.8 KiB
Go
package rpc
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
ptypes "github.com/gogo/protobuf/types"
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/version"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/reflection"
|
|
)
|
|
|
|
type mockSyncChecker struct {
|
|
syncing bool
|
|
}
|
|
|
|
func (m *mockSyncChecker) Syncing() bool {
|
|
return m.syncing
|
|
}
|
|
|
|
func (m *mockSyncChecker) Status() error {
|
|
return nil
|
|
}
|
|
|
|
func TestNodeServer_GetSyncStatus(t *testing.T) {
|
|
mSync := &mockSyncChecker{false}
|
|
ns := &NodeServer{
|
|
syncChecker: mSync,
|
|
}
|
|
res, err := ns.GetSyncStatus(context.Background(), &ptypes.Empty{})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if res.Syncing != mSync.syncing {
|
|
t.Errorf("Wanted GetSyncStatus() = %v, received %v", mSync.syncing, res.Syncing)
|
|
}
|
|
mSync.syncing = true
|
|
res, err = ns.GetSyncStatus(context.Background(), &ptypes.Empty{})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if res.Syncing != mSync.syncing {
|
|
t.Errorf("Wanted GetSyncStatus() = %v, received %v", mSync.syncing, res.Syncing)
|
|
}
|
|
}
|
|
|
|
func TestNodeServer_GetVersion(t *testing.T) {
|
|
v := version.GetVersion()
|
|
ns := &NodeServer{}
|
|
res, err := ns.GetVersion(context.Background(), &ptypes.Empty{})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if res.Version != v {
|
|
t.Errorf("Wanted GetVersion() = %s, received %s", v, res.Version)
|
|
}
|
|
}
|
|
|
|
func TestNodeServer_GetImplementedServices(t *testing.T) {
|
|
server := grpc.NewServer()
|
|
ns := &NodeServer{
|
|
server: server,
|
|
}
|
|
ethpb.RegisterNodeServer(server, ns)
|
|
reflection.Register(server)
|
|
|
|
res, err := ns.ListImplementedServices(context.Background(), &ptypes.Empty{})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// We verify the services include the node service + the registered reflection service.
|
|
if len(res.Services) != 2 {
|
|
t.Errorf("Expected 2 services, received %d: %v", len(res.Services), res.Services)
|
|
}
|
|
}
|