2021-08-24 16:07:11 +00:00
|
|
|
package altair_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/altair"
|
2021-09-21 19:59:25 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/config/params"
|
2021-09-23 18:53:46 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
|
|
|
"github.com/prysmaticlabs/prysm/testing/util"
|
2021-08-24 16:07:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestProcessEpoch_CanProcess(t *testing.T) {
|
2021-09-23 18:53:46 +00:00
|
|
|
st, _ := util.DeterministicGenesisStateAltair(t, params.BeaconConfig().MaxValidatorsPerCommittee)
|
2021-08-24 16:07:11 +00:00
|
|
|
require.NoError(t, st.SetSlot(10*params.BeaconConfig().SlotsPerEpoch))
|
|
|
|
newState, err := altair.ProcessEpoch(context.Background(), st)
|
2021-12-08 19:02:53 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, uint64(0), newState.Slashings()[2], "Unexpected slashed balance")
|
|
|
|
|
|
|
|
b := st.Balances()
|
|
|
|
require.Equal(t, params.BeaconConfig().MaxValidatorsPerCommittee, uint64(len(b)))
|
|
|
|
require.Equal(t, uint64(31999841265), b[0])
|
|
|
|
|
|
|
|
s, err := st.InactivityScores()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, params.BeaconConfig().MaxValidatorsPerCommittee, uint64(len(s)))
|
|
|
|
|
|
|
|
p, err := st.PreviousEpochParticipation()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, params.BeaconConfig().MaxValidatorsPerCommittee, uint64(len(p)))
|
|
|
|
|
|
|
|
p, err = st.CurrentEpochParticipation()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, params.BeaconConfig().MaxValidatorsPerCommittee, uint64(len(p)))
|
|
|
|
|
|
|
|
sc, err := st.CurrentSyncCommittee()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, params.BeaconConfig().SyncCommitteeSize, uint64(len(sc.Pubkeys)))
|
|
|
|
|
|
|
|
sc, err = st.NextSyncCommittee()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, params.BeaconConfig().SyncCommitteeSize, uint64(len(sc.Pubkeys)))
|
|
|
|
}
|
|
|
|
|
2022-01-10 16:47:30 +00:00
|
|
|
func TestProcessEpoch_CanProcessBellatrix(t *testing.T) {
|
2022-01-26 07:24:47 +00:00
|
|
|
st, _ := util.DeterministicGenesisStateBellatrix(t, params.BeaconConfig().MaxValidatorsPerCommittee)
|
2021-12-08 19:02:53 +00:00
|
|
|
require.NoError(t, st.SetSlot(10*params.BeaconConfig().SlotsPerEpoch))
|
|
|
|
newState, err := altair.ProcessEpoch(context.Background(), st)
|
2021-08-24 16:07:11 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, uint64(0), newState.Slashings()[2], "Unexpected slashed balance")
|
|
|
|
|
|
|
|
b := st.Balances()
|
|
|
|
require.Equal(t, params.BeaconConfig().MaxValidatorsPerCommittee, uint64(len(b)))
|
2021-12-13 18:04:37 +00:00
|
|
|
require.Equal(t, uint64(31999839993), b[0])
|
2021-08-24 16:07:11 +00:00
|
|
|
|
|
|
|
s, err := st.InactivityScores()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, params.BeaconConfig().MaxValidatorsPerCommittee, uint64(len(s)))
|
|
|
|
|
|
|
|
p, err := st.PreviousEpochParticipation()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, params.BeaconConfig().MaxValidatorsPerCommittee, uint64(len(p)))
|
|
|
|
|
|
|
|
p, err = st.CurrentEpochParticipation()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, params.BeaconConfig().MaxValidatorsPerCommittee, uint64(len(p)))
|
|
|
|
|
|
|
|
sc, err := st.CurrentSyncCommittee()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, params.BeaconConfig().SyncCommitteeSize, uint64(len(sc.Pubkeys)))
|
|
|
|
|
|
|
|
sc, err = st.NextSyncCommittee()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, params.BeaconConfig().SyncCommitteeSize, uint64(len(sc.Pubkeys)))
|
|
|
|
}
|