mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Part 3 of Aligning Beacon Chain with Latest 2.1 - Processing Attestations (#423)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user