mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
@@ -19,7 +19,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
"github.com/prysmaticlabs/prysm/v3/container/slice"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
)
|
||||
|
||||
func TestBlocksFetcher_InitStartStop(t *testing.T) {
|
||||
mc, p2p, _ := initializeTestServices(t, []types.Slot{}, []*peerData{})
|
||||
mc, p2p, _ := initializeTestServices(t, []primitives.Slot{}, []*peerData{})
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
@@ -100,8 +100,8 @@ func TestBlocksFetcher_InitStartStop(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBlocksFetcher_RoundRobin(t *testing.T) {
|
||||
slotsInBatch := types.Slot(flags.Get().BlockBatchLimit)
|
||||
requestsGenerator := func(start, end, batchSize types.Slot) []*fetchRequestParams {
|
||||
slotsInBatch := primitives.Slot(flags.Get().BlockBatchLimit)
|
||||
requestsGenerator := func(start, end, batchSize primitives.Slot) []*fetchRequestParams {
|
||||
var requests []*fetchRequestParams
|
||||
for i := start; i <= end; i += batchSize {
|
||||
requests = append(requests, &fetchRequestParams{
|
||||
@@ -113,7 +113,7 @@ func TestBlocksFetcher_RoundRobin(t *testing.T) {
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
expectedBlockSlots []types.Slot
|
||||
expectedBlockSlots []primitives.Slot
|
||||
peers []*peerData
|
||||
requests []*fetchRequestParams
|
||||
}{
|
||||
@@ -343,7 +343,7 @@ func TestBlocksFetcher_RoundRobin(t *testing.T) {
|
||||
return blocks[i].Block().Slot() < blocks[j].Block().Slot()
|
||||
})
|
||||
|
||||
ss := make([]types.Slot, len(blocks))
|
||||
ss := make([]primitives.Slot, len(blocks))
|
||||
for i, block := range blocks {
|
||||
ss[i] = block.Block().Slot()
|
||||
}
|
||||
@@ -357,7 +357,7 @@ func TestBlocksFetcher_RoundRobin(t *testing.T) {
|
||||
t.Errorf("Too many blocks returned. Wanted %d got %d", maxExpectedBlocks, len(blocks))
|
||||
}
|
||||
assert.Equal(t, len(tt.expectedBlockSlots), len(blocks), "Processes wrong number of blocks")
|
||||
var receivedBlockSlots []types.Slot
|
||||
var receivedBlockSlots []primitives.Slot
|
||||
for _, blk := range blocks {
|
||||
receivedBlockSlots = append(receivedBlockSlots, blk.Block().Slot())
|
||||
}
|
||||
@@ -395,10 +395,10 @@ func TestBlocksFetcher_scheduleRequest(t *testing.T) {
|
||||
func TestBlocksFetcher_handleRequest(t *testing.T) {
|
||||
blockBatchLimit := flags.Get().BlockBatchLimit
|
||||
chainConfig := struct {
|
||||
expectedBlockSlots []types.Slot
|
||||
expectedBlockSlots []primitives.Slot
|
||||
peers []*peerData
|
||||
}{
|
||||
expectedBlockSlots: makeSequence(1, types.Slot(blockBatchLimit)),
|
||||
expectedBlockSlots: makeSequence(1, primitives.Slot(blockBatchLimit)),
|
||||
peers: []*peerData{
|
||||
{
|
||||
blocks: makeSequence(1, 320),
|
||||
@@ -461,7 +461,7 @@ func TestBlocksFetcher_handleRequest(t *testing.T) {
|
||||
t.Errorf("incorrect number of blocks returned, expected: %v, got: %v", blockBatchLimit, len(blocks))
|
||||
}
|
||||
|
||||
var receivedBlockSlots []types.Slot
|
||||
var receivedBlockSlots []primitives.Slot
|
||||
for _, blk := range blocks {
|
||||
receivedBlockSlots = append(receivedBlockSlots, blk.Block().Slot())
|
||||
}
|
||||
@@ -475,7 +475,7 @@ func TestBlocksFetcher_handleRequest(t *testing.T) {
|
||||
func TestBlocksFetcher_requestBeaconBlocksByRange(t *testing.T) {
|
||||
blockBatchLimit := flags.Get().BlockBatchLimit
|
||||
chainConfig := struct {
|
||||
expectedBlockSlots []types.Slot
|
||||
expectedBlockSlots []primitives.Slot
|
||||
peers []*peerData
|
||||
}{
|
||||
expectedBlockSlots: makeSequence(1, 320),
|
||||
@@ -644,7 +644,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T)
|
||||
},
|
||||
handlerGenFn: func(req *ethpb.BeaconBlocksByRangeRequest) func(stream network.Stream) {
|
||||
return func(stream network.Stream) {
|
||||
for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += types.Slot(req.Step) {
|
||||
for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += primitives.Slot(req.Step) {
|
||||
blk := util.NewBeaconBlock()
|
||||
blk.Block.Slot = i
|
||||
mchain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
|
||||
@@ -668,7 +668,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T)
|
||||
},
|
||||
handlerGenFn: func(req *ethpb.BeaconBlocksByRangeRequest) func(stream network.Stream) {
|
||||
return func(stream network.Stream) {
|
||||
for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step+1); i += types.Slot(req.Step) {
|
||||
for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step+1); i += primitives.Slot(req.Step) {
|
||||
blk := util.NewBeaconBlock()
|
||||
blk.Block.Slot = i
|
||||
chain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
|
||||
@@ -755,7 +755,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T)
|
||||
defer func() {
|
||||
assert.NoError(t, stream.Close())
|
||||
}()
|
||||
for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += types.Slot(req.Step) {
|
||||
for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += primitives.Slot(req.Step) {
|
||||
blk := util.NewBeaconBlock()
|
||||
chain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
|
||||
// Patch mid block, with invalid slot number.
|
||||
@@ -790,7 +790,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T)
|
||||
defer func() {
|
||||
assert.NoError(t, stream.Close())
|
||||
}()
|
||||
for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += types.Slot(req.Step) {
|
||||
for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += primitives.Slot(req.Step) {
|
||||
blk := util.NewBeaconBlock()
|
||||
chain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
|
||||
// Patch mid block, with invalid slot number.
|
||||
|
||||
Reference in New Issue
Block a user