Makes test naming consistent across codebase (#1636)

This commit is contained in:
Ivan Martinez
2019-02-22 10:11:26 -05:00
committed by terence tsao
parent 9f533fb7ae
commit 0d29b2cd91
53 changed files with 404 additions and 305 deletions

View File

@@ -21,7 +21,7 @@ func init() {
logrus.SetLevel(logrus.DebugLevel)
}
func TestUpdateLatestAttestation_Ok(t *testing.T) {
func TestUpdateLatestAttestation_UpdatesLatest(t *testing.T) {
beaconDB := internal.SetupDB(t)
defer internal.TeardownDB(t, beaconDB)
if err := beaconDB.SaveState(&pb.BeaconState{
@@ -59,7 +59,7 @@ func TestUpdateLatestAttestation_Ok(t *testing.T) {
}
}
func TestAttestationPool_Ok(t *testing.T) {
func TestAttestationPool_UpdatesAttestationPool(t *testing.T) {
hook := logTest.NewGlobal()
beaconDB := internal.SetupDB(t)
defer internal.TeardownDB(t, beaconDB)
@@ -88,7 +88,7 @@ func TestAttestationPool_Ok(t *testing.T) {
testutil.AssertLogsContain(t, hook, "Updated attestation pool for attestation")
}
func TestLatestAttestation_Ok(t *testing.T) {
func TestLatestAttestation_ReturnsLatestAttestation(t *testing.T) {
beaconDB := internal.SetupDB(t)
defer internal.TeardownDB(t, beaconDB)
pubKey := []byte{'A'}
@@ -163,7 +163,7 @@ func TestLatestAttestationTarget_CantGetAttestation(t *testing.T) {
}
}
func TestLatestAttestationTarget_Ok(t *testing.T) {
func TestLatestAttestationTarget_ReturnsLatestAttestedBlock(t *testing.T) {
beaconDB := internal.SetupDB(t)
defer internal.TeardownDB(t, beaconDB)

View File

@@ -238,7 +238,7 @@ func SetSlotInState(service *ChainService, slot uint64) error {
return service.beaconDB.SaveState(bState)
}
func TestStartStopUninitializedChain(t *testing.T) {
func TestChainStartStop_Uninitialized(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
@@ -273,7 +273,7 @@ func TestStartStopUninitializedChain(t *testing.T) {
testutil.AssertLogsContain(t, hook, "ChainStart time reached, starting the beacon chain!")
}
func TestStartUninitializedChainWithoutConfigPOWChain(t *testing.T) {
func TestChainStartStop_UninitializedAndNoPOWChain(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
@@ -292,7 +292,7 @@ func TestStartUninitializedChainWithoutConfigPOWChain(t *testing.T) {
testutil.AssertLogsContain(t, hook, "Not configured web3Service for POW chain")
}
func TestStartStopInitializedChain(t *testing.T) {
func TestChainStartStop_Initialized(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
@@ -322,7 +322,7 @@ func TestStartStopInitializedChain(t *testing.T) {
testutil.AssertLogsContain(t, hook, "Beacon chain data already exists, starting service")
}
func TestRunningChainServiceFaultyPOWChain(t *testing.T) {
func TestChainService_FaultyPOWChain(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
@@ -376,7 +376,7 @@ func TestRunningChainServiceFaultyPOWChain(t *testing.T) {
testutil.AssertLogsContain(t, hook, "unable to retrieve POW chain reference block")
}
func TestRunningChainService(t *testing.T) {
func TestChainService_Starts(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
@@ -502,7 +502,7 @@ func TestReceiveBlock_RemovesPendingDeposits(t *testing.T) {
testutil.AssertLogsContain(t, hook, "Executing state transition")
}
func TestDoesPOWBlockExist(t *testing.T) {
func TestPOWBlockExists_UsingDepositRootHash(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
@@ -527,7 +527,7 @@ func TestDoesPOWBlockExist(t *testing.T) {
testutil.AssertLogsContain(t, hook, "fetching PoW block corresponding to mainchain reference failed")
}
func TestUpdateHead(t *testing.T) {
func TestUpdateHead_SavesBlock(t *testing.T) {
beaconState, err := state.GenesisBeaconState(nil, 0, nil)
if err != nil {
t.Fatalf("Cannot create genesis beacon state: %v", err)
@@ -610,7 +610,7 @@ func TestUpdateHead(t *testing.T) {
}
}
func TestIsBlockReadyForProcessing(t *testing.T) {
func TestIsBlockReadyForProcessing_ValidBlock(t *testing.T) {
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
chainService := setupBeaconChain(t, false, db, true)

View File

@@ -7,7 +7,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/trieutil"
)
func TestSimulatedBackendStop(t *testing.T) {
func TestSimulatedBackendStop_ShutsDown(t *testing.T) {
backend, err := NewSimulatedBackend()
if err != nil {
@@ -18,7 +18,7 @@ func TestSimulatedBackendStop(t *testing.T) {
}
}
func TestGenerateBlocks(t *testing.T) {
func TestGenerateBlockAndAdvanceChain_IncreasesSlot(t *testing.T) {
backend, err := NewSimulatedBackend()
if err != nil {
t.Fatalf("Could not create a new simulated backedn %v", err)
@@ -51,7 +51,7 @@ func TestGenerateBlocks(t *testing.T) {
}
func TestGenerateNilBlocks(t *testing.T) {
func TestGenerateNilBlockAndAdvanceChain_IncreasesSlot(t *testing.T) {
backend, err := NewSimulatedBackend()
if err != nil {
t.Fatalf("Could not create a new simulated backedn %v", err)

View File

@@ -6,7 +6,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/chaintest/backend"
)
func TestFromYaml(t *testing.T) {
func TestFromYaml_Pass(t *testing.T) {
tests, err := readTestsFromYaml("./tests")
if err != nil {
t.Fatalf("Failed to read yaml files: %v", err)

View File

@@ -6,7 +6,7 @@ import (
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
)
func TestIsDoubleVote(t *testing.T) {
func TestIsDoubleVote_SameAndDifferentEpochs(t *testing.T) {
att1 := &pb.AttestationData{
Slot: 0,
}
@@ -26,7 +26,7 @@ func TestIsDoubleVote(t *testing.T) {
}
}
func TestIsSurroundVote(t *testing.T) {
func TestIsSurroundVote_SameAndDifferentEpochs(t *testing.T) {
att1 := &pb.AttestationData{
Slot: 0,
JustifiedEpoch: 0,
@@ -48,5 +48,4 @@ func TestIsSurroundVote(t *testing.T) {
if !IsSurroundVote(att1, att2) {
t.Error("It is not a surround vote despite all the surround conditions being fulfilled")
}
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
)
func TestFFGSrcRewardsPenalties(t *testing.T) {
func TestFFGSrcRewardsPenalties_AccurateBalances(t *testing.T) {
tests := []struct {
voted []uint64
balanceAfterSrcRewardPenalties []uint64
@@ -47,7 +47,7 @@ func TestFFGSrcRewardsPenalties(t *testing.T) {
}
}
func TestFFGTargetRewardsPenalties(t *testing.T) {
func TestFFGTargetRewardsPenalties_AccurateBalances(t *testing.T) {
tests := []struct {
voted []uint64
balanceAfterTgtRewardPenalties []uint64
@@ -86,7 +86,7 @@ func TestFFGTargetRewardsPenalties(t *testing.T) {
}
}
func TestChainHeadRewardsPenalties(t *testing.T) {
func TestChainHeadRewardsPenalties_AccuratePenalties(t *testing.T) {
tests := []struct {
voted []uint64
balanceAfterHeadRewardPenalties []uint64
@@ -125,7 +125,7 @@ func TestChainHeadRewardsPenalties(t *testing.T) {
}
}
func TestInclusionDistRewards_Ok(t *testing.T) {
func TestInclusionDistRewards_AccurateRewards(t *testing.T) {
validators := make([]*pb.Validator, params.BeaconConfig().DepositsForChainStart)
for i := 0; i < len(validators); i++ {
validators[i] = &pb.Validator{
@@ -180,7 +180,7 @@ func TestInclusionDistRewards_Ok(t *testing.T) {
}
}
func TestInclusionDistRewards_NotOk(t *testing.T) {
func TestInclusionDistRewards_OutOfBounds(t *testing.T) {
validators := make([]*pb.Validator, params.BeaconConfig().SlotsPerEpoch*2)
for i := 0; i < len(validators); i++ {
validators[i] = &pb.Validator{
@@ -211,7 +211,7 @@ func TestInclusionDistRewards_NotOk(t *testing.T) {
}
}
func TestInactivityFFGSrcPenalty(t *testing.T) {
func TestInactivityFFGSrcPenalty_AccuratePenalties(t *testing.T) {
tests := []struct {
voted []uint64
balanceAfterFFGSrcPenalty []uint64
@@ -250,7 +250,7 @@ func TestInactivityFFGSrcPenalty(t *testing.T) {
}
}
func TestInactivityFFGTargetPenalty(t *testing.T) {
func TestInactivityFFGTargetPenalty_AccuratePenalties(t *testing.T) {
tests := []struct {
voted []uint64
balanceAfterFFGTargetPenalty []uint64
@@ -289,7 +289,7 @@ func TestInactivityFFGTargetPenalty(t *testing.T) {
}
}
func TestInactivityHeadPenalty(t *testing.T) {
func TestInactivityHeadPenalty_AccuratePenalties(t *testing.T) {
tests := []struct {
voted []uint64
balanceAfterInactivityHeadPenalty []uint64
@@ -324,7 +324,7 @@ func TestInactivityHeadPenalty(t *testing.T) {
}
}
func TestInactivityExitedPenality(t *testing.T) {
func TestInactivityExitedPenality_AccuratePenalties(t *testing.T) {
tests := []struct {
balanceAfterExitedPenalty []uint64
epochsSinceFinality uint64
@@ -359,7 +359,7 @@ func TestInactivityExitedPenality(t *testing.T) {
}
}
func TestInactivityInclusionPenalty_Ok(t *testing.T) {
func TestInactivityInclusionPenalty_AccuratePenalties(t *testing.T) {
validators := make([]*pb.Validator, params.BeaconConfig().DepositsForChainStart)
for i := 0; i < len(validators); i++ {
validators[i] = &pb.Validator{
@@ -413,7 +413,7 @@ func TestInactivityInclusionPenalty_Ok(t *testing.T) {
}
}
func TestInactivityInclusionPenalty_NotOk(t *testing.T) {
func TestInactivityInclusionPenalty_OutOfBounds(t *testing.T) {
validators := make([]*pb.Validator, params.BeaconConfig().SlotsPerEpoch*2)
for i := 0; i < len(validators); i++ {
validators[i] = &pb.Validator{
@@ -443,7 +443,7 @@ func TestInactivityInclusionPenalty_NotOk(t *testing.T) {
}
}
func TestAttestationInclusionRewards(t *testing.T) {
func TestAttestationInclusionRewards_AccurateRewards(t *testing.T) {
validators := make([]*pb.Validator, params.BeaconConfig().DepositsForChainStart)
for i := 0; i < len(validators); i++ {
validators[i] = &pb.Validator{
@@ -562,7 +562,7 @@ func TestAttestationInclusionRewards_NoProposerIndex(t *testing.T) {
}
}
func TestCrosslinksRewardsPenalties(t *testing.T) {
func TestCrosslinksRewardsPenalties_AccurateBalances(t *testing.T) {
validators := make([]*pb.Validator, params.BeaconConfig().SlotsPerEpoch*4)
for i := 0; i < len(validators); i++ {
validators[i] = &pb.Validator{

View File

@@ -14,7 +14,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
)
func TestGenesisBlock(t *testing.T) {
func TestGenesisBlock_InitializedCorrectly(t *testing.T) {
stateHash := []byte{0}
b1 := NewGenesisBlock(stateHash)
@@ -42,7 +42,7 @@ func TestGenesisBlock(t *testing.T) {
}
}
func TestBlockRootAtSlot_OK(t *testing.T) {
func TestBlockRootAtSlot_AccurateBlockRoot(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("epochLength should be 64 for these tests to pass")
}
@@ -143,7 +143,7 @@ func TestBlockRootAtSlot_OutOfBounds(t *testing.T) {
}
}
func TestProcessBlockRoots(t *testing.T) {
func TestProcessBlockRoots_AccurateMerkleTree(t *testing.T) {
state := &pb.BeaconState{}
state.LatestBlockRootHash32S = make([][]byte, params.BeaconConfig().LatestBlockRootsLength)
@@ -172,7 +172,7 @@ func TestProcessBlockRoots(t *testing.T) {
}
}
func TestBlockChildren(t *testing.T) {
func TestBlockChildren_Fetches2Children(t *testing.T) {
genesisBlock := NewGenesisBlock([]byte{})
genesisRoot, err := ssz.TreeHash(genesisBlock)
if err != nil {

View File

@@ -36,7 +36,7 @@ func (m *mockPOWClient) BlockByHash(ctx context.Context, hash common.Hash) (*get
return nil, nil
}
func TestBadBlock(t *testing.T) {
func TestIsValidBlock_NoParent(t *testing.T) {
beaconState := &pb.BeaconState{}
ctx := context.Background()
@@ -58,6 +58,23 @@ func TestBadBlock(t *testing.T) {
db.HasBlock, powClient.BlockByHash, genesisTime); err == nil {
t.Fatal("block is valid despite not having a parent")
}
}
func TestIsValidBlock_InvalidSlot(t *testing.T) {
beaconState := &pb.BeaconState{}
ctx := context.Background()
db := &mockDB{}
powClient := &mockPOWClient{}
beaconState.Slot = params.BeaconConfig().GenesisSlot + 3
block := &pb.BeaconBlock{
Slot: params.BeaconConfig().GenesisSlot + 4,
}
genesisTime := time.Unix(0, 0)
block.Slot = params.BeaconConfig().GenesisSlot + 3
db.hasBlock = true
@@ -70,7 +87,25 @@ func TestBadBlock(t *testing.T) {
db.HasBlock, powClient.BlockByHash, genesisTime); err == nil {
t.Fatalf("block is valid despite having an invalid slot %d", block.Slot)
}
}
func TestIsValidBlock_InvalidPoWReference(t *testing.T) {
beaconState := &pb.BeaconState{}
ctx := context.Background()
db := &mockDB{}
powClient := &mockPOWClient{}
beaconState.Slot = params.BeaconConfig().GenesisSlot + 3
block := &pb.BeaconBlock{
Slot: params.BeaconConfig().GenesisSlot + 4,
}
genesisTime := time.Unix(0, 0)
db.hasBlock = true
block.Slot = params.BeaconConfig().GenesisSlot + 4
powClient.blockExists = false
beaconState.LatestEth1Data = &pb.Eth1Data{
@@ -83,9 +118,31 @@ func TestBadBlock(t *testing.T) {
t.Fatalf("block is valid despite having an invalid pow reference block")
}
invalidTime := time.Now().AddDate(1, 2, 3)
}
func TestIsValidBlock_InvalidGenesis(t *testing.T) {
beaconState := &pb.BeaconState{}
ctx := context.Background()
db := &mockDB{}
db.hasBlock = true
powClient := &mockPOWClient{}
powClient.blockExists = false
beaconState.Slot = params.BeaconConfig().GenesisSlot + 3
beaconState.LatestEth1Data = &pb.Eth1Data{
DepositRootHash32: []byte{2},
BlockHash32: []byte{3},
}
genesisTime := time.Unix(0, 0)
block := &pb.BeaconBlock{
Slot: params.BeaconConfig().GenesisSlot + 4,
}
invalidTime := time.Now().AddDate(1, 2, 3)
if err := IsValidBlock(ctx, beaconState, block, true,
db.HasBlock, powClient.BlockByHash, genesisTime); err == nil {
t.Fatalf("block is valid despite having an invalid genesis time %v", invalidTime)
@@ -93,28 +150,28 @@ func TestBadBlock(t *testing.T) {
}
func TestValidBlock(t *testing.T) {
func TestIsValidBlock_GoodBlock(t *testing.T) {
beaconState := &pb.BeaconState{}
ctx := context.Background()
db := &mockDB{}
powClient := &mockPOWClient{}
beaconState.Slot = params.BeaconConfig().GenesisSlot + 3
db.hasBlock = true
block := &pb.BeaconBlock{
Slot: params.BeaconConfig().GenesisSlot + 4,
}
genesisTime := time.Unix(0, 0)
powClient := &mockPOWClient{}
powClient.blockExists = true
beaconState.Slot = params.BeaconConfig().GenesisSlot + 3
beaconState.LatestEth1Data = &pb.Eth1Data{
DepositRootHash32: []byte{2},
BlockHash32: []byte{3},
}
genesisTime := time.Unix(0, 0)
block := &pb.BeaconBlock{
Slot: params.BeaconConfig().GenesisSlot + 4,
}
if err := IsValidBlock(ctx, beaconState, block, true,
db.HasBlock, powClient.BlockByHash, genesisTime); err != nil {
t.Fatal(err)

View File

@@ -29,7 +29,7 @@ func buildState(slot uint64, validatorCount uint64) *pb.BeaconState {
}
}
func TestEpochAttestations(t *testing.T) {
func TestEpochAttestations_AttestationSlotValid(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
@@ -82,16 +82,36 @@ func TestEpochAttestations(t *testing.T) {
}
}
func TestEpochBoundaryAttestations(t *testing.T) {
func TestEpochBoundaryAttestations_AccurateAttestationData(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
epochAttestations := []*pb.PendingAttestation{
{Data: &pb.AttestationData{JustifiedBlockRootHash32: []byte{64}, JustifiedEpoch: params.BeaconConfig().GenesisEpoch}},
{Data: &pb.AttestationData{JustifiedBlockRootHash32: []byte{64}, JustifiedEpoch: params.BeaconConfig().GenesisEpoch}},
{Data: &pb.AttestationData{JustifiedBlockRootHash32: []byte{64}, JustifiedEpoch: params.BeaconConfig().GenesisEpoch}},
{Data: &pb.AttestationData{JustifiedBlockRootHash32: []byte{64}, JustifiedEpoch: params.BeaconConfig().GenesisEpoch}},
{
Data: &pb.AttestationData{
JustifiedBlockRootHash32: []byte{64},
JustifiedEpoch: params.BeaconConfig().GenesisEpoch,
},
},
{
Data: &pb.AttestationData{
JustifiedBlockRootHash32: []byte{64},
JustifiedEpoch: params.BeaconConfig().GenesisEpoch,
},
},
{
Data: &pb.AttestationData{
JustifiedBlockRootHash32: []byte{64},
JustifiedEpoch: params.BeaconConfig().GenesisEpoch,
},
},
{
Data: &pb.AttestationData{
JustifiedBlockRootHash32: []byte{64},
JustifiedEpoch: params.BeaconConfig().GenesisEpoch,
},
},
}
var latestBlockRootHash [][]byte
@@ -126,7 +146,7 @@ func TestEpochBoundaryAttestations(t *testing.T) {
}
}
func TestPrevEpochAttestations(t *testing.T) {
func TestPrevEpochAttestations_AccurateAttestationSlots(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
@@ -181,7 +201,7 @@ func TestPrevEpochAttestations(t *testing.T) {
}
}
func TestPrevJustifiedAttestations(t *testing.T) {
func TestPrevJustifiedAttestations_AccurateShardsAndEpoch(t *testing.T) {
prevEpochAttestations := []*pb.PendingAttestation{
{Data: &pb.AttestationData{JustifiedEpoch: 0}},
{Data: &pb.AttestationData{JustifiedEpoch: 0}},
@@ -214,7 +234,7 @@ func TestPrevJustifiedAttestations(t *testing.T) {
}
}
func TestPrevEpochBoundaryAttestations(t *testing.T) {
func TestPrevEpochBoundaryAttestations_AccurateAttestationData(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
@@ -254,7 +274,7 @@ func TestPrevEpochBoundaryAttestations(t *testing.T) {
}
}
func TestHeadAttestationsOk(t *testing.T) {
func TestHeadAttestations_AccurateHeadData(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
@@ -287,17 +307,17 @@ func TestHeadAttestationsOk(t *testing.T) {
if headAttestations[1].Data.Slot != params.BeaconConfig().GenesisSlot+2 {
t.Errorf("headAttestations[1] wanted slot 9223372036854775810, got slot %d", headAttestations[1].Data.Slot)
}
if !bytes.Equal([]byte{'A'}, headAttestations[0].Data.BeaconBlockRootHash32) {
if !bytes.Equal(headAttestations[0].Data.BeaconBlockRootHash32, []byte{'A'}) {
t.Errorf("headAttestations[0] wanted hash [A], got slot %v",
headAttestations[0].Data.BeaconBlockRootHash32)
}
if !bytes.Equal([]byte{'A'}, headAttestations[1].Data.BeaconBlockRootHash32) {
if !bytes.Equal(headAttestations[1].Data.BeaconBlockRootHash32, []byte{'A'}) {
t.Errorf("headAttestations[1] wanted hash [A], got slot %v",
headAttestations[1].Data.BeaconBlockRootHash32)
}
}
func TestHeadAttestationsNotOk(t *testing.T) {
func TestHeadAttestations_InvalidRange(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
@@ -311,7 +331,7 @@ func TestHeadAttestationsNotOk(t *testing.T) {
}
}
func TestWinningRootOk(t *testing.T) {
func TestWinningRoot_AccurateRoot(t *testing.T) {
state := buildState(0, params.BeaconConfig().DepositsForChainStart)
var participationBitfield []byte
for i := 0; i < 16; i++ {
@@ -346,7 +366,7 @@ func TestWinningRootOk(t *testing.T) {
}
}
func TestWinningRootCantGetParticipantBitfield(t *testing.T) {
func TestWinningRoot_EmptyParticipantBitfield(t *testing.T) {
state := buildState(0, params.BeaconConfig().DepositsForChainStart)
attestations := []*pb.PendingAttestation{
@@ -363,7 +383,7 @@ func TestWinningRootCantGetParticipantBitfield(t *testing.T) {
}
}
func TestAttestingValidatorsOk(t *testing.T) {
func TestAttestingValidators_MatchActive(t *testing.T) {
state := buildState(0, params.BeaconConfig().SlotsPerEpoch*2)
var attestations []*pb.PendingAttestation
@@ -392,7 +412,7 @@ func TestAttestingValidatorsOk(t *testing.T) {
}
}
func TestAttestingValidatorsCantGetWinningRoot(t *testing.T) {
func TestAttestingValidators_EmptyWinningRoot(t *testing.T) {
state := buildState(0, params.BeaconConfig().DepositsForChainStart)
attestation := &pb.PendingAttestation{
@@ -408,7 +428,7 @@ func TestAttestingValidatorsCantGetWinningRoot(t *testing.T) {
}
}
func TestTotalAttestingBalanceOk(t *testing.T) {
func TestTotalAttestingBalance_CorrectBalance(t *testing.T) {
validatorsPerCommittee := uint64(2)
state := buildState(0, 2*params.BeaconConfig().SlotsPerEpoch)
@@ -439,7 +459,7 @@ func TestTotalAttestingBalanceOk(t *testing.T) {
}
}
func TestTotalAttestingBalanceCantGetWinningRoot(t *testing.T) {
func TestTotalAttestingBalance_EmptyWinningRoot(t *testing.T) {
state := buildState(0, params.BeaconConfig().DepositsForChainStart)
attestation := &pb.PendingAttestation{
@@ -455,7 +475,7 @@ func TestTotalAttestingBalanceCantGetWinningRoot(t *testing.T) {
}
}
func TestTotalBalance(t *testing.T) {
func TestTotalBalance_CorrectBalance(t *testing.T) {
// Assign validators to different balances.
state := &pb.BeaconState{
Slot: 5,
@@ -470,7 +490,7 @@ func TestTotalBalance(t *testing.T) {
}
}
func TestInclusionSlotOk(t *testing.T) {
func TestInclusionSlot_GetsCorrectSlot(t *testing.T) {
state := buildState(0, params.BeaconConfig().DepositsForChainStart)
var participationBitfield []byte
for i := 0; i < 16; i++ {
@@ -498,7 +518,7 @@ func TestInclusionSlotOk(t *testing.T) {
}
}
func TestInclusionSlotBadBitfield(t *testing.T) {
func TestInclusionSlot_InvalidBitfield(t *testing.T) {
state := buildState(0, params.BeaconConfig().DepositsForChainStart)
state.LatestAttestations = []*pb.PendingAttestation{
@@ -513,7 +533,7 @@ func TestInclusionSlotBadBitfield(t *testing.T) {
}
}
func TestInclusionSlotNotFound(t *testing.T) {
func TestInclusionSlot_SlotNotFound(t *testing.T) {
state := buildState(0, params.BeaconConfig().SlotsPerEpoch)
badIndex := uint64(10000)
@@ -523,7 +543,7 @@ func TestInclusionSlotNotFound(t *testing.T) {
}
}
func TestInclusionDistanceOk(t *testing.T) {
func TestInclusionDistance_CorrectDistance(t *testing.T) {
state := buildState(0, params.BeaconConfig().DepositsForChainStart)
var participationBitfield []byte
for i := 0; i < 16; i++ {
@@ -548,7 +568,7 @@ func TestInclusionDistanceOk(t *testing.T) {
}
}
func TestInclusionDistanceBadBitfield(t *testing.T) {
func TestInclusionDistance_InvalidBitfield(t *testing.T) {
state := buildState(0, params.BeaconConfig().DepositsForChainStart)
state.LatestAttestations = []*pb.PendingAttestation{
@@ -563,7 +583,7 @@ func TestInclusionDistanceBadBitfield(t *testing.T) {
}
}
func TestInclusionDistanceNotFound(t *testing.T) {
func TestInclusionDistance_NotFound(t *testing.T) {
state := buildState(0, params.BeaconConfig().SlotsPerEpoch)
badIndex := uint64(10000)

View File

@@ -14,10 +14,11 @@ import (
"github.com/prysmaticlabs/prysm/shared/ssz"
)
func TestCanProcessEpoch(t *testing.T) {
func TestCanProcessEpoch_TrueOnEpochs(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
tests := []struct {
slot uint64
canProcessEpoch bool
@@ -25,12 +26,10 @@ func TestCanProcessEpoch(t *testing.T) {
{
slot: 1,
canProcessEpoch: false,
},
{
}, {
slot: 63,
canProcessEpoch: false,
},
{
}, {
slot: 64,
canProcessEpoch: true,
}, {
@@ -41,6 +40,7 @@ func TestCanProcessEpoch(t *testing.T) {
canProcessEpoch: true,
},
}
for _, tt := range tests {
state := &pb.BeaconState{Slot: tt.slot}
if CanProcessEpoch(state) != tt.canProcessEpoch {
@@ -54,10 +54,11 @@ func TestCanProcessEpoch(t *testing.T) {
}
}
func TestCanProcessEth1Data(t *testing.T) {
func TestCanProcessEth1Data_TrueOnVotingPeriods(t *testing.T) {
if params.BeaconConfig().EpochsPerEth1VotingPeriod != 16 {
t.Errorf("EpochsPerEth1VotingPeriodshould be 16 for these tests to pass")
}
tests := []struct {
slot uint64
canProcessEth1Data bool
@@ -83,6 +84,7 @@ func TestCanProcessEth1Data(t *testing.T) {
canProcessEth1Data: false,
},
}
for _, tt := range tests {
state := &pb.BeaconState{Slot: tt.slot}
if CanProcessEth1Data(state) != tt.canProcessEth1Data {
@@ -96,7 +98,7 @@ func TestCanProcessEth1Data(t *testing.T) {
}
}
func TestProcessEth1Data(t *testing.T) {
func TestProcessEth1Data_UpdatesStateAndCleans(t *testing.T) {
requiredVoteCount := params.BeaconConfig().EpochsPerEth1VotingPeriod
state := &pb.BeaconState{
Slot: 15 * params.BeaconConfig().SlotsPerEpoch,
@@ -129,6 +131,7 @@ func TestProcessEth1Data(t *testing.T) {
},
},
}
newState := ProcessEth1Data(state)
if !bytes.Equal(newState.LatestEth1Data.DepositRootHash32, []byte{'C'}) {
t.Errorf("Incorrect DepositRootHash32. Wanted: %v, got: %v",
@@ -198,7 +201,7 @@ func TestProcessEth1Data_InactionSlot(t *testing.T) {
}
}
func TestProcessJustification(t *testing.T) {
func TestProcessJustification_PreviousEpochJustified(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
@@ -234,7 +237,7 @@ func TestProcessJustification(t *testing.T) {
}
}
func TestProcessFinalization(t *testing.T) {
func TestProcessFinalization_2EpochsInARow(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
@@ -247,55 +250,76 @@ func TestProcessFinalization(t *testing.T) {
PreviousJustifiedEpoch: 1,
JustificationBitfield: 3,
}
newState := ProcessFinalization(state)
if newState.FinalizedEpoch != state.JustifiedEpoch {
t.Errorf("Wanted finalized epoch to be %d, got %d:",
state.JustifiedEpoch, newState.FinalizedEpoch)
}
}
func TestProcessFinalization_3EpochsInARow(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
// 3 consecutive justified epoch in a row,
// and previous justified epoch is slot_to_epoch(state.slot) - 3.
state = &pb.BeaconState{
state := &pb.BeaconState{
Slot: 300,
JustifiedEpoch: 3,
PreviousJustifiedEpoch: 1,
JustificationBitfield: 7,
}
newState = ProcessFinalization(state)
newState := ProcessFinalization(state)
if newState.FinalizedEpoch != state.JustifiedEpoch {
t.Errorf("Wanted finalized epoch to be %d, got %d:",
state.JustifiedEpoch, newState.FinalizedEpoch)
}
}
func TestProcessFinalization_4EpochsInARow(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
// 4 consecutive justified epoch in a row,
// and previous justified epoch is slot_to_epoch(state.slot) - 3.
state = &pb.BeaconState{
state := &pb.BeaconState{
Slot: 400,
JustifiedEpoch: 5,
PreviousJustifiedEpoch: 2,
JustificationBitfield: 15,
}
newState = ProcessFinalization(state)
newState := ProcessFinalization(state)
if newState.FinalizedEpoch != state.JustifiedEpoch {
t.Errorf("Wanted finalized epoch to be %d, got %d:",
state.JustifiedEpoch, newState.FinalizedEpoch)
}
}
func TestProcessFinalization_NoFinalizationYet(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
// if nothing gets finalized it just returns the same state.
state = &pb.BeaconState{
state := &pb.BeaconState{
Slot: 100,
JustifiedEpoch: 1,
PreviousJustifiedEpoch: 0,
JustificationBitfield: 1,
}
newState = ProcessFinalization(state)
newState := ProcessFinalization(state)
if newState.FinalizedEpoch != 0 {
t.Errorf("Wanted finalized epoch to be %d, got %d:",
0, newState.FinalizedEpoch)
}
}
func TestProcessCrosslinksOk(t *testing.T) {
func TestProcessCrosslinks_CrosslinksCorrectEpoch(t *testing.T) {
state := buildState(5, params.BeaconConfig().DepositsForChainStart)
state.LatestCrosslinks = []*pb.Crosslink{{}, {}}
epoch := uint64(5)
@@ -342,7 +366,7 @@ func TestProcessCrosslinksOk(t *testing.T) {
}
}
func TestProcessCrosslinksNoParticipantsBitField(t *testing.T) {
func TestProcessCrosslinks_NoParticipantsBitField(t *testing.T) {
state := buildState(5, params.BeaconConfig().DepositsForChainStart)
state.LatestCrosslinks = []*pb.Crosslink{{}, {}}
@@ -360,7 +384,7 @@ func TestProcessCrosslinksNoParticipantsBitField(t *testing.T) {
}
}
func TestProcessEjectionsOk(t *testing.T) {
func TestProcessEjections_EjectsAtCorrectSlot(t *testing.T) {
state := &pb.BeaconState{
Slot: 1,
ValidatorBalances: []uint64{
@@ -388,7 +412,7 @@ func TestProcessEjectionsOk(t *testing.T) {
}
}
func TestCanProcessValidatorRegistry(t *testing.T) {
func TestCanProcessValidatorRegistry_OnFarEpoch(t *testing.T) {
crosslinks := make([]*pb.Crosslink, params.BeaconConfig().DepositsForChainStart)
for i := 0; i < len(crosslinks); i++ {
crosslinks[i] = &pb.Crosslink{
@@ -402,19 +426,19 @@ func TestCanProcessValidatorRegistry(t *testing.T) {
LatestCrosslinks: crosslinks,
}
if !CanProcessValidatorRegistry(state) {
t.Errorf("Wanted True for CanProcessValidatorRegistry, but got %v", CanProcessValidatorRegistry(state))
if processed := CanProcessValidatorRegistry(state); !processed {
t.Errorf("Wanted True for CanProcessValidatorRegistry, but got %v", processed)
}
}
func TestCanNotProcessValidatorRegistry(t *testing.T) {
func TestCanProcessValidatorRegistry_OutOfBounds(t *testing.T) {
state := &pb.BeaconState{
FinalizedEpoch: 1,
ValidatorRegistryUpdateEpoch: 101,
}
if CanProcessValidatorRegistry(state) {
t.Errorf("Wanted False for CanProcessValidatorRegistry, but got %v", CanProcessValidatorRegistry(state))
if processed := CanProcessValidatorRegistry(state); processed {
t.Errorf("Wanted False for CanProcessValidatorRegistry, but got %v", processed)
}
state = &pb.BeaconState{
ValidatorRegistryUpdateEpoch: 101,
@@ -423,12 +447,12 @@ func TestCanNotProcessValidatorRegistry(t *testing.T) {
{Epoch: 100},
},
}
if CanProcessValidatorRegistry(state) {
t.Errorf("Wanted False for CanProcessValidatorRegistry, but got %v", CanProcessValidatorRegistry(state))
if processed := CanProcessValidatorRegistry(state); processed {
t.Errorf("Wanted False for CanProcessValidatorRegistry, but got %v", processed)
}
}
func TestProcessPrevSlotShardOk(t *testing.T) {
func TestProcessPrevSlotShard_CorrectPrevEpochData(t *testing.T) {
state := &pb.BeaconState{
CurrentShufflingEpoch: 1,
CurrentShufflingStartShard: 2,
@@ -439,20 +463,20 @@ func TestProcessPrevSlotShardOk(t *testing.T) {
proto.Clone(state).(*pb.BeaconState))
if newState.PreviousShufflingEpoch != state.CurrentShufflingEpoch {
t.Errorf("Incorret prev epoch calculation slot: Wanted: %d, got: %d",
t.Errorf("Incorrect prev epoch calculation slot: Wanted: %d, got: %d",
newState.PreviousShufflingEpoch, state.CurrentShufflingEpoch)
}
if newState.PreviousShufflingStartShard != state.CurrentShufflingStartShard {
t.Errorf("Incorret prev epoch start shard: Wanted: %d, got: %d",
t.Errorf("Incorrect prev epoch start shard: Wanted: %d, got: %d",
newState.PreviousShufflingStartShard, state.CurrentShufflingStartShard)
}
if !bytes.Equal(newState.PreviousShufflingSeedHash32, state.CurrentShufflingSeedHash32) {
t.Errorf("Incorret prev epoch seed mix hash: Wanted: %v, got: %v",
t.Errorf("Incorrect prev epoch seed mix hash: Wanted: %v, got: %v",
state.CurrentShufflingSeedHash32, newState.PreviousShufflingSeedHash32)
}
}
func TestProcessValidatorRegistryOk(t *testing.T) {
func TestProcessValidatorRegistry_CorrectCurrentEpochData(t *testing.T) {
state := &pb.BeaconState{
Slot: params.BeaconConfig().MinSeedLookahead,
LatestRandaoMixes: [][]byte{{'A'}, {'B'}},
@@ -464,16 +488,16 @@ func TestProcessValidatorRegistryOk(t *testing.T) {
t.Fatalf("Could not execute ProcessValidatorRegistry: %v", err)
}
if newState.CurrentShufflingEpoch != state.Slot {
t.Errorf("Incorret curr epoch calculation slot: Wanted: %d, got: %d",
t.Errorf("Incorrect current epoch calculation slot: Wanted: %d, got: %d",
newState.CurrentShufflingEpoch, state.Slot)
}
if !bytes.Equal(newState.CurrentShufflingSeedHash32, state.LatestRandaoMixes[0]) {
t.Errorf("Incorret current epoch seed mix hash: Wanted: %v, got: %v",
t.Errorf("Incorrect current epoch seed mix hash: Wanted: %v, got: %v",
state.LatestRandaoMixes[0], newState.CurrentShufflingSeedHash32)
}
}
func TestProcessPartialValidatorRegistry(t *testing.T) {
func TestProcessPartialValidatorRegistry_CorrectShufflingEpoch(t *testing.T) {
state := &pb.BeaconState{
Slot: params.BeaconConfig().SlotsPerEpoch * 2,
LatestRandaoMixes: [][]byte{{'A'}, {'B'}, {'C'}},
@@ -490,7 +514,7 @@ func TestProcessPartialValidatorRegistry(t *testing.T) {
}
}
func TestCleanupAttestations(t *testing.T) {
func TestCleanupAttestations_RemovesFromLastEpoch(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
@@ -525,7 +549,7 @@ func TestCleanupAttestations(t *testing.T) {
}
}
func TestUpdateLatestSlashedBalances_Ok(t *testing.T) {
func TestUpdateLatestSlashedBalances_UpdatesBalances(t *testing.T) {
tests := []struct {
epoch uint64
balances uint64
@@ -569,7 +593,7 @@ func TestUpdateLatestSlashedBalances_Ok(t *testing.T) {
}
}
func TestUpdateLatestRandaoMixes_Ok(t *testing.T) {
func TestUpdateLatestRandaoMixes_UpdatesRandao(t *testing.T) {
tests := []struct {
epoch uint64
seed []byte
@@ -615,7 +639,7 @@ func TestUpdateLatestRandaoMixes_Ok(t *testing.T) {
}
}
func TestUpdateLatestActiveIndexRoots_Ok(t *testing.T) {
func TestUpdateLatestActiveIndexRoots_UpdatesActiveIndexRoots(t *testing.T) {
epoch := uint64(1234)
latestActiveIndexRoots := make([][]byte,
params.BeaconConfig().LatestActiveIndexRootsLength)

View File

@@ -22,7 +22,7 @@ func populateValidatorsMax() {
}
}
func TestEpochCommitteeCount_Ok(t *testing.T) {
func TestEpochCommitteeCount_OK(t *testing.T) {
// this defines the # of validators required to have 1 committee
// per slot for epoch length.
validatorsPerEpoch := params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().TargetCommitteeSize
@@ -61,7 +61,7 @@ func TestEpochCommitteeCount_LessShardsThanEpoch(t *testing.T) {
params.OverrideBeaconConfig(productionConfig)
}
func TestCurrentEpochCommitteeCount_Ok(t *testing.T) {
func TestCurrentEpochCommitteeCount_OK(t *testing.T) {
validatorsPerEpoch := params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().TargetCommitteeSize
committeesPerEpoch := uint64(8)
// set curr epoch total validators count to 8 committees per slot.
@@ -82,7 +82,7 @@ func TestCurrentEpochCommitteeCount_Ok(t *testing.T) {
}
}
func TestPrevEpochCommitteeCount_Ok(t *testing.T) {
func TestPrevEpochCommitteeCount_OK(t *testing.T) {
validatorsPerEpoch := params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().TargetCommitteeSize
committeesPerEpoch := uint64(3)
// set prev epoch total validators count to 3 committees per slot.
@@ -103,7 +103,7 @@ func TestPrevEpochCommitteeCount_Ok(t *testing.T) {
}
}
func TestNextEpochCommitteeCount_Ok(t *testing.T) {
func TestNextEpochCommitteeCount_OK(t *testing.T) {
validatorsPerEpoch := params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().TargetCommitteeSize
committeesPerEpoch := uint64(6)
// set prev epoch total validators count to 3 committees per slot.
@@ -123,7 +123,7 @@ func TestNextEpochCommitteeCount_Ok(t *testing.T) {
}
}
func TestShuffling_Ok(t *testing.T) {
func TestShuffling_OK(t *testing.T) {
validatorsPerEpoch := params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().TargetCommitteeSize
committeesPerEpoch := uint64(6)
// Set epoch total validators count to 6 committees per slot.
@@ -167,7 +167,7 @@ func TestShuffling_OutOfBound(t *testing.T) {
}
}
func TestCrosslinkCommitteesAtSlot_Ok(t *testing.T) {
func TestCrosslinkCommitteesAtSlot_OK(t *testing.T) {
validatorsPerEpoch := params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().TargetCommitteeSize
committeesPerEpoch := uint64(6)
// Set epoch total validators count to 6 committees per slot.
@@ -228,7 +228,7 @@ func TestCrosslinkCommitteesAtSlot_ShuffleFailed(t *testing.T) {
}
}
func TestAttestationParticipants_ok(t *testing.T) {
func TestAttestationParticipants_OK(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
@@ -332,7 +332,7 @@ func TestAttestationParticipants_IncorrectBitfield(t *testing.T) {
}
}
func TestVerifyBitfield(t *testing.T) {
func TestVerifyBitfield_OK(t *testing.T) {
bitfield := []byte{0xff}
committeeSize := 8
@@ -368,7 +368,7 @@ func TestVerifyBitfield(t *testing.T) {
t.Error("bitfield is not validated when it was supposed to be")
}
}
func TestNextEpochCommitteeAssignment_ok(t *testing.T) {
func TestNextEpochCommitteeAssignment_OK(t *testing.T) {
// Initialize test with 128 validators, each slot and each shard gets 2 validators.
validators := make([]*pb.Validator, 2*params.BeaconConfig().SlotsPerEpoch)
for i := 0; i < len(validators); i++ {

View File

@@ -11,7 +11,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
)
func TestRandaoMix_Ok(t *testing.T) {
func TestRandaoMix_OK(t *testing.T) {
randaoMixes := make([][]byte, params.BeaconConfig().LatestRandaoMixesLength)
for i := 0; i < len(randaoMixes); i++ {
intInBytes := make([]byte, 32)
@@ -59,7 +59,7 @@ func TestRandaoMix_OutOfBound(t *testing.T) {
}
}
func TestActiveIndexRoot_Ok(t *testing.T) {
func TestActiveIndexRoot_OK(t *testing.T) {
activeIndexRoots := make([][]byte, params.BeaconConfig().LatestActiveIndexRootsLength)
for i := 0; i < len(activeIndexRoots); i++ {
intInBytes := make([]byte, 32)
@@ -117,7 +117,7 @@ func TestGenerateSeed_OutOfBound(t *testing.T) {
}
}
func TestGenerateSeed_Ok(t *testing.T) {
func TestGenerateSeed_OK(t *testing.T) {
activeIndexRoots := make([][]byte, params.BeaconConfig().LatestActiveIndexRootsLength)
for i := 0; i < len(activeIndexRoots); i++ {
intInBytes := make([]byte, 32)

View File

@@ -7,7 +7,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
)
func TestBaseRewardQuotient(t *testing.T) {
func TestBaseRewardQuotient_OK(t *testing.T) {
if params.BeaconConfig().BaseRewardQuotient != 1<<5 {
t.Errorf("BaseRewardQuotient should be 32 for these tests to pass")
}
@@ -32,7 +32,7 @@ func TestBaseRewardQuotient(t *testing.T) {
}
}
func TestBaseReward(t *testing.T) {
func TestBaseReward_OK(t *testing.T) {
tests := []struct {
a uint64
b uint64
@@ -56,7 +56,7 @@ func TestBaseReward(t *testing.T) {
}
}
func TestInactivityPenalty(t *testing.T) {
func TestInactivityPenalty_OK(t *testing.T) {
tests := []struct {
a uint64
b uint64
@@ -80,7 +80,7 @@ func TestInactivityPenalty(t *testing.T) {
}
}
func TestEffectiveBalance(t *testing.T) {
func TestEffectiveBalance_OK(t *testing.T) {
defaultBalance := params.BeaconConfig().MaxDepositAmount
tests := []struct {
@@ -101,7 +101,7 @@ func TestEffectiveBalance(t *testing.T) {
}
}
func TestTotalBalance(t *testing.T) {
func TestTotalBalance_OK(t *testing.T) {
state := &pb.BeaconState{ValidatorBalances: []uint64{
27 * 1e9, 28 * 1e9, 32 * 1e9, 40 * 1e9,
}}

View File

@@ -7,7 +7,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
)
func TestSlotToEpoch(t *testing.T) {
func TestSlotToEpoch_OK(t *testing.T) {
tests := []struct {
slot uint64
epoch uint64
@@ -25,7 +25,7 @@ func TestSlotToEpoch(t *testing.T) {
}
}
func TestCurrentEpoch(t *testing.T) {
func TestCurrentEpoch_OK(t *testing.T) {
tests := []struct {
slot uint64
epoch uint64
@@ -44,7 +44,7 @@ func TestCurrentEpoch(t *testing.T) {
}
}
func TestPrevEpoch(t *testing.T) {
func TestPrevEpoch_OK(t *testing.T) {
tests := []struct {
slot uint64
epoch uint64
@@ -63,7 +63,7 @@ func TestPrevEpoch(t *testing.T) {
}
}
func TestNextEpoch(t *testing.T) {
func TestNextEpoch_OK(t *testing.T) {
tests := []struct {
slot uint64
epoch uint64
@@ -82,7 +82,7 @@ func TestNextEpoch(t *testing.T) {
}
}
func TestEpochStartSlot(t *testing.T) {
func TestEpochStartSlot_OK(t *testing.T) {
tests := []struct {
epoch uint64
startSlot uint64
@@ -99,7 +99,7 @@ func TestEpochStartSlot(t *testing.T) {
}
}
func TestAttestationCurrentEpoch(t *testing.T) {
func TestAttestationCurrentEpoch_OK(t *testing.T) {
tests := []struct {
slot uint64
epoch uint64

View File

@@ -7,7 +7,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
)
func TestIsActiveValidator(t *testing.T) {
func TestIsActiveValidator_OK(t *testing.T) {
tests := []struct {
a uint64
b bool
@@ -27,7 +27,7 @@ func TestIsActiveValidator(t *testing.T) {
}
}
func TestBeaconProposerIdx(t *testing.T) {
func TestBeaconProposerIndex_OK(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
@@ -85,7 +85,7 @@ func TestBeaconProposerIdx(t *testing.T) {
}
}
func TestBeaconProposerIdx_returnsErrorWithEmptyCommittee(t *testing.T) {
func TestBeaconProposerIndex_EmptyCommittee(t *testing.T) {
_, err := BeaconProposerIndex(&pb.BeaconState{}, 0)
expected := "empty first committee at slot 0"
if err.Error() != expected {
@@ -93,7 +93,7 @@ func TestBeaconProposerIdx_returnsErrorWithEmptyCommittee(t *testing.T) {
}
}
func TestEntryExitEffectEpoch_Ok(t *testing.T) {
func TestEntryExitEffectEpoch_OK(t *testing.T) {
epoch := uint64(9999)
got := EntryExitEffectEpoch(epoch)
wanted := epoch + 1 + params.BeaconConfig().ActivationExitDelay

View File

@@ -16,7 +16,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
)
func TestGenesisBeaconState_Ok(t *testing.T) {
func TestGenesisBeaconState_OK(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/bytesutil"
)
func TestValidatorIndexMap(t *testing.T) {
func TestValidatorIndexMap_OK(t *testing.T) {
state := &pb.BeaconState{
ValidatorRegistry: []*pb.Validator{
{

View File

@@ -13,7 +13,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
)
func TestHasVoted(t *testing.T) {
func TestHasVoted_OK(t *testing.T) {
// Setting bit field to 11111111.
pendingAttestation := &pb.Attestation{
AggregationBitfield: []byte{255},
@@ -48,7 +48,7 @@ func TestHasVoted(t *testing.T) {
}
}
func TestValidatorIdx(t *testing.T) {
func TestValidatorIndex_OK(t *testing.T) {
var validators []*pb.Validator
for i := 0; i < 10; i++ {
validators = append(validators, &pb.Validator{Pubkey: []byte{}, ExitEpoch: params.BeaconConfig().FarFutureEpoch})
@@ -66,7 +66,7 @@ func TestValidatorIdx(t *testing.T) {
}
}
func TestBoundaryAttesterIndices(t *testing.T) {
func TestBoundaryAttesterIndices_OK(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
@@ -97,7 +97,7 @@ func TestBoundaryAttesterIndices(t *testing.T) {
}
}
func TestAttestingValidatorIndices_Ok(t *testing.T) {
func TestAttestingValidatorIndices_OK(t *testing.T) {
if params.BeaconConfig().SlotsPerEpoch != 64 {
t.Errorf("SlotsPerEpoch should be 64 for these tests to pass")
}
@@ -174,7 +174,7 @@ func TestAttestingValidatorIndices_OutOfBound(t *testing.T) {
}
}
func TestAllValidatorIndices(t *testing.T) {
func TestAllValidatorIndices_OK(t *testing.T) {
tests := []struct {
registries []*pb.Validator
indices []uint64
@@ -192,7 +192,7 @@ func TestAllValidatorIndices(t *testing.T) {
}
}
func TestProcessDeposit_PublicKeyExistsBadWithdrawalCredentials(t *testing.T) {
func TestProcessDeposit_BadWithdrawalCredentials(t *testing.T) {
registry := []*pb.Validator{
{
Pubkey: []byte{1, 2, 3},
@@ -223,7 +223,7 @@ func TestProcessDeposit_PublicKeyExistsBadWithdrawalCredentials(t *testing.T) {
}
}
func TestProcessDeposit_PublicKeyExistsGoodWithdrawalCredentials(t *testing.T) {
func TestProcessDeposit_GoodWithdrawalCredentials(t *testing.T) {
registry := []*pb.Validator{
{
Pubkey: []byte{1, 2, 3},
@@ -259,7 +259,7 @@ func TestProcessDeposit_PublicKeyExistsGoodWithdrawalCredentials(t *testing.T) {
}
}
func TestProcessDeposit_PublicKeyDoesNotExistNoEmptyValidator(t *testing.T) {
func TestProcessDeposit_PublicKeyDoesNotExist(t *testing.T) {
registry := []*pb.Validator{
{
Pubkey: []byte{1, 2, 3},
@@ -299,7 +299,7 @@ func TestProcessDeposit_PublicKeyDoesNotExistNoEmptyValidator(t *testing.T) {
}
}
func TestProcessDeposit_PublicKeyDoesNotExistEmptyValidatorExists(t *testing.T) {
func TestProcessDeposit_PublicKeyDoesNotExistAndEmptyValidator(t *testing.T) {
registry := []*pb.Validator{
{
Pubkey: []byte{1, 2, 3},
@@ -340,7 +340,7 @@ func TestProcessDeposit_PublicKeyDoesNotExistEmptyValidatorExists(t *testing.T)
}
}
func TestActivateValidatorGenesis_Ok(t *testing.T) {
func TestActivateValidatorGenesis_OK(t *testing.T) {
state := &pb.BeaconState{
ValidatorRegistry: []*pb.Validator{
{Pubkey: []byte{'A'}},
@@ -356,7 +356,7 @@ func TestActivateValidatorGenesis_Ok(t *testing.T) {
}
}
func TestActivateValidator_Ok(t *testing.T) {
func TestActivateValidator_OK(t *testing.T) {
state := &pb.BeaconState{
Slot: 100, // epoch 2
ValidatorRegistry: []*pb.Validator{
@@ -376,7 +376,7 @@ func TestActivateValidator_Ok(t *testing.T) {
}
}
func TestInitiateValidatorExit_Ok(t *testing.T) {
func TestInitiateValidatorExit_OK(t *testing.T) {
state := &pb.BeaconState{ValidatorRegistry: []*pb.Validator{{}, {}, {}}}
newState := InitiateValidatorExit(state, 2)
if newState.ValidatorRegistry[0].StatusFlags != pb.Validator_INITIAL {
@@ -387,7 +387,7 @@ func TestInitiateValidatorExit_Ok(t *testing.T) {
}
}
func TestExitValidator_Ok(t *testing.T) {
func TestExitValidator_OK(t *testing.T) {
state := &pb.BeaconState{
Slot: 100, // epoch 2
LatestSlashedBalances: []uint64{0},
@@ -478,7 +478,7 @@ func TestProcessPenaltiesExits_ValidatorSlashed(t *testing.T) {
}
}
func TestEligibleToExit(t *testing.T) {
func TestEligibleToExit_OK(t *testing.T) {
state := &pb.BeaconState{
Slot: 1,
ValidatorRegistry: []*pb.Validator{
@@ -535,7 +535,7 @@ func TestUpdateRegistry_NoRotation(t *testing.T) {
}
}
func TestUpdateRegistry_Activate(t *testing.T) {
func TestUpdateRegistry_Activations(t *testing.T) {
state := &pb.BeaconState{
Slot: 5 * params.BeaconConfig().SlotsPerEpoch,
ValidatorRegistry: []*pb.Validator{
@@ -565,7 +565,7 @@ func TestUpdateRegistry_Activate(t *testing.T) {
}
}
func TestUpdateRegistry_Exit(t *testing.T) {
func TestUpdateRegistry_Exits(t *testing.T) {
epoch := uint64(5)
exitEpoch := helpers.EntryExitEffectEpoch(epoch)
state := &pb.BeaconState{
@@ -601,7 +601,7 @@ func TestUpdateRegistry_Exit(t *testing.T) {
}
}
func TestMaxBalanceChurn(t *testing.T) {
func TestMaxBalanceChurn_OK(t *testing.T) {
tests := []struct {
totalBalance uint64
maxBalanceChurn uint64

View File

@@ -11,7 +11,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/hashutil"
)
func TestSaveAndRetrieveAttestation(t *testing.T) {
func TestSaveAndRetrieveAttestation_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)
@@ -48,7 +48,7 @@ func TestSaveAndRetrieveAttestation(t *testing.T) {
}
}
func TestRetrieveAttestations(t *testing.T) {
func TestRetrieveAttestations_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)
@@ -80,7 +80,7 @@ func TestRetrieveAttestations(t *testing.T) {
}
}
func TestDeleteAttestation(t *testing.T) {
func TestDeleteAttestation_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)
@@ -117,7 +117,7 @@ func TestDeleteAttestation(t *testing.T) {
}
}
func TestNilAttestation(t *testing.T) {
func TestNilAttestation_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)
@@ -131,7 +131,7 @@ func TestNilAttestation(t *testing.T) {
}
}
func TestHasAttestation(t *testing.T) {
func TestHasAttestation_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)

View File

@@ -10,7 +10,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
)
func TestNilDB(t *testing.T) {
func TestNilDB_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)
@@ -31,7 +31,7 @@ func TestNilDB(t *testing.T) {
}
}
func TestSave(t *testing.T) {
func TestSave_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)
@@ -73,7 +73,7 @@ func TestSave(t *testing.T) {
}
}
func TestBlockBySlotEmptyChain(t *testing.T) {
func TestBlockBySlotEmptyChain_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)
@@ -86,7 +86,7 @@ func TestBlockBySlotEmptyChain(t *testing.T) {
}
}
func TestUpdateChainHeadNoBlock(t *testing.T) {
func TestUpdateChainHead_NoBlock(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)
@@ -107,7 +107,7 @@ func TestUpdateChainHeadNoBlock(t *testing.T) {
}
}
func TestUpdateChainHead(t *testing.T) {
func TestUpdateChainHead_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)
@@ -173,7 +173,7 @@ func TestUpdateChainHead(t *testing.T) {
}
}
func TestChainProgress(t *testing.T) {
func TestChainProgress_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)

View File

@@ -4,7 +4,7 @@ import (
"testing"
)
func TestSaveCleanedFinalizedSlot(t *testing.T) {
func TestSaveCleanedFinalizedSlot_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)
@@ -28,7 +28,7 @@ func TestCleanedFinalizedSlot_NotFound(t *testing.T) {
}
}
func TestCleanedFinalizedSlot(t *testing.T) {
func TestCleanedFinalizedSlot_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)

View File

@@ -10,7 +10,7 @@ import (
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
)
func TestInsertPendingDeposit(t *testing.T) {
func TestInsertPendingDeposit_OK(t *testing.T) {
db := BeaconDB{}
db.InsertPendingDeposit(context.Background(), &pb.Deposit{}, big.NewInt(111))
@@ -28,7 +28,7 @@ func TestInsertPendingDeposit_ignoresNilDeposit(t *testing.T) {
}
}
func TestRemovePendingDeposit(t *testing.T) {
func TestRemovePendingDeposit_OK(t *testing.T) {
db := BeaconDB{}
depToRemove := &pb.Deposit{MerkleTreeIndex: 1}
otherDep := &pb.Deposit{MerkleTreeIndex: 5}
@@ -62,7 +62,7 @@ func TestPendingDeposit_RoundTrip(t *testing.T) {
}
}
func TestPendingDeposits(t *testing.T) {
func TestPendingDeposits_OK(t *testing.T) {
db := BeaconDB{}
db.deposits = []*depositContainer{

View File

@@ -36,7 +36,7 @@ func setupInitialDeposits(t *testing.T, numDeposits int) ([]*pb.Deposit, []*bls.
return deposits, privKeys
}
func TestInitializeState(t *testing.T) {
func TestInitializeState_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)
@@ -79,7 +79,7 @@ func TestInitializeState(t *testing.T) {
}
}
func TestGenesisTime(t *testing.T) {
func TestGenesisTime_OK(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)

View File

@@ -13,7 +13,7 @@ import (
)
// Test that the beacon chain validator node build fails without PoW service.
func TestNodeValidator_Builds(t *testing.T) {
func TestNodeValidator_NoPOWService(t *testing.T) {
tmp := fmt.Sprintf("%s/datadirtest1", testutil.TempDir())
os.RemoveAll(tmp)
@@ -31,7 +31,7 @@ func TestNodeValidator_Builds(t *testing.T) {
}
// Start a subprocess to test beacon node crashes.
cmd := exec.Command(os.Args[0], "-test.run=TestNodeValidator_Builds")
cmd := exec.Command(os.Args[0], "-test.run=TestNodeValidator_NoPOWService")
cmd.Env = append(os.Environ(), "TEST_NODE_PANIC=1")
if err := cmd.Start(); err != nil {
t.Fatal(err)
@@ -46,7 +46,7 @@ func TestNodeValidator_Builds(t *testing.T) {
}
// Test that beacon chain node can close.
func TestNodeClose(t *testing.T) {
func TestNodeClose_OK(t *testing.T) {
hook := logTest.NewGlobal()
tmp := fmt.Sprintf("%s/datadirtest2", testutil.TempDir())

View File

@@ -20,7 +20,7 @@ func init() {
logrus.SetLevel(logrus.DebugLevel)
}
func TestStop(t *testing.T) {
func TestStop_OK(t *testing.T) {
hook := logTest.NewGlobal()
opsService := NewOpsPoolService(context.Background(), &Config{})
@@ -41,7 +41,7 @@ func TestStop(t *testing.T) {
hook.Reset()
}
func TestErrorStatus_Ok(t *testing.T) {
func TestServiceStatus_Error(t *testing.T) {
service := NewOpsPoolService(context.Background(), &Config{})
if service.Status() != nil {
t.Errorf("service status should be nil to begin with, got: %v", service.error)
@@ -97,7 +97,7 @@ func TestIncomingExits_Ok(t *testing.T) {
testutil.AssertLogsContain(t, hook, want)
}
func TestIncomingAttestation_Ok(t *testing.T) {
func TestIncomingAttestation_OK(t *testing.T) {
hook := logTest.NewGlobal()
beaconDB := internal.SetupDB(t)
defer internal.TeardownDB(t, beaconDB)
@@ -126,7 +126,7 @@ func TestIncomingAttestation_Ok(t *testing.T) {
testutil.AssertLogsContain(t, hook, want)
}
func TestRetrieveAttestations_Ok(t *testing.T) {
func TestRetrieveAttestations_OK(t *testing.T) {
beaconDB := internal.SetupDB(t)
defer internal.TeardownDB(t, beaconDB)
service := NewOpsPoolService(context.Background(), &Config{BeaconDB: beaconDB})

View File

@@ -133,7 +133,7 @@ func setup() (*testAccount, error) {
return &testAccount{addr, contract, contractAddr, backend, txOpts}, nil
}
func TestNewWeb3Service(t *testing.T) {
func TestNewWeb3Service_OK(t *testing.T) {
endpoint := "http://127.0.0.1"
ctx := context.Background()
var err error
@@ -174,7 +174,7 @@ func TestNewWeb3Service(t *testing.T) {
}
}
func TestStart(t *testing.T) {
func TestStart_OK(t *testing.T) {
hook := logTest.NewGlobal()
endpoint := "ws://127.0.0.1"
@@ -206,7 +206,7 @@ func TestStart(t *testing.T) {
web3Service.cancel()
}
func TestStop(t *testing.T) {
func TestStop_OK(t *testing.T) {
hook := logTest.NewGlobal()
endpoint := "ws://127.0.0.1"
@@ -245,7 +245,7 @@ func TestStop(t *testing.T) {
hook.Reset()
}
func TestInitDataFromContract(t *testing.T) {
func TestInitDataFromContract_OK(t *testing.T) {
endpoint := "ws://127.0.0.1"
testAcc, err := setup()
if err != nil {
@@ -290,7 +290,7 @@ func TestInitDataFromContract(t *testing.T) {
}
func TestSaveInTrie(t *testing.T) {
func TestSaveInTrie_OK(t *testing.T) {
endpoint := "ws://127.0.0.1"
testAcc, err := setup()
if err != nil {
@@ -319,7 +319,7 @@ func TestSaveInTrie(t *testing.T) {
}
func TestBadReader(t *testing.T) {
func TestWeb3Service_BadReader(t *testing.T) {
hook := logTest.NewGlobal()
endpoint := "ws://127.0.0.1"
testAcc, err := setup()
@@ -349,7 +349,7 @@ func TestBadReader(t *testing.T) {
hook.Reset()
}
func TestLatestMainchainInfo(t *testing.T) {
func TestLatestMainchainInfo_OK(t *testing.T) {
endpoint := "ws://127.0.0.1"
testAcc, err := setup()
if err != nil {
@@ -392,7 +392,7 @@ func TestLatestMainchainInfo(t *testing.T) {
}
}
func TestProcessDepositLog(t *testing.T) {
func TestProcessDepositLog_OK(t *testing.T) {
hook := logTest.NewGlobal()
endpoint := "ws://127.0.0.1"
testAcc, err := setup()
@@ -584,7 +584,7 @@ func TestProcessDepositLog_SkipDuplicateLog(t *testing.T) {
}
}
func TestUnpackDepositLogs(t *testing.T) {
func TestUnpackDepositLogData_OK(t *testing.T) {
endpoint := "ws://127.0.0.1"
testAcc, err := setup()
if err != nil {
@@ -672,7 +672,7 @@ func TestUnpackDepositLogs(t *testing.T) {
}
func TestProcessChainStartLog(t *testing.T) {
func TestProcessChainStartLog_OK(t *testing.T) {
hook := logTest.NewGlobal()
endpoint := "ws://127.0.0.1"
testAcc, err := setup()
@@ -767,7 +767,7 @@ func TestProcessChainStartLog(t *testing.T) {
}
func TestUnpackChainStartLogs(t *testing.T) {
func TestUnpackChainStartLogData_OK(t *testing.T) {
endpoint := "ws://127.0.0.1"
testAcc, err := setup()
if err != nil {
@@ -835,7 +835,7 @@ func TestUnpackChainStartLogs(t *testing.T) {
}
}
func TestHasChainStartLogOccurred(t *testing.T) {
func TestHasChainStartLogOccurred_OK(t *testing.T) {
endpoint := "ws://127.0.0.1"
testAcc, err := setup()
if err != nil {

View File

@@ -17,7 +17,7 @@ import (
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
)
func TestAttestHead(t *testing.T) {
func TestAttestHead_OK(t *testing.T) {
mockOperationService := &mockOperationService{}
attesterServer := &AttesterServer{
operationService: mockOperationService,
@@ -95,7 +95,7 @@ func TestAttestationInfoAtSlot_JustifiedBlockFailure(t *testing.T) {
}
}
func TestAttestationInfoAtSlot_Ok(t *testing.T) {
func TestAttestationInfoAtSlot_OK(t *testing.T) {
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
block := &pbp2p.BeaconBlock{

View File

@@ -259,7 +259,7 @@ func TestLatestAttestation_SendsCorrectly(t *testing.T) {
testutil.AssertLogsContain(t, hook, "Sending attestation to RPC clients")
}
func TestPendingDeposits_ReturnsErrorOnUnknownBlockNum(t *testing.T) {
func TestPendingDeposits_UnknownBlockNum(t *testing.T) {
p := &mockPOWChainService{
latestBlockNumber: nil,
}
@@ -271,7 +271,7 @@ func TestPendingDeposits_ReturnsErrorOnUnknownBlockNum(t *testing.T) {
}
}
func TestPendingDeposits_ReturnsDepositsOutsideEth1FollowWindow(t *testing.T) {
func TestPendingDeposits_OutsideEth1FollowWindow(t *testing.T) {
p := &mockPOWChainService{
latestBlockNumber: big.NewInt(int64(10 + params.BeaconConfig().Eth1FollowDistance)),
}

View File

@@ -15,7 +15,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
)
func TestProposeBlock(t *testing.T) {
func TestProposeBlock_OK(t *testing.T) {
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
mockChain := &mockChainService{}
@@ -65,7 +65,7 @@ func TestProposeBlock(t *testing.T) {
}
}
func TestComputeStateRoot(t *testing.T) {
func TestComputeStateRoot_OK(t *testing.T) {
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
@@ -123,7 +123,7 @@ func TestComputeStateRoot(t *testing.T) {
_, _ = proposerServer.ComputeStateRoot(context.Background(), req)
}
func TestPendingAttestations_Ok(t *testing.T) {
func TestPendingAttestations_OK(t *testing.T) {
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
proposerServer := &ProposerServer{

View File

@@ -84,7 +84,7 @@ func newMockChainService() *mockChainService {
}
}
func TestLifecycle(t *testing.T) {
func TestLifecycle_OK(t *testing.T) {
hook := logTest.NewGlobal()
rpcService := NewRPCService(context.Background(), &Config{
Port: "7348",
@@ -102,7 +102,7 @@ func TestLifecycle(t *testing.T) {
}
func TestBadEndpoint(t *testing.T) {
func TestRPC_BadEndpoint(t *testing.T) {
fl := logrus.WithField("prefix", "rpc")
log = &TestLogger{
@@ -130,7 +130,7 @@ func TestBadEndpoint(t *testing.T) {
}
func TestStatus(t *testing.T) {
func TestStatus_CredentialError(t *testing.T) {
credentialErr := errors.New("credentialError")
s := &Service{credentialError: credentialErr}
@@ -139,7 +139,7 @@ func TestStatus(t *testing.T) {
}
}
func TestInsecureEndpoint(t *testing.T) {
func TestRPC_InsecureEndpoint(t *testing.T) {
hook := logTest.NewGlobal()
rpcService := NewRPCService(context.Background(), &Config{
Port: "7777",

View File

@@ -18,7 +18,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
)
func TestValidatorIndex_Ok(t *testing.T) {
func TestValidatorIndex_OK(t *testing.T) {
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
@@ -49,7 +49,7 @@ func TestValidatorIndex_Ok(t *testing.T) {
}
}
func TestValidatorEpochAssignments_Ok(t *testing.T) {
func TestValidatorEpochAssignments_OK(t *testing.T) {
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
@@ -126,7 +126,7 @@ func TestValidatorCommitteeAtSlot_CrosslinkCommitteesFailure(t *testing.T) {
}
}
func TestValidatorCommitteeAtSlot_Ok(t *testing.T) {
func TestValidatorCommitteeAtSlot_OK(t *testing.T) {
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
genesis := b.NewGenesisBlock([]byte{})

View File

@@ -55,7 +55,7 @@ func (ms *mockChainService) IncomingBlockFeed() *event.Feed {
return &event.Feed{}
}
func TestSetBlockForInitialSync(t *testing.T) {
func TestSetBlock_InitialSync(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
@@ -114,7 +114,7 @@ func TestSetBlockForInitialSync(t *testing.T) {
hook.Reset()
}
func TestSavingBlocksInSync(t *testing.T) {
func TestSavingBlock_InSync(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
@@ -238,7 +238,7 @@ func TestSavingBlocksInSync(t *testing.T) {
hook.Reset()
}
func TestDelayChan(t *testing.T) {
func TestDelayChan_OK(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
@@ -323,7 +323,7 @@ func TestDelayChan(t *testing.T) {
hook.Reset()
}
func TestRequestBlocksBySlot(t *testing.T) {
func TestRequestBlocksBySlot_OK(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)

View File

@@ -38,7 +38,7 @@ func (mp *afterGenesisPowChain) ChainStartFeed() *event.Feed {
return mp.feed
}
func TestStartStop(t *testing.T) {
func TestQuerier_StartStop(t *testing.T) {
hook := logTest.NewGlobal()
cfg := &QuerierConfig{
P2P: &mockP2P{},
@@ -113,7 +113,7 @@ func TestListenForChainStart(t *testing.T) {
sq.cancel()
}
func TestChainReqResponse(t *testing.T) {
func TestQuerier_ChainReqResponse(t *testing.T) {
hook := logTest.NewGlobal()
cfg := &QuerierConfig{
P2P: &mockP2P{},

View File

@@ -67,7 +67,7 @@ func setupService(t *testing.T, db *db.BeaconDB) *RegularSync {
return NewRegularSyncService(context.Background(), cfg)
}
func TestProcessBlockRoot(t *testing.T) {
func TestProcessBlockRoot_OK(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
@@ -111,7 +111,7 @@ func TestProcessBlockRoot(t *testing.T) {
hook.Reset()
}
func TestProcessBlock(t *testing.T) {
func TestProcessBlock_OK(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
@@ -190,7 +190,7 @@ func TestProcessBlock(t *testing.T) {
hook.Reset()
}
func TestProcessMultipleBlocks(t *testing.T) {
func TestProcessBlock_MultipleBlocks(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
@@ -295,7 +295,7 @@ func TestProcessMultipleBlocks(t *testing.T) {
hook.Reset()
}
func TestBlockRequestErrors(t *testing.T) {
func TestBlockRequest_InvalidMsg(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
@@ -325,7 +325,7 @@ func TestBlockRequestErrors(t *testing.T) {
testutil.AssertLogsContain(t, hook, "Received malformed beacon block request p2p message")
}
func TestBlockRequest(t *testing.T) {
func TestBlockRequest_OK(t *testing.T) {
hook := logTest.NewGlobal()
db := internal.SetupDB(t)
@@ -356,7 +356,7 @@ func TestBlockRequest(t *testing.T) {
testutil.AssertLogsDoNotContain(t, hook, "Sending requested block to peer")
}
func TestReceiveAttestation_Ok(t *testing.T) {
func TestReceiveAttestation_OK(t *testing.T) {
hook := logTest.NewGlobal()
ms := &mockChainService{}
os := &mockOperationService{}
@@ -446,7 +446,7 @@ func TestReceiveAttestation_OlderThanFinalizedEpoch(t *testing.T) {
testutil.AssertLogsContain(t, hook, want)
}
func TestReceiveExitReq_Ok(t *testing.T) {
func TestReceiveExitReq_OK(t *testing.T) {
hook := logTest.NewGlobal()
os := &mockOperationService{}
db := internal.SetupDB(t)

View File

@@ -97,7 +97,7 @@ func setupTestSyncService(t *testing.T, synced bool) (*Service, *db.BeaconDB) {
}
func TestStatus_ReturnsNoErrorWhenSynced(t *testing.T) {
func TestStatus_Synced(t *testing.T) {
serviceSynced, db := setupTestSyncService(t, true)
defer internal.TeardownDB(t, db)
if serviceSynced.Status() != nil {
@@ -105,7 +105,7 @@ func TestStatus_ReturnsNoErrorWhenSynced(t *testing.T) {
}
}
func TestStatus_ReturnsErrorWhenNotSynced(t *testing.T) {
func TestStatus_NotSynced(t *testing.T) {
serviceNotSynced, db := setupTestSyncService(t, false)
defer internal.TeardownDB(t, db)
_, querierErr := serviceNotSynced.Querier.IsSynced()

View File

@@ -5,7 +5,7 @@ import (
"time"
)
func TestRealClockIsAccurate(t *testing.T) {
func TestRealClock_IsAccurate(t *testing.T) {
var clock Clock = &RealClock{}
clockTime := clock.Now().Second()
actualTime := time.Now().Second()

View File

@@ -8,7 +8,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
)
func TestFaultyShuffleIndices(t *testing.T) {
func TestShuffleIndices_InvalidValidatorCount(t *testing.T) {
var list []uint64
upperBound := 1<<(params.BeaconConfig().RandBytes*8) - 1
@@ -22,7 +22,7 @@ func TestFaultyShuffleIndices(t *testing.T) {
}
}
func TestShuffleIndices(t *testing.T) {
func TestShuffleIndices_OK(t *testing.T) {
hash1 := common.BytesToHash([]byte{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g'})
hash2 := common.BytesToHash([]byte{'1', '2', '3', '4', '5', '6', '7', '1', '2', '3', '4', '5', '6', '7', '1', '2', '3', '4', '5', '6', '7', '1', '2', '3', '4', '5', '6', '7', '1', '2', '3', '4', '5', '6', '7'})
var list1 []uint64
@@ -55,7 +55,7 @@ func TestShuffleIndices(t *testing.T) {
}
}
func TestSplitIndices(t *testing.T) {
func TestSplitIndices_OK(t *testing.T) {
var l []uint64
validators := 64000
for i := 0; i < validators; i++ {

View File

@@ -62,7 +62,7 @@ func setup() (*testAccount, error) {
return &testAccount{addr, contract, contractAddr, backend, txOpts}, nil
}
func TestSetupAndContractRegistration(t *testing.T) {
func TestSetupRegistrationContract_OK(t *testing.T) {
_, err := setup()
if err != nil {
log.Fatalf("Can not deploy validator registration contract: %v", err)
@@ -70,7 +70,7 @@ func TestSetupAndContractRegistration(t *testing.T) {
}
// negative test case, deposit with less than 1 ETH which is less than the top off amount.
func TestRegisterWithLessThan1Eth(t *testing.T) {
func TestRegister_Below1ETH(t *testing.T) {
testAccount, err := setup()
if err != nil {
t.Fatal(err)
@@ -84,7 +84,7 @@ func TestRegisterWithLessThan1Eth(t *testing.T) {
}
// negative test case, deposit with more than 32 ETH which is more than the asked amount.
func TestRegisterWithMoreThan32Eth(t *testing.T) {
func TestRegister_Above32Eth(t *testing.T) {
testAccount, err := setup()
if err != nil {
t.Fatal(err)
@@ -98,7 +98,7 @@ func TestRegisterWithMoreThan32Eth(t *testing.T) {
}
// normal test case, test depositing 32 ETH and verify HashChainValue event is correctly emitted.
func TestValidatorRegisters(t *testing.T) {
func TestValidatorRegister_OK(t *testing.T) {
testAccount, err := setup()
if err != nil {
t.Fatal(err)
@@ -158,7 +158,7 @@ func TestValidatorRegisters(t *testing.T) {
}
// normal test case, test beacon chain start log event.
func TestChainStarts(t *testing.T) {
func TestChainStart_OK(t *testing.T) {
testAccount, err := setup()
if err != nil {
t.Fatal(err)

View File

@@ -232,16 +232,16 @@ func checkAttesterPoolLength(smc *SMC, n *big.Int) error {
return nil
}
// TestContractCreation tests SMC smart contract can successfully be deployed.
func TestContractCreation(t *testing.T) {
// TestContractCreation_OK tests SMC smart contract can successfully be deployed.
func TestContractCreation_OK(t *testing.T) {
_, err := newSMCTestHelper(1)
if err != nil {
t.Fatalf("can't deploy SMC: %v", err)
}
}
// TestAttesterRegister tests attester registers in a normal condition.
func TestAttesterRegister(t *testing.T) {
// TestRegisterAttesters_OK tests attester registers in a normal condition.
func TestRegisterAttesters_OK(t *testing.T) {
// Initializes 3 accounts to register as attesters.
const attesterCount = 3
s, _ := newSMCTestHelper(attesterCount)
@@ -272,16 +272,16 @@ func TestAttesterRegister(t *testing.T) {
}
}
// TestAttesterRegisterInsufficientEther tests attester registers with insufficient deposit.
func TestAttesterRegisterInsufficientEther(t *testing.T) {
// TestRegisterAttesters_InsufficientEther tests attester registration with insufficient deposit.
func TestRegisterAttesters_InsufficientEther(t *testing.T) {
s, _ := newSMCTestHelper(1)
if err := s.registerAttesters(attesterDepositInsufficient, 0, 1); err == nil {
t.Errorf("Attester register should have failed with insufficient deposit")
}
}
// TestAttesterDoubleRegisters tests attester registers twice.
func TestAttesterDoubleRegisters(t *testing.T) {
// TestRegisterAttesters_DoubleRegister tests the same attester registering twice.
func TestRegisterAttesters_DoubleRegister(t *testing.T) {
s, _ := newSMCTestHelper(1)
// Attester 0 registers.
@@ -304,8 +304,8 @@ func TestAttesterDoubleRegisters(t *testing.T) {
}
}
// TestAttesterDeregister tests attester deregisters in a normal condition.
func TestAttesterDeregister(t *testing.T) {
// TestDeregisterAttesters_OK tests attester deregisters in a normal condition.
func TestDeregisterAttesters_OK(t *testing.T) {
s, _ := newSMCTestHelper(1)
// Attester 0 registers.
@@ -328,8 +328,8 @@ func TestAttesterDeregister(t *testing.T) {
}
}
// TestAttesterDeregisterThenRegister tests attester deregisters then registers before lock up ends.
func TestAttesterDeregisterThenRegister(t *testing.T) {
// TestDeregisterAttesters_RegisterAgain tests attester deregisteration and then registers before lock up ends.
func TestDeregisterAttesters_RegisterAgain(t *testing.T) {
s, _ := newSMCTestHelper(1)
// Attester 0 registers.
@@ -362,7 +362,7 @@ func TestAttesterDeregisterThenRegister(t *testing.T) {
}
// TestAttesterRelease tests attester releases in a normal condition.
func TestAttesterRelease(t *testing.T) {
func TestReleaseAttester_OK(t *testing.T) {
s, _ := newSMCTestHelper(1)
// Attester 0 registers.
@@ -409,7 +409,7 @@ func TestAttesterRelease(t *testing.T) {
}
// TestAttesterInstantRelease tests attester releases before lockup ends.
func TestAttesterInstantRelease(t *testing.T) {
func TestReleaseAttester_BeforeLockup(t *testing.T) {
s, _ := newSMCTestHelper(1)
// Attester 0 registers.
@@ -448,8 +448,8 @@ func TestAttesterInstantRelease(t *testing.T) {
}
}
// TestCommitteeListsAreDifferent tests different shards have different attester committee.
func TestCommitteeListsAreDifferent(t *testing.T) {
// TestCommitteeListsAreDifferent tests that different shards should have different attester committee.
func TestCommitteeListsAreDifferent_OK(t *testing.T) {
const attesterCount = 1000
s, _ := newSMCTestHelper(attesterCount)
@@ -473,8 +473,8 @@ func TestCommitteeListsAreDifferent(t *testing.T) {
}
}
// TestGetCommitteeWithNonMember tests unregistered attester tries to be in the committee.
func TestGetCommitteeWithNonMember(t *testing.T) {
// TestGetAttesterInCommittee_NonMember tests unregistered attester trying to be in the committee.
func TestGetAttesterInCommittee_NonMember(t *testing.T) {
const attesterCount = 11
s, _ := newSMCTestHelper(attesterCount)
@@ -497,8 +497,8 @@ func TestGetCommitteeWithNonMember(t *testing.T) {
}
}
// TestGetCommitteeWithinSamePeriod tests attester registers and samples within the same period.
func TestGetCommitteeWithinSamePeriod(t *testing.T) {
// TestGetAttesterInCommittee_SamePeriod tests attester registeration and samples within the same period.
func TestGetAttesterInCommittee_SamePeriod(t *testing.T) {
s, _ := newSMCTestHelper(1)
// Attester 0 registers.
@@ -519,7 +519,7 @@ func TestGetCommitteeWithinSamePeriod(t *testing.T) {
}
// TestGetCommitteeAfterDeregisters tests attester tries to be in committee after deregistered.
func TestGetCommitteeAfterDeregisters(t *testing.T) {
func TestGetAttesterInCommittee_AfterDeregister(t *testing.T) {
const attesterCount = 10
s, _ := newSMCTestHelper(attesterCount)
@@ -549,8 +549,8 @@ func TestGetCommitteeAfterDeregisters(t *testing.T) {
}
}
// TestNormalAddHeader tests proposer add header in normal condition.
func TestNormalAddHeader(t *testing.T) {
// TestAddHeader_OK tests proposer adding header in normal condition.
func TestAddHeader_OK(t *testing.T) {
s, _ := newSMCTestHelper(1)
s.fastForward(1)
@@ -574,7 +574,7 @@ func TestNormalAddHeader(t *testing.T) {
}
// TestAddTwoHeadersAtSamePeriod tests we can't add two headers within the same period.
func TestAddTwoHeadersAtSamePeriod(t *testing.T) {
func TestAddHeader_TwoSamePeriod(t *testing.T) {
s, _ := newSMCTestHelper(1)
s.fastForward(1)
@@ -591,8 +591,8 @@ func TestAddTwoHeadersAtSamePeriod(t *testing.T) {
}
}
// TestAddHeadersAtWrongPeriod tests proposer adds header in the wrong period.
func TestAddHeadersAtWrongPeriod(t *testing.T) {
// TestAddHeader_WrongPeriod tests proposer adding the header in the wrong period.
func TestAddHeader_WrongPeriod(t *testing.T) {
s, _ := newSMCTestHelper(1)
s.fastForward(1)
@@ -613,8 +613,8 @@ func TestAddHeadersAtWrongPeriod(t *testing.T) {
}
}
// TestSubmitVote tests attester submit votes in normal condition.
func TestSubmitVote(t *testing.T) {
// TestSubmitVote_OK tests attester submitting votes in normal condition.
func TestSubmitVote_OK(t *testing.T) {
s, _ := newSMCTestHelper(1)
// Attester 0 registers.
if err := s.registerAttesters(attesterDeposit, 0, 1); err != nil {
@@ -664,8 +664,8 @@ func TestSubmitVote(t *testing.T) {
}
// TestSubmitVoteTwice tests attester tries to submit same vote twice.
func TestSubmitVoteTwice(t *testing.T) {
// TestSubmitVote_Twice tests attester trying to submit same vote twice.
func TestSubmitVote_Twice(t *testing.T) {
s, _ := newSMCTestHelper(1)
// Attester 0 registers.
if err := s.registerAttesters(attesterDeposit, 0, 1); err != nil {
@@ -699,8 +699,8 @@ func TestSubmitVoteTwice(t *testing.T) {
}
}
// TestSubmitVoteByNonEligibleAttester tests a non-eligible attester tries to submit vote.
func TestSubmitVoteByNonEligibleAttester(t *testing.T) {
// TestSubmitVote_IneligibleAttester tests a ineligible attester tries to submit vote.
func TestSubmitVote_IneligibleAttester(t *testing.T) {
s, _ := newSMCTestHelper(1)
s.fastForward(1)
@@ -726,8 +726,8 @@ func TestSubmitVoteByNonEligibleAttester(t *testing.T) {
}
}
// TestSubmitVoteWithOutAHeader tests a attester tries to submit vote before header gets added.
func TestSubmitVoteWithOutAHeader(t *testing.T) {
// TestSubmitVote_NoHeader tests a attester tries to submit vote before header gets added.
func TestSubmitVote_NoHeader(t *testing.T) {
s, _ := newSMCTestHelper(1)
// Attester 0 registers.
if err := s.registerAttesters(attesterDeposit, 0, 1); err != nil {
@@ -753,8 +753,8 @@ func TestSubmitVoteWithOutAHeader(t *testing.T) {
}
}
// TestSubmitVoteWithInvalidArgs tests attester submits vote using wrong chunkroot and period.
func TestSubmitVoteWithInvalidArgs(t *testing.T) {
// TestSubmitVote_InvalidArgs tests attester submits vote using wrong chunkroot and period.
func TestSubmitVote_InvalidArgs(t *testing.T) {
s, _ := newSMCTestHelper(1)
// Attester 0 registers.
if err := s.registerAttesters(attesterDeposit, 0, 1); err != nil {

View File

@@ -7,7 +7,7 @@ import (
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
)
func TestForkVersion(t *testing.T) {
func TestForkVersion_OK(t *testing.T) {
fork := &pb.Fork{
Epoch: 10,
PreviousVersion: 2,
@@ -23,7 +23,7 @@ func TestForkVersion(t *testing.T) {
}
}
func TestDomainVersion(t *testing.T) {
func TestDomainVersion_OK(t *testing.T) {
fork := &pb.Fork{
Epoch: 10,
PreviousVersion: 2,

View File

@@ -63,8 +63,8 @@ func TestStoreRandomKey(t *testing.T) {
if err := os.RemoveAll(filedir); err != nil {
t.Errorf("unable to remove temporary files %v", err)
}
}
func TestNewKeyFromBLS(t *testing.T) {
b := []byte("hi")
b32 := bytesutil.ToBytes32(b)
@@ -88,7 +88,6 @@ func TestNewKeyFromBLS(t *testing.T) {
if err != nil {
t.Fatalf("random key unable to be generated: %v", err)
}
}
func TestWriteFile(t *testing.T) {

View File

@@ -13,7 +13,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/testutil"
)
func TestStoreandGetKey(t *testing.T) {
func TestStoreAndGetKey(t *testing.T) {
tmpdir := testutil.TempDir()
filedir := tmpdir + "/keystore"
ks := &Store{

View File

@@ -16,7 +16,7 @@ import (
const addr = "127.0.0.1:8989"
func TestMessageMetrics(t *testing.T) {
func TestMessageMetrics_OK(t *testing.T) {
service := prometheus.NewPrometheusService(addr, nil)
go service.Start()
defer service.Stop()

View File

@@ -7,7 +7,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/p2p"
)
func TestNewTracer(t *testing.T) {
func TestNewTracer_OK(t *testing.T) {
a, err := New("test", "test:1234", 0.25, false)
if err != nil {
t.Errorf("Unexpected error: %s", err.Error())
@@ -32,7 +32,7 @@ func TestNewTracer(t *testing.T) {
}
}
func TestNewTracerBad(t *testing.T) {
func TestNewTracer_EmptyData(t *testing.T) {
_, err := New("", "test:1234", 0.25, true)
if err == nil {
t.Errorf("Expected error with empty name")

View File

@@ -9,14 +9,14 @@ import (
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
)
func TestMakePeerFails(t *testing.T) {
func TestMakePeer_InvalidMultiaddress(t *testing.T) {
_, err := MakePeer("/ip4")
if err == nil {
t.Error("Expect error when invalid multiaddress was provided")
}
}
func TestMakePeerSucceeds(t *testing.T) {
func TestMakePeer_OK(t *testing.T) {
a, err := MakePeer("/ip4/127.0.0.1/tcp/5678/p2p/QmUn6ycS8Fu6L462uZvuEfDoSgYX6kqP4aSZWMa7z1tWAX")
if err != nil {
t.Fatalf("Unexpected error when making a valid peer: %v", err)
@@ -27,13 +27,13 @@ func TestMakePeerSucceeds(t *testing.T) {
}
}
func TestDialRelayNodeFailsInvalidPeerString(t *testing.T) {
func TestDialRelayNode_InvalidPeerString(t *testing.T) {
if err := dialRelayNode(context.Background(), nil, "/ip4"); err == nil {
t.Fatal("Expected to fail with invalid peer string, but there was no error")
}
}
func TestDialRelayNodeSucceeds(t *testing.T) {
func TestDialRelayNode_OK(t *testing.T) {
ctx := context.Background()
relay := bh.NewBlankHost(swarmt.GenSwarm(t, ctx))
host := bh.NewBlankHost(swarmt.GenSwarm(t, ctx))

View File

@@ -24,7 +24,7 @@ func expectPeers(t *testing.T, h *bhost.BasicHost, n int) {
}
}
func TestStartDiscovery_HandlePeerFound(t *testing.T) {
func TestStartDiscovery_PeerFound(t *testing.T) {
discoveryInterval = 50 * time.Millisecond // Short interval for testing.
ctx, cancel := context.WithCancel(context.TODO())

View File

@@ -9,7 +9,7 @@ import (
testpb "github.com/prysmaticlabs/prysm/proto/testing"
)
func TestFeed_ReturnsSameFeed(t *testing.T) {
func TestFeed_SameFeed(t *testing.T) {
tests := []struct {
a proto.Message
b proto.Message

View File

@@ -32,7 +32,7 @@ func init() {
ipfslog.SetDebugLogging()
}
func TestStartDialRelayNodeFails(t *testing.T) {
func TestStartDialRelayNode_InvalidMultiaddress(t *testing.T) {
hook := logTest.NewGlobal()
s, err := NewServer(&ServerConfig{
@@ -47,10 +47,10 @@ func TestStartDialRelayNodeFails(t *testing.T) {
logContains(t, hook, "Could not dial relay node: invalid multiaddr, must begin with /", logrus.ErrorLevel)
}
func TestP2pPortTakenError(t *testing.T) {
thePort := 10000
func TestP2P_PortTaken(t *testing.T) {
port := 10000
_, err := NewServer(&ServerConfig{
Port: thePort,
Port: port,
})
if err != nil {
@@ -58,15 +58,15 @@ func TestP2pPortTakenError(t *testing.T) {
}
_, err = NewServer(&ServerConfig{
Port: thePort,
Port: port,
})
if !strings.Contains(err.Error(), fmt.Sprintf("port %d already taken", thePort)) {
if !strings.Contains(err.Error(), fmt.Sprintf("port %d already taken", port)) {
t.Fatalf("expected fail when setting another server with same p2p port")
}
}
func TestBroadcast(t *testing.T) {
func TestBroadcast_OK(t *testing.T) {
s, err := NewServer(&ServerConfig{})
if err != nil {
t.Fatalf("Could not start a new server: %v", err)
@@ -78,7 +78,7 @@ func TestBroadcast(t *testing.T) {
// TODO(543): test that topic was published
}
func TestEmit(t *testing.T) {
func TestEmit_OK(t *testing.T) {
s, _ := NewServer(&ServerConfig{})
p := &testpb.TestMessage{Foo: "bar"}
@@ -95,7 +95,7 @@ func TestEmit(t *testing.T) {
}
}
func TestSubscribeToTopic(t *testing.T) {
func TestSubscribeToTopic_OK(t *testing.T) {
ctx, cancel := context.WithTimeout(context.TODO(), 1*time.Second)
defer cancel()
h := bhost.NewBlankHost(swarmt.GenSwarm(t, ctx))
@@ -122,7 +122,7 @@ func TestSubscribeToTopic(t *testing.T) {
testSubscribe(ctx, t, s, gsub, ch)
}
func TestSubscribe(t *testing.T) {
func TestSubscribe_OK(t *testing.T) {
ctx, cancel := context.WithTimeout(context.TODO(), 1*time.Second)
defer cancel()
h := bhost.NewBlankHost(swarmt.GenSwarm(t, ctx))
@@ -191,7 +191,7 @@ func testSubscribe(ctx context.Context, t *testing.T, s Server, gsub *pubsub.Pub
}
}
func TestRegisterTopic_HandleInvalidProtobufs(t *testing.T) {
func TestRegisterTopic_InvalidProtobufs(t *testing.T) {
topic := shardpb.Topic_COLLATION_BODY_REQUEST
hook := logTest.NewGlobal()

View File

@@ -35,7 +35,7 @@ func (s *secondMockService) Status() error {
return s.status
}
func TestRegisterServiceTwice(t *testing.T) {
func TestRegisterService_Twice(t *testing.T) {
registry := &ServiceRegistry{
services: make(map[reflect.Type]Service),
}
@@ -55,7 +55,7 @@ func TestRegisterServiceTwice(t *testing.T) {
}
}
func TestRegisterDifferentServices(t *testing.T) {
func TestRegisterService_Different(t *testing.T) {
registry := &ServiceRegistry{
services: make(map[reflect.Type]Service),
}
@@ -83,7 +83,7 @@ func TestRegisterDifferentServices(t *testing.T) {
}
}
func TestFetchService(t *testing.T) {
func TestFetchService_OK(t *testing.T) {
registry := &ServiceRegistry{
services: make(map[reflect.Type]Service),
}
@@ -112,7 +112,7 @@ func TestFetchService(t *testing.T) {
}
}
func TestServiceStatus(t *testing.T) {
func TestServiceStatus_OK(t *testing.T) {
registry := &ServiceRegistry{
services: make(map[reflect.Type]Service),
}

View File

@@ -68,7 +68,7 @@ func (e *exampleStruct2) TreeHashSSZ() ([32]byte, error) {
})
}
func TestEncodeDecodeExampleStruct1(t *testing.T) {
func TestEncodeDecode_Struct1(t *testing.T) {
var err error
e1 := &exampleStruct1{
Field1: 10,
@@ -107,7 +107,7 @@ func TestEncodeDecodeExampleStruct1(t *testing.T) {
}
}
func TestEncodeDecodeExampleStruct2(t *testing.T) {
func TestEncodeDecode_Struct2(t *testing.T) {
var err error
e1 := &exampleStruct2{
Field1: 10,

View File

@@ -7,7 +7,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/hashutil"
)
func TestDepositTrie_UpdateDepositTrie(t *testing.T) {
func TestDepositTrie_UpdateDeposit(t *testing.T) {
tests := []struct {
deposits [][]byte
}{
@@ -60,7 +60,7 @@ func TestDepositTrie_UpdateDepositTrie(t *testing.T) {
}
}
func TestDepositTrie_VerifyMerkleBranch(t *testing.T) {
func TestVerifyMerkleBranch_OK(t *testing.T) {
d := NewDepositTrie()
deposit1 := []byte{1, 2, 3}
d.UpdateDepositTrie(deposit1)

View File

@@ -29,7 +29,7 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}
func TestStop_cancelsContext(t *testing.T) {
func TestStop_CancelsContext(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
vs := &ValidatorService{
ctx: ctx,
@@ -66,7 +66,7 @@ func TestLifecycle(t *testing.T) {
testutil.AssertLogsContain(t, hook, "Stopping service")
}
func TestLifecycle_WithInsecure(t *testing.T) {
func TestLifecycle_Insecure(t *testing.T) {
hook := logTest.NewGlobal()
// Use cancelled context so that the run function exits immediately.
ctx, cancel := context.WithCancel(context.Background())
@@ -85,7 +85,7 @@ func TestLifecycle_WithInsecure(t *testing.T) {
testutil.AssertLogsContain(t, hook, "Stopping service")
}
func TestStatus(t *testing.T) {
func TestStatus_NoConnectionError(t *testing.T) {
validatorService := &ValidatorService{}
if err := validatorService.Status(); !strings.Contains(err.Error(), "no connection") {
t.Errorf("Expected status check to fail if no connection is found, received: %v", err)

View File

@@ -182,7 +182,7 @@ func TestUpdateAssignments_ReturnsError(t *testing.T) {
}
}
func TestUpdateAssignments_DoesUpdateAssignments(t *testing.T) {
func TestUpdateAssignments_OK(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := internal.NewMockValidatorServiceClient(ctrl)