mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 21:08:10 -05:00
make tests pass
This commit is contained in:
@@ -47,9 +47,14 @@ func prepareForkchoiceState(
|
||||
BlockHash: payloadHash[:],
|
||||
}
|
||||
|
||||
mixes := make([][]byte, fieldparams.RandaoMixesLength)
|
||||
for i := range mixes {
|
||||
mixes[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
|
||||
base := ðpb.BeaconStateBellatrix{
|
||||
Slot: slot,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
RandaoMixes: mixes,
|
||||
BlockRoots: make([][]byte, 1),
|
||||
CurrentJustifiedCheckpoint: justified,
|
||||
FinalizedCheckpoint: finalized,
|
||||
|
||||
2
beacon-chain/cache/active_balance_test.go
vendored
2
beacon-chain/cache/active_balance_test.go
vendored
@@ -17,7 +17,7 @@ import (
|
||||
func TestBalanceCache_AddGetBalance(t *testing.T) {
|
||||
blockRoots := make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot)
|
||||
for i := 0; i < len(blockRoots); i++ {
|
||||
b := make([]byte, 8)
|
||||
b := make([]byte, 32)
|
||||
binary.LittleEndian.PutUint64(b, uint64(i))
|
||||
blockRoots[i] = b
|
||||
}
|
||||
|
||||
@@ -191,11 +191,15 @@ func TestConvertToIndexed_OK(t *testing.T) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
}
|
||||
}
|
||||
mixes := make([][]byte, fieldparams.RandaoMixesLength)
|
||||
for i := range mixes {
|
||||
mixes[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
|
||||
state, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{
|
||||
Slot: 5,
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
RandaoMixes: mixes,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
tests := []struct {
|
||||
@@ -249,6 +253,10 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) {
|
||||
WithdrawalCredentials: make([]byte, 32),
|
||||
}
|
||||
}
|
||||
mixes := make([][]byte, fieldparams.RandaoMixesLength)
|
||||
for i := range mixes {
|
||||
mixes[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
|
||||
state, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{
|
||||
Slot: 5,
|
||||
@@ -258,7 +266,7 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) {
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
},
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
RandaoMixes: mixes,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
tests := []struct {
|
||||
|
||||
@@ -54,6 +54,7 @@ go_test(
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//math:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v1alpha1/attestation:go_default_library",
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v4/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
||||
@@ -19,9 +20,9 @@ import (
|
||||
func TestProcessJustificationAndFinalizationPreCompute_ConsecutiveEpochs(t *testing.T) {
|
||||
e := params.BeaconConfig().FarFutureEpoch
|
||||
a := params.BeaconConfig().MaxEffectiveBalance
|
||||
blockRoots := make([][]byte, params.BeaconConfig().SlotsPerEpoch*2+1)
|
||||
blockRoots := make([][]byte, fieldparams.BlockRootsLength)
|
||||
for i := 0; i < len(blockRoots); i++ {
|
||||
blockRoots[i] = []byte{byte(i)}
|
||||
blockRoots[i] = bytesutil.PadTo([]byte{byte(i)}, 32)
|
||||
}
|
||||
base := ðpb.BeaconState{
|
||||
Slot: params.BeaconConfig().SlotsPerEpoch*2 + 1,
|
||||
|
||||
@@ -8,8 +8,10 @@ import (
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers"
|
||||
state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v4/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
||||
@@ -58,13 +60,25 @@ func TestAttestation_ComputeSubnetForAttestation(t *testing.T) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
}
|
||||
}
|
||||
bRoots := make([][]byte, fieldparams.BlockRootsLength)
|
||||
for i := range bRoots {
|
||||
bRoots[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
sRoots := make([][]byte, fieldparams.StateRootsLength)
|
||||
for i := range sRoots {
|
||||
sRoots[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
mixes := make([][]byte, fieldparams.RandaoMixesLength)
|
||||
for i := range mixes {
|
||||
mixes[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
|
||||
state, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{
|
||||
Validators: validators,
|
||||
Slot: 200,
|
||||
BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot),
|
||||
StateRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot),
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
BlockRoots: bRoots,
|
||||
StateRoots: sRoots,
|
||||
RandaoMixes: mixes,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
att := ðpb.Attestation{
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/time"
|
||||
state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v4/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v4/container/slice"
|
||||
@@ -35,13 +36,25 @@ func TestComputeCommittee_WithoutCache(t *testing.T) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
}
|
||||
}
|
||||
bRoots := make([][]byte, fieldparams.BlockRootsLength)
|
||||
for i := range bRoots {
|
||||
bRoots[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
sRoots := make([][]byte, fieldparams.StateRootsLength)
|
||||
for i := range sRoots {
|
||||
sRoots[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
mixes := make([][]byte, fieldparams.RandaoMixesLength)
|
||||
for i := range mixes {
|
||||
mixes[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
|
||||
state, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{
|
||||
Validators: validators,
|
||||
Slot: 200,
|
||||
BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot),
|
||||
StateRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot),
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
BlockRoots: bRoots,
|
||||
StateRoots: sRoots,
|
||||
RandaoMixes: mixes,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) {
|
||||
}
|
||||
var blockRoots [][]byte
|
||||
for i := uint64(0); i < uint64(params.BeaconConfig().SlotsPerHistoricalRoot); i++ {
|
||||
blockRoots = append(blockRoots, []byte{byte(i)})
|
||||
blockRoots = append(blockRoots, bytesutil.PadTo([]byte{byte(i)}, 32))
|
||||
}
|
||||
require.NoError(t, beaconState.SetBlockRoots(blockRoots))
|
||||
blockAtt := util.HydrateAttestation(ðpb.Attestation{
|
||||
@@ -295,7 +295,7 @@ func createFullBlockWithOperations(t *testing.T) (state.BeaconState,
|
||||
|
||||
var blockRoots [][]byte
|
||||
for i := uint64(0); i < uint64(params.BeaconConfig().SlotsPerHistoricalRoot); i++ {
|
||||
blockRoots = append(blockRoots, []byte{byte(i)})
|
||||
blockRoots = append(blockRoots, bytesutil.PadTo([]byte{byte(i)}, 32))
|
||||
}
|
||||
require.NoError(t, beaconState.SetBlockRoots(blockRoots))
|
||||
|
||||
|
||||
@@ -31,8 +31,10 @@ go_test(
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/time:go_default_library",
|
||||
"//beacon-chain/state/state-native:go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//runtime/version:go_default_library",
|
||||
"//testing/assert:go_default_library",
|
||||
|
||||
@@ -7,8 +7,10 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/time"
|
||||
state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v4/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v4/runtime/version"
|
||||
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
||||
@@ -122,11 +124,15 @@ func TestSlashValidator_OK(t *testing.T) {
|
||||
})
|
||||
balances = append(balances, params.BeaconConfig().MaxEffectiveBalance)
|
||||
}
|
||||
mixes := make([][]byte, fieldparams.RandaoMixesLength)
|
||||
for i := range mixes {
|
||||
mixes[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
|
||||
base := ðpb.BeaconState{
|
||||
Validators: registry,
|
||||
Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector),
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
RandaoMixes: mixes,
|
||||
Balances: balances,
|
||||
}
|
||||
state, err := state_native.InitializeFromProtoPhase0(base)
|
||||
|
||||
@@ -65,6 +65,7 @@ go_test(
|
||||
"//beacon-chain/forkchoice/types:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/state-native:go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
|
||||
@@ -10,10 +10,12 @@ import (
|
||||
forkchoicetypes "github.com/prysmaticlabs/prysm/v4/beacon-chain/forkchoice/types"
|
||||
"github.com/prysmaticlabs/prysm/v4/beacon-chain/state"
|
||||
state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v4/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v4/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v4/crypto/hash"
|
||||
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
|
||||
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
||||
@@ -48,9 +50,14 @@ func prepareForkchoiceState(
|
||||
Epoch: finalizedEpoch,
|
||||
}
|
||||
|
||||
mixes := make([][]byte, fieldparams.RandaoMixesLength)
|
||||
for i := range mixes {
|
||||
mixes[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
|
||||
base := ðpb.BeaconStateBellatrix{
|
||||
Slot: slot,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
RandaoMixes: mixes,
|
||||
CurrentJustifiedCheckpoint: justifiedCheckpoint,
|
||||
FinalizedCheckpoint: finalizedCheckpoint,
|
||||
LatestExecutionPayloadHeader: executionHeader,
|
||||
|
||||
@@ -400,17 +400,17 @@ func TestGetRandao(t *testing.T) {
|
||||
t.Run("no epoch requested", func(t *testing.T) {
|
||||
resp, err := server.GetRandao(ctx, ð2.RandaoRequest{StateId: []byte("head")})
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, mixCurrent, resp.Data.Randao)
|
||||
assert.DeepEqual(t, mixCurrent[:], resp.Data.Randao)
|
||||
})
|
||||
t.Run("current epoch requested", func(t *testing.T) {
|
||||
resp, err := server.GetRandao(ctx, ð2.RandaoRequest{StateId: []byte("head"), Epoch: &epochCurrent})
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, mixCurrent, resp.Data.Randao)
|
||||
assert.DeepEqual(t, mixCurrent[:], resp.Data.Randao)
|
||||
})
|
||||
t.Run("old epoch requested", func(t *testing.T) {
|
||||
resp, err := server.GetRandao(ctx, ð2.RandaoRequest{StateId: []byte("head"), Epoch: &epochOld})
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, mixOld, resp.Data.Randao)
|
||||
assert.DeepEqual(t, mixOld[:], resp.Data.Randao)
|
||||
})
|
||||
t.Run("head state below `EpochsPerHistoricalVector`", func(t *testing.T) {
|
||||
server.Stater = &testutil.MockStater{
|
||||
@@ -418,7 +418,7 @@ func TestGetRandao(t *testing.T) {
|
||||
}
|
||||
resp, err := server.GetRandao(ctx, ð2.RandaoRequest{StateId: []byte("head")})
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, headRandao, resp.Data.Randao)
|
||||
assert.DeepEqual(t, headRandao[:], resp.Data.Randao)
|
||||
})
|
||||
t.Run("epoch too old", func(t *testing.T) {
|
||||
epochTooOld := primitives.Epoch(100000 - st.RandaoMixesLength())
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native"
|
||||
syncmock "github.com/prysmaticlabs/prysm/v4/beacon-chain/sync/initial-sync/testing"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v4/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v4/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
|
||||
@@ -313,11 +312,19 @@ func prepareForkchoiceState(
|
||||
executionHeader := &enginev1.ExecutionPayloadHeader{
|
||||
BlockHash: payloadHash[:],
|
||||
}
|
||||
bRoots := make([][]byte, fieldparams.BlockRootsLength)
|
||||
for i := range bRoots {
|
||||
bRoots[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
mixes := make([][]byte, fieldparams.RandaoMixesLength)
|
||||
for i := range mixes {
|
||||
mixes[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
|
||||
base := ð.BeaconStateBellatrix{
|
||||
Slot: slot,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
BlockRoots: make([][]byte, 1),
|
||||
RandaoMixes: mixes,
|
||||
BlockRoots: bRoots,
|
||||
CurrentJustifiedCheckpoint: justified,
|
||||
FinalizedCheckpoint: finalized,
|
||||
LatestExecutionPayloadHeader: executionHeader,
|
||||
|
||||
@@ -58,6 +58,9 @@ func TestBlockRewards(t *testing.T) {
|
||||
require.NoError(t, st.SetCurrentSyncCommittee(syncCommittee))
|
||||
slot0bRoot := bytesutil.PadTo([]byte("slot0root"), 32)
|
||||
bRoots := make([][]byte, fieldparams.BlockRootsLength)
|
||||
for i := range bRoots {
|
||||
bRoots[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
bRoots[0] = slot0bRoot
|
||||
require.NoError(t, st.SetBlockRoots(bRoots))
|
||||
|
||||
|
||||
@@ -54,6 +54,9 @@ func TestGetAttesterDuties(t *testing.T) {
|
||||
genesisRoot, err := genesis.Block.HashTreeRoot()
|
||||
require.NoError(t, err, "Could not get signing root")
|
||||
roots := make([][]byte, fieldparams.BlockRootsLength)
|
||||
for i := range roots {
|
||||
roots[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
roots[0] = genesisRoot[:]
|
||||
require.NoError(t, bs.SetBlockRoots(roots))
|
||||
db := dbutil.SetupDB(t)
|
||||
|
||||
@@ -47,8 +47,12 @@ func TestSubmitAggregateAndProof_Syncing(t *testing.T) {
|
||||
func TestSubmitAggregateAndProof_CantFindValidatorIndex(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
mixes := make([][]byte, fieldparams.RandaoMixesLength)
|
||||
for i := range mixes {
|
||||
mixes[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
s, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
RandaoMixes: mixes,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
@@ -8,14 +8,6 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
||||
)
|
||||
|
||||
func TestBlockRoots_Casting(t *testing.T) {
|
||||
var b [][32]byte
|
||||
d := BlockRoots(b)
|
||||
if !reflect.DeepEqual([fieldparams.BlockRootsLength][32]byte(d), b) {
|
||||
t.Errorf("Unequal: %v = %v", d, b)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBlockRoots_UnmarshalSSZ(t *testing.T) {
|
||||
t.Run("Ok", func(t *testing.T) {
|
||||
d := BlockRoots{}
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestFieldTrie_RecomputeTrie(t *testing.T) {
|
||||
st, ok := newState.(*state_native.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
// 10 represents the enum value of validators
|
||||
trie, err := state_native.NewFieldTrie(st, types.FieldIndex(11), types.FieldInfo{ArrayType: types.CompositeArray, ValueType: types.SingleValue}, newState.Validators(), params.BeaconConfig().ValidatorRegistryLimit)
|
||||
trie, err := state_native.NewFieldTrie(st, types.FieldIndex(11), types.FieldInfo{ArrayType: types.CompositeArray, ValueType: types.MultiValue}, state_native.NewMultiValueValidators(newState.Validators()), params.BeaconConfig().ValidatorRegistryLimit)
|
||||
require.NoError(t, err)
|
||||
|
||||
oldroot, err := trie.TrieRoot()
|
||||
@@ -64,7 +64,7 @@ func TestFieldTrie_RecomputeTrie(t *testing.T) {
|
||||
|
||||
expectedRoot, err := stateutil.ValidatorRegistryRoot(newState.Validators())
|
||||
require.NoError(t, err)
|
||||
root, err := trie.RecomputeTrie(st, changedIdx, newState.Validators())
|
||||
root, err := trie.RecomputeTrie(st, changedIdx, state_native.NewMultiValueValidators(newState.Validators()))
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expectedRoot, root)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@ package state_native
|
||||
import (
|
||||
"testing"
|
||||
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v4/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
||||
)
|
||||
@@ -18,9 +20,13 @@ func TestState_UnrealizedCheckpointBalances(t *testing.T) {
|
||||
}
|
||||
balances[i] = params.BeaconConfig().MaxEffectiveBalance
|
||||
}
|
||||
mixes := make([][]byte, fieldparams.RandaoMixesLength)
|
||||
for i := range mixes {
|
||||
mixes[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
base := ðpb.BeaconStateAltair{
|
||||
Slot: 2,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
RandaoMixes: mixes,
|
||||
|
||||
Validators: validators,
|
||||
CurrentEpochParticipation: make([]byte, params.BeaconConfig().MinGenesisActiveValidatorCount),
|
||||
|
||||
@@ -21,9 +21,11 @@ import (
|
||||
state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native"
|
||||
mockSync "github.com/prysmaticlabs/prysm/v4/beacon-chain/sync/initial-sync/testing"
|
||||
lruwrpr "github.com/prysmaticlabs/prysm/v4/cache/lru"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v4/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v4/crypto/bls"
|
||||
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
||||
@@ -44,6 +46,18 @@ func setupValidProposerSlashing(t *testing.T) (*ethpb.ProposerSlashing, state.Be
|
||||
for i := 0; i < len(validatorBalances); i++ {
|
||||
validatorBalances[i] = params.BeaconConfig().MaxEffectiveBalance
|
||||
}
|
||||
bRoots := make([][]byte, fieldparams.BlockRootsLength)
|
||||
for i := range bRoots {
|
||||
bRoots[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
sRoots := make([][]byte, fieldparams.StateRootsLength)
|
||||
for i := range sRoots {
|
||||
sRoots[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
mixes := make([][]byte, fieldparams.RandaoMixesLength)
|
||||
for i := range mixes {
|
||||
mixes[i] = bytesutil.PadTo([]byte{}, 32)
|
||||
}
|
||||
|
||||
currentSlot := primitives.Slot(0)
|
||||
st, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{
|
||||
@@ -56,10 +70,10 @@ func setupValidProposerSlashing(t *testing.T) (*ethpb.ProposerSlashing, state.Be
|
||||
Epoch: 0,
|
||||
},
|
||||
Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector),
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
RandaoMixes: mixes,
|
||||
|
||||
StateRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot),
|
||||
BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot),
|
||||
StateRoots: sRoots,
|
||||
BlockRoots: bRoots,
|
||||
LatestBlockHeader: ðpb.BeaconBlockHeader{},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user