From 6f39dcc7f8c39c4f60da67e25ddf271ab7b37be7 Mon Sep 17 00:00:00 2001 From: Terence Tsao Date: Thu, 19 Mar 2020 15:26:07 -0700 Subject: [PATCH] Fixed failed tests --- beacon-chain/core/blocks/block_operations_test.go | 3 ++- beacon-chain/core/blocks/eth1_data_test.go | 4 ++-- beacon-chain/rpc/validator/proposer.go | 2 +- beacon-chain/rpc/validator/proposer_test.go | 9 ++++++--- validator/client/validator_test.go | 1 + 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/beacon-chain/core/blocks/block_operations_test.go b/beacon-chain/core/blocks/block_operations_test.go index dece01e2ece3..2d4a37bcc05a 100644 --- a/beacon-chain/core/blocks/block_operations_test.go +++ b/beacon-chain/core/blocks/block_operations_test.go @@ -399,7 +399,8 @@ func TestProcessEth1Data_SetsCorrectly(t *testing.T) { }, } var err error - for i := uint64(0); i < params.BeaconConfig().SlotsPerEth1VotingPeriod; i++ { + period := params.BeaconConfig().EpochsPerEth1VotingPeriod * params.BeaconConfig().SlotsPerEpoch + for i := uint64(0); i < period; i++ { beaconState, err = blocks.ProcessEth1DataInBlock(beaconState, block) if err != nil { t.Fatal(err) diff --git a/beacon-chain/core/blocks/eth1_data_test.go b/beacon-chain/core/blocks/eth1_data_test.go index cfa56103aaae..e0ad32e300f8 100644 --- a/beacon-chain/core/blocks/eth1_data_test.go +++ b/beacon-chain/core/blocks/eth1_data_test.go @@ -38,7 +38,7 @@ func TestEth1DataHasEnoughSupport(t *testing.T) { DepositCount: 1, DepositRoot: []byte("root"), }, - hasSupport: true, + hasSupport: false, votingPeriodLength: 7, }, { stateVotes: []*ethpb.Eth1Data{ @@ -90,7 +90,7 @@ func TestEth1DataHasEnoughSupport(t *testing.T) { for i, tt := range tests { t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { c := params.BeaconConfig() - c.SlotsPerEth1VotingPeriod = tt.votingPeriodLength + c.EpochsPerEth1VotingPeriod = tt.votingPeriodLength params.OverrideBeaconConfig(c) s, _ := beaconstate.InitializeFromProto(&pb.BeaconState{ diff --git a/beacon-chain/rpc/validator/proposer.go b/beacon-chain/rpc/validator/proposer.go index f391b370add2..f0675a56ad6c 100644 --- a/beacon-chain/rpc/validator/proposer.go +++ b/beacon-chain/rpc/validator/proposer.go @@ -183,7 +183,7 @@ func (vs *Server) mockETH1DataVote(ctx context.Context, slot uint64) (*ethpb.Eth // DepositCount = state.eth1_deposit_index, // BlockHash = hash(hash(current_epoch + slot_in_voting_period)), // ) - slotInVotingPeriod := slot % params.BeaconConfig().EpochsPerEth1VotingPeriod * params.BeaconConfig().SlotsPerEpoch + slotInVotingPeriod := slot % (params.BeaconConfig().EpochsPerEth1VotingPeriod * params.BeaconConfig().SlotsPerEpoch) headState, err := vs.HeadFetcher.HeadState(ctx) if err != nil { return nil, err diff --git a/beacon-chain/rpc/validator/proposer_test.go b/beacon-chain/rpc/validator/proposer_test.go index a0044998588f..9ac15d9e82f5 100644 --- a/beacon-chain/rpc/validator/proposer_test.go +++ b/beacon-chain/rpc/validator/proposer_test.go @@ -411,7 +411,8 @@ func TestPendingDeposits_Eth1DataVoteOK(t *testing.T) { BlockHash: blockHash, DepositCount: 3, } - for i := 0; i <= int(params.BeaconConfig().SlotsPerEth1VotingPeriod/2); i++ { + period := params.BeaconConfig().EpochsPerEth1VotingPeriod * params.BeaconConfig().SlotsPerEpoch + for i := 0; i <= int(period/2); i++ { votes = append(votes, vote) } @@ -635,7 +636,8 @@ func TestPendingDeposits_FollowsCorrectEth1Block(t *testing.T) { BlockHash: []byte("0x1"), DepositCount: 7, } - for i := 0; i <= int(params.BeaconConfig().SlotsPerEth1VotingPeriod/2); i++ { + period := params.BeaconConfig().EpochsPerEth1VotingPeriod * params.BeaconConfig().SlotsPerEpoch + for i := 0; i <= int(period/2); i++ { votes = append(votes, vote) } @@ -1232,7 +1234,8 @@ func TestEth1Data_MockEnabled(t *testing.T) { if err != nil { t.Fatal(err) } - wantedSlot := 100 % params.BeaconConfig().SlotsPerEth1VotingPeriod + period := params.BeaconConfig().EpochsPerEth1VotingPeriod * params.BeaconConfig().SlotsPerEpoch + wantedSlot := 100 % period currentEpoch := helpers.SlotToEpoch(100) enc, err := ssz.Marshal(currentEpoch + wantedSlot) if err != nil { diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index 5f3445c652af..81f4a290416b 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -343,6 +343,7 @@ func TestWaitMultipleActivation_LogsActivationEpochOK(t *testing.T) { } testutil.AssertLogsContain(t, hook, "Validator activated") } + func TestWaitActivation_NotAllValidatorsActivatedOK(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish()