prysm-pulse/validator/client/validator_aggregate_test.go
terence tsao f5cb04012e Aggregator selection from RPC to validator client (#4071)
* Config
* Updated proto
* Updated pool
* Updated RPC
* Updated validator client
* run time works
* Clean ups
* Fix tests
* Visibility
* Merge branch 'master' of https://github.com/prysmaticlabs/prysm into aggregator
* Raul's feedback
* Tests for RPC server
* Tests for validator client
* Span
* More tests
* Use go routine for SubmitAggregateAndProof
* Go routines
* Updated comments
* Use array of roles
* Fixed tests
* Build
* Update validator/client/runner.go

Co-Authored-By: Preston Van Loon <preston@prysmaticlabs.com>
* Update validator/client/runner.go

Co-Authored-By: Preston Van Loon <preston@prysmaticlabs.com>
* If
* Merge branch 'refactor-validator-roles' of https://github.com/prysmaticlabs/prysm into refactor-validator-roles
* Empty
* Feedback
* Merge branch 'master' of https://github.com/prysmaticlabs/prysm into aggregator
* Removed proto/eth/v1alpha1/shard_chain.pb.go?
* Cleaned up
* Revert
* Comments
* Lint
* Comment
* Merge branch 'master' into aggregator
2019-11-22 05:11:38 +00:00

47 lines
1.4 KiB
Go

package client
import (
"context"
"testing"
"github.com/golang/mock/gomock"
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
"github.com/prysmaticlabs/prysm/shared/testutil"
logTest "github.com/sirupsen/logrus/hooks/test"
)
func TestSubmitAggregateAndProof_AssignmentRequestFailure(t *testing.T) {
hook := logTest.NewGlobal()
validator, _, finish := setup(t)
validator.assignments = &pb.AssignmentResponse{ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{}}
defer finish()
validator.SubmitAggregateAndProof(context.Background(), 0, validatorPubKey)
testutil.AssertLogsContain(t, hook, "Could not fetch validator assignment")
}
func TestSubmitAggregateAndProof_Ok(t *testing.T) {
hook := logTest.NewGlobal()
validator, m, finish := setup(t)
defer finish()
validator.assignments = &pb.AssignmentResponse{ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{
{
PublicKey: validatorKey.PublicKey.Marshal(),
},
}}
m.validatorClient.EXPECT().DomainData(
gomock.Any(), // ctx
gomock.Any(), // epoch
).Return(&pb.DomainResponse{}, nil /*err*/)
m.aggregatorClient.EXPECT().SubmitAggregateAndProof(
gomock.Any(), // ctx
gomock.AssignableToTypeOf(&pb.AggregationRequest{}),
).Return(&pb.AggregationResponse{}, nil)
validator.SubmitAggregateAndProof(context.Background(), 0, validatorPubKey)
testutil.AssertLogsContain(t, hook, "Assigned and submitted aggregation and proof request")
}