Part 3 of Aligning Beacon Chain with Latest 2.1 - Processing Attestations (#423)

This commit is contained in:
terence tsao
2018-08-24 09:07:23 -07:00
committed by GitHub
parent 2ee9ec2120
commit 1598ae8605
16 changed files with 367 additions and 180 deletions

View File

@@ -38,8 +38,8 @@ func DefaultConfig() *Config {
return &Config{AttesterChanBuf: 5, ProposerChanBuf: 5}
}
// NewBeaconClient instantiates a service that interacts with a beacon node.
func NewBeaconClient(ctx context.Context, cfg *Config, rpcClient types.RPCClient) *Service {
// NewBeaconValidator instantiates a service that interacts with a beacon node.
func NewBeaconValidator(ctx context.Context, cfg *Config, rpcClient types.RPCClient) *Service {
ctx, cancel := context.WithCancel(ctx)
return &Service{
ctx: ctx,

View File

@@ -49,7 +49,7 @@ func (fc *mockClient) BeaconServiceClient() pb.BeaconServiceClient {
func TestChannelGetters(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
b := NewBeaconClient(context.Background(), &Config{AttesterChanBuf: 1, ProposerChanBuf: 1}, &mockClient{ctrl})
b := NewBeaconValidator(context.Background(), &Config{AttesterChanBuf: 1, ProposerChanBuf: 1}, &mockClient{ctrl})
b.proposerChan <- false
proposerVal := <-b.ProposerAssignment()
if proposerVal {
@@ -66,7 +66,7 @@ func TestLifecycle(t *testing.T) {
hook := logTest.NewGlobal()
ctrl := gomock.NewController(t)
defer ctrl.Finish()
b := NewBeaconClient(context.Background(), &Config{AttesterChanBuf: 0, ProposerChanBuf: 0}, &mockClient{ctrl})
b := NewBeaconValidator(context.Background(), &Config{AttesterChanBuf: 0, ProposerChanBuf: 0}, &mockClient{ctrl})
// Testing default config values.
cfg := DefaultConfig()
@@ -88,7 +88,7 @@ func TestFetchBeaconBlocks(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
b := NewBeaconClient(context.Background(), &Config{AttesterChanBuf: 1, ProposerChanBuf: 1}, &mockClient{ctrl})
b := NewBeaconValidator(context.Background(), &Config{AttesterChanBuf: 1, ProposerChanBuf: 1}, &mockClient{ctrl})
// Create mock for the stream returned by LatestBeaconBlock.
stream := internal.NewMockBeaconService_LatestBeaconBlockClient(ctrl)
@@ -163,7 +163,7 @@ func TestFetchCrystallizedState(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
b := NewBeaconClient(context.Background(), &Config{AttesterChanBuf: 0, ProposerChanBuf: 0}, &mockClient{ctrl})
b := NewBeaconValidator(context.Background(), &Config{AttesterChanBuf: 0, ProposerChanBuf: 0}, &mockClient{ctrl})
// Creating a faulty stream will trigger error.
stream := internal.NewMockBeaconService_LatestCrystallizedStateClient(ctrl)

View File

@@ -168,7 +168,7 @@ func (s *ShardEthereum) registerBeaconService() error {
if err := s.services.FetchService(&rpcService); err != nil {
return err
}
b := beacon.NewBeaconClient(context.TODO(), beacon.DefaultConfig(), rpcService)
b := beacon.NewBeaconValidator(context.TODO(), beacon.DefaultConfig(), rpcService)
return s.services.RegisterService(b)
}