prysm-pulse/beacon-chain/state/state-native/setters_withdrawal_test.go

55 lines
1.9 KiB
Go
Raw Normal View History

package state_native
import (
"testing"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native/types"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/runtime/version"
"github.com/prysmaticlabs/prysm/v4/testing/require"
)
2022-11-03 16:55:44 +00:00
func TestSetNextWithdrawalIndex(t *testing.T) {
s := BeaconState{
version: version.Capella,
nextWithdrawalIndex: 3,
dirtyFields: make(map[types.FieldIndex]bool),
2022-11-03 16:55:44 +00:00
}
require.NoError(t, s.SetNextWithdrawalIndex(5))
require.Equal(t, uint64(5), s.nextWithdrawalIndex)
require.Equal(t, true, s.dirtyFields[types.NextWithdrawalIndex])
}
2023-02-02 17:24:09 +00:00
func TestSetNextWithdrawalValidatorIndex(t *testing.T) {
2022-11-03 16:55:44 +00:00
s := BeaconState{
version: version.Capella,
nextWithdrawalValidatorIndex: 3,
dirtyFields: make(map[types.FieldIndex]bool),
2022-11-03 16:55:44 +00:00
}
require.NoError(t, s.SetNextWithdrawalValidatorIndex(5))
require.Equal(t, primitives.ValidatorIndex(5), s.nextWithdrawalValidatorIndex)
require.Equal(t, true, s.dirtyFields[types.NextWithdrawalValidatorIndex])
}
2023-05-09 21:38:13 +00:00
func TestSetNextWithdrawalIndex_Deneb(t *testing.T) {
s := BeaconState{
version: version.Deneb,
nextWithdrawalIndex: 3,
dirtyFields: make(map[types.FieldIndex]bool),
}
require.NoError(t, s.SetNextWithdrawalIndex(5))
require.Equal(t, uint64(5), s.nextWithdrawalIndex)
require.Equal(t, true, s.dirtyFields[types.NextWithdrawalIndex])
}
func TestSetNextWithdrawalValidatorIndex_Deneb(t *testing.T) {
s := BeaconState{
version: version.Deneb,
nextWithdrawalValidatorIndex: 3,
dirtyFields: make(map[types.FieldIndex]bool),
}
require.NoError(t, s.SetNextWithdrawalValidatorIndex(5))
require.Equal(t, primitives.ValidatorIndex(5), s.nextWithdrawalValidatorIndex)
require.Equal(t, true, s.dirtyFields[types.NextWithdrawalValidatorIndex])
}