Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename NewService to New #8337

Merged
merged 9 commits into from
Jan 26, 2021
2 changes: 1 addition & 1 deletion beacon-chain/blockchain/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestService_TreeHandler(t *testing.T) {
),
StateGen: stategen.New(beaconDB),
}
s, err := NewService(ctx, cfg)
s, err := New(ctx, cfg)
require.NoError(t, err)
require.NoError(t, s.forkChoiceStore.ProcessBlock(ctx, 0, [32]byte{'a'}, [32]byte{'g'}, [32]byte{'c'}, 0, 0))
require.NoError(t, s.forkChoiceStore.ProcessBlock(ctx, 1, [32]byte{'b'}, [32]byte{'a'}, [32]byte{'c'}, 0, 0))
Expand Down
26 changes: 13 additions & 13 deletions beacon-chain/blockchain/process_attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestStore_OnAttestation_ErrorConditions(t *testing.T) {
ForkChoiceStore: protoarray.New(0, 0, [32]byte{}),
StateGen: stategen.New(beaconDB),
}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

_, err = blockTree1(beaconDB, []byte{'g'})
Expand Down Expand Up @@ -133,7 +133,7 @@ func TestStore_OnAttestation_Ok(t *testing.T) {
ForkChoiceStore: protoarray.New(0, 0, [32]byte{}),
StateGen: stategen.New(beaconDB),
}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)
genesisState, pks := testutil.DeterministicGenesisState(t, 64)
require.NoError(t, genesisState.SetGenesisTime(uint64(timeutils.Now().Unix())-params.BeaconConfig().SecondsPerSlot))
Expand All @@ -157,7 +157,7 @@ func TestStore_SaveCheckpointState(t *testing.T) {
BeaconDB: beaconDB,
StateGen: stategen.New(beaconDB),
}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

s := testutil.NewBeaconState()
Expand Down Expand Up @@ -228,7 +228,7 @@ func TestStore_UpdateCheckpointState(t *testing.T) {
BeaconDB: beaconDB,
StateGen: stategen.New(beaconDB),
}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

