2022-01-13 11:23:53 +00:00
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
types "github.com/prysmaticlabs/eth2-types"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBeaconState_RotateAttestations(t *testing.T) {
|
|
|
|
st, err := InitializeFromProto(ðpb.BeaconState{
|
|
|
|
Slot: 1,
|
|
|
|
CurrentEpochAttestations: []*ethpb.PendingAttestation{{Data: ðpb.AttestationData{Slot: 456}}},
|
|
|
|
PreviousEpochAttestations: []*ethpb.PendingAttestation{{Data: ðpb.AttestationData{Slot: 123}}},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
require.NoError(t, st.RotateAttestations())
|
2022-02-14 09:51:22 +00:00
|
|
|
currEpochAtts, err := st.CurrentEpochAttestations()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 0, len(currEpochAtts))
|
|
|
|
prevEpochAtts, err := st.PreviousEpochAttestations()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, types.Slot(456), prevEpochAtts[0].Data.Slot)
|
2022-01-13 11:23:53 +00:00
|
|
|
}
|