2021-03-01 13:52:07 +00:00
|
|
|
package migration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2024-02-15 05:46:47 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
|
|
|
ethpbv1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
2021-03-01 13:52:07 +00:00
|
|
|
)
|
|
|
|
|
2021-08-05 07:23:52 +00:00
|
|
|
func Test_V1ValidatorToV1Alpha1(t *testing.T) {
|
2021-08-26 15:22:06 +00:00
|
|
|
v1Validator := ðpbv1.Validator{
|
2021-08-05 07:23:52 +00:00
|
|
|
Pubkey: []byte("pubkey"),
|
|
|
|
WithdrawalCredentials: []byte("withdraw"),
|
|
|
|
EffectiveBalance: 99,
|
|
|
|
Slashed: true,
|
|
|
|
ActivationEligibilityEpoch: 1,
|
|
|
|
ActivationEpoch: 11,
|
|
|
|
ExitEpoch: 111,
|
|
|
|
WithdrawableEpoch: 1111,
|
|
|
|
}
|
|
|
|
|
|
|
|
v1Alpha1Validator := V1ValidatorToV1Alpha1(v1Validator)
|
|
|
|
require.NotNil(t, v1Alpha1Validator)
|
|
|
|
assert.DeepEqual(t, []byte("pubkey"), v1Alpha1Validator.PublicKey)
|
|
|
|
assert.DeepEqual(t, []byte("withdraw"), v1Alpha1Validator.WithdrawalCredentials)
|
|
|
|
assert.Equal(t, uint64(99), v1Alpha1Validator.EffectiveBalance)
|
|
|
|
assert.Equal(t, true, v1Alpha1Validator.Slashed)
|
2023-01-26 14:40:12 +00:00
|
|
|
assert.Equal(t, primitives.Epoch(1), v1Alpha1Validator.ActivationEligibilityEpoch)
|
|
|
|
assert.Equal(t, primitives.Epoch(11), v1Alpha1Validator.ActivationEpoch)
|
|
|
|
assert.Equal(t, primitives.Epoch(111), v1Alpha1Validator.ExitEpoch)
|
|
|
|
assert.Equal(t, primitives.Epoch(1111), v1Alpha1Validator.WithdrawableEpoch)
|
2021-08-05 07:23:52 +00:00
|
|
|
}
|