Move Shared/Testutil into Testing (#9659)

* move testutil

* util pkg

* build

* gaz

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Raul Jordan
2021-09-23 13:53:46 -05:00
committed by GitHub
parent 2952bb3570
commit a9a4bb9163
654 changed files with 2950 additions and 2950 deletions

View File

@@ -25,9 +25,9 @@ import (
p2ppb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/prysmaticlabs/prysm/testing/assert"
"github.com/prysmaticlabs/prysm/testing/require"
"github.com/prysmaticlabs/prysm/testing/util"
"github.com/sirupsen/logrus"
logTest "github.com/sirupsen/logrus/hooks/test"
)
@@ -268,10 +268,10 @@ func TestBlocksFetcher_RoundRobin(t *testing.T) {
genesisRoot := cache.rootCache[0]
cache.RUnlock()
err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()))
err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(util.NewBeaconBlock()))
require.NoError(t, err)
st, err := testutil.NewBeaconState()
st, err := util.NewBeaconState()
require.NoError(t, err)
mc := &mock.ChainService{
@@ -611,7 +611,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T)
handlerGenFn: func(req *p2ppb.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) {
blk := testutil.NewBeaconBlock()
blk := util.NewBeaconBlock()
blk.Block.Slot = i
mchain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
assert.NoError(t, beaconsync.WriteBlockChunk(stream, mchain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk)))
@@ -633,7 +633,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T)
handlerGenFn: func(req *p2ppb.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) {
blk := testutil.NewBeaconBlock()
blk := util.NewBeaconBlock()
blk.Block.Slot = i
chain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk)))
@@ -655,12 +655,12 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T)
},
handlerGenFn: func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) {
return func(stream network.Stream) {
blk := testutil.NewBeaconBlock()
blk := util.NewBeaconBlock()
blk.Block.Slot = 163
chain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk)))
blk = testutil.NewBeaconBlock()
blk = util.NewBeaconBlock()
blk.Block.Slot = 162
assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk)))
assert.NoError(t, stream.Close())
@@ -680,13 +680,13 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T)
},
handlerGenFn: func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) {
return func(stream network.Stream) {
blk := testutil.NewBeaconBlock()
blk := util.NewBeaconBlock()
blk.Block.Slot = 160
chain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk)))
blk = testutil.NewBeaconBlock()
blk = util.NewBeaconBlock()
blk.Block.Slot = 160
assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk)))
assert.NoError(t, stream.Close())
@@ -710,7 +710,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T)
assert.NoError(t, stream.Close())
}()
for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += types.Slot(req.Step) {
blk := testutil.NewBeaconBlock()
blk := util.NewBeaconBlock()
chain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
// Patch mid block, with invalid slot number.
if i == req.StartSlot.Add(req.Count*req.Step/2) {
@@ -742,7 +742,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T)
assert.NoError(t, stream.Close())
}()
for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += types.Slot(req.Step) {
blk := testutil.NewBeaconBlock()
blk := util.NewBeaconBlock()
chain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
// Patch mid block, with invalid slot number.
if i == req.StartSlot.Add(req.Count*req.Step/2) {
@@ -770,12 +770,12 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T)
},
handlerGenFn: func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) {
return func(stream network.Stream) {
blk := testutil.NewBeaconBlock()
blk := util.NewBeaconBlock()
blk.Block.Slot = 100
chain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk)))
blk = testutil.NewBeaconBlock()
blk = util.NewBeaconBlock()
blk.Block.Slot = 105
assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk)))
assert.NoError(t, stream.Close())
@@ -794,12 +794,12 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T)
},
handlerGenFn: func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) {
return func(stream network.Stream) {
blk := testutil.NewBeaconBlock()
blk := util.NewBeaconBlock()
blk.Block.Slot = 100
chain := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk)))
blk = testutil.NewBeaconBlock()
blk = util.NewBeaconBlock()
blk.Block.Slot = 103
assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk)))
assert.NoError(t, stream.Close())