mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
* Ran gopls modernize to fix everything go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./... * Override rules_go provided dependency for golang.org/x/tools to v0.38.0. To update this, checked out rules_go, then ran `bazel run //go/tools/releaser -- upgrade-dep -mirror=false org_golang_x_tools` and copied the patches. * Fix buildtag violations and ignore buildtag violations in external * Introduce modernize analyzer package. * Add modernize "any" analyzer. * Fix violations of any analyzer * Add modernize "appendclipped" analyzer. * Fix violations of appendclipped * Add modernize "bloop" analyzer. * Add modernize "fmtappendf" analyzer. * Add modernize "forvar" analyzer. * Add modernize "mapsloop" analyzer. * Add modernize "minmax" analyzer. * Fix violations of minmax analyzer * Add modernize "omitzero" analyzer. * Add modernize "rangeint" analyzer. * Fix violations of rangeint. * Add modernize "reflecttypefor" analyzer. * Fix violations of reflecttypefor analyzer. * Add modernize "slicescontains" analyzer. * Add modernize "slicessort" analyzer. * Add modernize "slicesdelete" analyzer. This is disabled by default for now. See https://go.dev/issue/73686. * Add modernize "stringscutprefix" analyzer. * Add modernize "stringsbuilder" analyzer. * Fix violations of stringsbuilder analyzer. * Add modernize "stringsseq" analyzer. * Add modernize "testingcontext" analyzer. * Add modernize "waitgroup" analyzer. * Changelog fragment * gofmt * gazelle * Add modernize "newexpr" analyzer. * Disable newexpr until go1.26 * Add more details in WORKSPACE on how to update the override * @nalepae feedback on min() * gofmt * Fix violations of forvar
52 lines
1.9 KiB
Go
52 lines
1.9 KiB
Go
package testutil
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/OffchainLabs/prysm/v7/beacon-chain/db"
|
|
"github.com/OffchainLabs/prysm/v7/consensus-types/blocks"
|
|
"github.com/OffchainLabs/prysm/v7/consensus-types/interfaces"
|
|
"github.com/OffchainLabs/prysm/v7/consensus-types/primitives"
|
|
"github.com/OffchainLabs/prysm/v7/encoding/bytesutil"
|
|
ethpbalpha "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1"
|
|
"github.com/OffchainLabs/prysm/v7/testing/require"
|
|
"github.com/OffchainLabs/prysm/v7/testing/util"
|
|
)
|
|
|
|
func FillDBWithBlocks(ctx context.Context, t *testing.T, beaconDB db.Database) (*ethpbalpha.SignedBeaconBlock, []*ethpbalpha.BeaconBlockContainer) {
|
|
parentRoot := [32]byte{1, 2, 3}
|
|
genBlk := util.NewBeaconBlock()
|
|
genBlk.Block.ParentRoot = parentRoot[:]
|
|
root, err := genBlk.Block.HashTreeRoot()
|
|
require.NoError(t, err)
|
|
util.SaveBlock(t, ctx, beaconDB, genBlk)
|
|
require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, root))
|
|
|
|
count := primitives.Slot(100)
|
|
blks := make([]interfaces.ReadOnlySignedBeaconBlock, count)
|
|
blkContainers := make([]*ethpbalpha.BeaconBlockContainer, count)
|
|
for i := range count {
|
|
b := util.NewBeaconBlock()
|
|
b.Block.Slot = i
|
|
b.Block.ParentRoot = bytesutil.PadTo([]byte{uint8(i)}, 32)
|
|
root, err := b.Block.HashTreeRoot()
|
|
require.NoError(t, err)
|
|
blks[i], err = blocks.NewSignedBeaconBlock(b)
|
|
require.NoError(t, err)
|
|
blkContainers[i] = ðpbalpha.BeaconBlockContainer{
|
|
Block: ðpbalpha.BeaconBlockContainer_Phase0Block{Phase0Block: b},
|
|
BlockRoot: root[:],
|
|
}
|
|
}
|
|
require.NoError(t, beaconDB.SaveBlocks(ctx, blks))
|
|
headRoot := bytesutil.ToBytes32(blkContainers[len(blks)-1].BlockRoot)
|
|
summary := ðpbalpha.StateSummary{
|
|
Root: headRoot[:],
|
|
Slot: blkContainers[len(blks)-1].Block.(*ethpbalpha.BeaconBlockContainer_Phase0Block).Phase0Block.Block.Slot,
|
|
}
|
|
require.NoError(t, beaconDB.SaveStateSummary(ctx, summary))
|
|
require.NoError(t, beaconDB.SaveHeadBlockRoot(ctx, headRoot))
|
|
return genBlk, blkContainers
|
|
}
|