mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
* Add the new Fulu state with the new field * fix the hasher for the fulu state * Fix ToProto() and ToProtoUnsafe() * Add the fields as shared * Add epoch transition code * short circuit the proposer cache to use the state * Marshal the state JSON * update spectests to 1.6.0-alpha.1 * Remove deneb and electra entries from blob schedule This was cherry picked from PR #15364 and edited to remove the minimal cases * Fix minimal tests * Increase deadling for processing blocks in spectests * Preston's review * review --------- Co-authored-by: terence tsao <terence@prysmaticlabs.com>
62 lines
2.3 KiB
Go
62 lines
2.3 KiB
Go
package sanity
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
"testing"
|
|
|
|
"github.com/OffchainLabs/prysm/v6/beacon-chain/core/transition"
|
|
state_native "github.com/OffchainLabs/prysm/v6/beacon-chain/state/state-native"
|
|
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
|
|
"github.com/OffchainLabs/prysm/v6/testing/require"
|
|
"github.com/OffchainLabs/prysm/v6/testing/spectest/utils"
|
|
"github.com/OffchainLabs/prysm/v6/testing/util"
|
|
"github.com/golang/snappy"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func init() {
|
|
transition.SkipSlotCache.Disable()
|
|
}
|
|
|
|
// RunSlotProcessingTests executes "sanity/slots" tests.
|
|
func RunSlotProcessingTests(t *testing.T, config string) {
|
|
require.NoError(t, utils.SetConfig(t, config))
|
|
|
|
testFolders, testsFolderPath := utils.TestFolders(t, config, "fulu", "sanity/slots/pyspec_tests")
|
|
|
|
for _, folder := range testFolders {
|
|
t.Run(folder.Name(), func(t *testing.T) {
|
|
preBeaconStateFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "pre.ssz_snappy")
|
|
require.NoError(t, err)
|
|
preBeaconStateSSZ, err := snappy.Decode(nil /* dst */, preBeaconStateFile)
|
|
require.NoError(t, err, "Failed to decompress")
|
|
base := ðpb.BeaconStateFulu{}
|
|
require.NoError(t, base.UnmarshalSSZ(preBeaconStateSSZ), "Failed to unmarshal")
|
|
beaconState, err := state_native.InitializeFromProtoFulu(base)
|
|
require.NoError(t, err)
|
|
|
|
file, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "slots.yaml")
|
|
require.NoError(t, err)
|
|
fileStr := string(file)
|
|
slotsCount, err := strconv.ParseUint(fileStr[:len(fileStr)-5], 10, 64)
|
|
require.NoError(t, err)
|
|
|
|
postBeaconStateFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "post.ssz_snappy")
|
|
require.NoError(t, err)
|
|
postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile)
|
|
require.NoError(t, err, "Failed to decompress")
|
|
postBeaconState := ðpb.BeaconStateFulu{}
|
|
require.NoError(t, postBeaconState.UnmarshalSSZ(postBeaconStateSSZ), "Failed to unmarshal")
|
|
postState, err := transition.ProcessSlots(context.Background(), beaconState, beaconState.Slot().Add(slotsCount))
|
|
require.NoError(t, err)
|
|
|
|
pbState, err := state_native.ProtobufBeaconStateFulu(postState.ToProto())
|
|
require.NoError(t, err)
|
|
if !proto.Equal(pbState, postBeaconState) {
|
|
t.Fatal("Did not receive expected post state")
|
|
}
|
|
})
|
|
}
|
|
}
|