epoch := uint64(1)
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestAttEpoch_MatchPrevEpoch(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

nowTime := params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().SecondsPerSlot
Expand All @@ -278,7 +278,7 @@ func TestAttEpoch_MatchCurrentEpoch(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

nowTime := params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().SecondsPerSlot
Expand All @@ -290,7 +290,7 @@ func TestAttEpoch_NotMatch(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

nowTime := 2 * params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().SecondsPerSlot
Expand All @@ -303,7 +303,7 @@ func TestVerifyBeaconBlock_NoBlock(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

d := testutil.HydrateAttestationData(&ethpb.AttestationData{})
Expand All @@ -315,7 +315,7 @@ func TestVerifyBeaconBlock_futureBlock(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

b := testutil.NewBeaconBlock()
Expand All @@ -333,7 +333,7 @@ func TestVerifyBeaconBlock_OK(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

b := testutil.NewBeaconBlock()
Expand All @@ -351,7 +351,7 @@ func TestVerifyFinalizedConsistency_InconsistentRoot(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB, ForkChoiceStore: protoarray.New(0, 0, [32]byte{})}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

b32 := testutil.NewBeaconBlock()
Expand All @@ -378,7 +378,7 @@ func TestVerifyFinalizedConsistency_OK(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB, ForkChoiceStore: protoarray.New(0, 0, [32]byte{})}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

b32 := testutil.NewBeaconBlock()
Expand All @@ -405,7 +405,7 @@ func TestVerifyFinalizedConsistency_IsCanonical(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB, ForkChoiceStore: protoarray.New(0, 0, [32]byte{})}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

b32 := testutil.NewBeaconBlock()
Expand Down
42 changes: 21 additions & 21 deletions beacon-chain/blockchain/process_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestStore_OnBlock(t *testing.T) {
StateGen: stategen.New(beaconDB),
ForkChoiceStore: protoarray.New(0, 0, [32]byte{}),
}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)
genesisStateRoot := [32]byte{}
genesis := blocks.NewGenesisBlock(genesisStateRoot[:])
Expand Down Expand Up @@ -129,7 +129,7 @@ func TestStore_OnBlockBatch(t *testing.T) {
BeaconDB: beaconDB,
StateGen: stategen.New(beaconDB),
}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

genesisStateRoot := [32]byte{}
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestRemoveStateSinceLastFinalized_EmptyStartSlot(t *testing.T) {
defer params.UseMainnetConfig()

cfg := &Config{BeaconDB: beaconDB, ForkChoiceStore: protoarray.New(0, 0, [32]byte{})}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)
service.genesisTime = time.Now()

Expand Down Expand Up @@ -213,7 +213,7 @@ func TestShouldUpdateJustified_ReturnFalse(t *testing.T) {
defer params.UseMainnetConfig()

cfg := &Config{BeaconDB: beaconDB}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)
lastJustifiedBlk := testutil.NewBeaconBlock()
lastJustifiedBlk.Block.ParentRoot = bytesutil.PadTo([]byte{'G'}, 32)
Expand Down Expand Up @@ -243,7 +243,7 @@ func TestCachedPreState_CanGetFromStateSummary(t *testing.T) {
BeaconDB: beaconDB,
StateGen: stategen.New(beaconDB),
}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

s, err := stateTrie.InitializeFromProto(&pb.BeaconState{Slot: 1, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]})
Expand Down Expand Up @@ -276,7 +276,7 @@ func TestCachedPreState_CanGetFromDB(t *testing.T) {
BeaconDB: beaconDB,
StateGen: stategen.New(beaconDB),
}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

genesisStateRoot := [32]byte{}
Expand Down Expand Up @@ -310,7 +310,7 @@ func TestUpdateJustified_CouldUpdateBest(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB, StateGen: stategen.New(beaconDB)}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

signedBlock := testutil.NewBeaconBlock()
Expand Down Expand Up @@ -341,7 +341,7 @@ func TestFillForkChoiceMissingBlocks_CanSave(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)
service.forkChoiceStore = protoarray.New(0, 0, [32]byte{'A'})
service.finalizedCheckpt = &ethpb.Checkpoint{Root: make([]byte, 32)}
Expand Down Expand Up @@ -378,7 +378,7 @@ func TestFillForkChoiceMissingBlocks_RootsMatch(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)
service.forkChoiceStore = protoarray.New(0, 0, [32]byte{'A'})
service.finalizedCheckpt = &ethpb.Checkpoint{Root: make([]byte, 32)}
Expand Down Expand Up @@ -418,7 +418,7 @@ func TestFillForkChoiceMissingBlocks_FilterFinalized(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)
service.forkChoiceStore = protoarray.New(0, 0, [32]byte{'A'})
// Set finalized epoch to 1.
Expand Down Expand Up @@ -558,7 +558,7 @@ func TestCurrentSlot_HandlesOverflow(t *testing.T) {
}
func TestAncestorByDB_CtxErr(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
service, err := NewService(ctx, &Config{})
service, err := New(ctx, &Config{})
require.NoError(t, err)

cancel()
Expand All @@ -571,7 +571,7 @@ func TestAncestor_HandleSkipSlot(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB, ForkChoiceStore: protoarray.New(0, 0, [32]byte{})}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

b1 := testutil.NewBeaconBlock()
Expand Down Expand Up @@ -614,7 +614,7 @@ func TestAncestor_HandleSkipSlot(t *testing.T) {
func TestAncestor_CanUseForkchoice(t *testing.T) {
ctx := context.Background()
cfg := &Config{ForkChoiceStore: protoarray.New(0, 0, [32]byte{})}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

b1 := testutil.NewBeaconBlock()
Expand Down Expand Up @@ -653,7 +653,7 @@ func TestAncestor_CanUseDB(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB, ForkChoiceStore: protoarray.New(0, 0, [32]byte{})}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

b1 := testutil.NewBeaconBlock()
Expand Down Expand Up @@ -690,7 +690,7 @@ func TestAncestor_CanUseDB(t *testing.T) {
func TestEnsureRootNotZeroHashes(t *testing.T) {
ctx := context.Background()
cfg := &Config{}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)
service.genesisRoot = [32]byte{'a'}

Expand Down Expand Up @@ -743,7 +743,7 @@ func TestFinalizedImpliesNewJustified(t *testing.T) {
for _, test := range tests {
beaconState := testutil.NewBeaconState()
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(test.args.stateCheckPoint))
service, err := NewService(ctx, &Config{BeaconDB: beaconDB, StateGen: stategen.New(beaconDB), ForkChoiceStore: protoarray.New(0, 0, [32]byte{})})
service, err := New(ctx, &Config{BeaconDB: beaconDB, StateGen: stategen.New(beaconDB), ForkChoiceStore: protoarray.New(0, 0, [32]byte{})})
require.NoError(t, err)
service.justifiedCheckpt = test.args.cachedCheckPoint
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &pb.StateSummary{Root: bytesutil.PadTo(test.want.Root, 32)}))
Expand Down Expand Up @@ -834,7 +834,7 @@ func TestVerifyBlkDescendant(t *testing.T) {
},
}
for _, tt := range tests {
service, err := NewService(ctx, &Config{BeaconDB: beaconDB, StateGen: stategen.New(beaconDB), ForkChoiceStore: protoarray.New(0, 0, [32]byte{})})
service, err := New(ctx, &Config{BeaconDB: beaconDB, StateGen: stategen.New(beaconDB), ForkChoiceStore: protoarray.New(0, 0, [32]byte{})})
require.NoError(t, err)
service.finalizedCheckpt = &ethpb.Checkpoint{
Root: tt.args.finalizedRoot[:],
Expand All @@ -852,7 +852,7 @@ func TestUpdateJustifiedInitSync(t *testing.T) {
beaconDB := testDB.SetupDB(t)
ctx := context.Background()
cfg := &Config{BeaconDB: beaconDB}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

gBlk := testutil.NewBeaconBlock()
Expand Down Expand Up @@ -880,7 +880,7 @@ func TestUpdateJustifiedInitSync(t *testing.T) {
func TestHandleEpochBoundary_BadMetrics(t *testing.T) {
ctx := context.Background()
cfg := &Config{}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

s := testutil.NewBeaconState()
Expand All @@ -892,7 +892,7 @@ func TestHandleEpochBoundary_BadMetrics(t *testing.T) {
func TestHandleEpochBoundary_UpdateFirstSlot(t *testing.T) {
ctx := context.Background()
cfg := &Config{}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

s, _ := testutil.DeterministicGenesisState(t, 1024)
Expand All @@ -913,7 +913,7 @@ func TestOnBlock_CanFinalize(t *testing.T) {
ForkChoiceStore: protoarray.New(0, 0, [32]byte{}),
DepositCache: depositCache,
}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

gs, keys := testutil.DeterministicGenesisState(t, 32)
Expand Down
6 changes: 3 additions & 3 deletions beacon-chain/blockchain/receive_attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestVerifyLMDFFGConsistent_NotOK(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB, ForkChoiceStore: protoarray.New(0, 0, [32]byte{})}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

b32 := testutil.NewBeaconBlock()
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestVerifyLMDFFGConsistent_OK(t *testing.T) {
beaconDB := testDB.SetupDB(t)

cfg := &Config{BeaconDB: beaconDB, ForkChoiceStore: protoarray.New(0, 0, [32]byte{})}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
require.NoError(t, err)

b32 := testutil.NewBeaconBlock()
Expand Down Expand Up @@ -99,7 +99,7 @@ func TestProcessAttestations_Ok(t *testing.T) {
StateGen: stategen.New(beaconDB),
AttPool: attestations.NewPool(),
}
service, err := NewService(ctx, cfg)
service, err := New(ctx, cfg)
service.genesisTime = timeutils.Now().Add(-1 * time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second)
require.NoError(t, err)
genesisState, pks := testutil.DeterministicGenesisState(t, 64)
Expand Down
Loading