2022-10-12 16:39:19 +00:00
|
|
|
package state_native
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-01-26 14:40:12 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native/types"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
2022-10-12 16:39:19 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
|
|
|
)
|
|
|
|
|
2022-11-03 16:55:44 +00:00
|
|
|
func TestSetNextWithdrawalIndex(t *testing.T) {
|
|
|
|
s := BeaconState{
|
|
|
|
version: version.Capella,
|
|
|
|
nextWithdrawalIndex: 3,
|
2023-01-26 14:40:12 +00:00
|
|
|
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)
|
2023-01-26 14:40:12 +00:00
|
|
|
require.Equal(t, true, s.dirtyFields[types.NextWithdrawalIndex])
|
2022-10-12 16:39:19 +00:00
|
|
|
}
|
2022-11-24 17:54:55 +00:00
|
|
|
|
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,
|
2022-11-12 18:38:21 +00:00
|
|
|
nextWithdrawalValidatorIndex: 3,
|
2023-01-26 14:40:12 +00:00
|
|
|
dirtyFields: make(map[types.FieldIndex]bool),
|
2022-11-03 16:55:44 +00:00
|
|
|
}
|
2022-11-12 18:38:21 +00:00
|
|
|
require.NoError(t, s.SetNextWithdrawalValidatorIndex(5))
|
2023-01-26 14:40:12 +00:00
|
|
|
require.Equal(t, primitives.ValidatorIndex(5), s.nextWithdrawalValidatorIndex)
|
|
|
|
require.Equal(t, true, s.dirtyFields[types.NextWithdrawalValidatorIndex])
|
2022-10-12 16:39:19 +00:00
|
|
|
}
|