mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 11:11:20 +00:00
d077483577
* v3 import renamings * tidy * fmt * rev * Update beacon-chain/core/epoch/precompute/reward_penalty_test.go * Update beacon-chain/core/helpers/validators_test.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/iface/BUILD.bazel * Update beacon-chain/db/kv/kv.go * Update beacon-chain/db/kv/state.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/sync/initial-sync/service.go * fix deps * fix bad replacements * fix bad replacements * change back * gohashtree version * fix deps Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com>
74 lines
2.5 KiB
Go
74 lines
2.5 KiB
Go
package state_native_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
statenative "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native"
|
|
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
|
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
|
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
|
)
|
|
|
|
func TestReadOnlyValidator_ReturnsErrorOnNil(t *testing.T) {
|
|
if _, err := statenative.NewValidator(nil); err != statenative.ErrNilWrappedValidator {
|
|
t.Errorf("Wrong error returned. Got %v, wanted %v", err, statenative.ErrNilWrappedValidator)
|
|
}
|
|
}
|
|
|
|
func TestReadOnlyValidator_EffectiveBalance(t *testing.T) {
|
|
bal := uint64(234)
|
|
v, err := statenative.NewValidator(ðpb.Validator{EffectiveBalance: bal})
|
|
require.NoError(t, err)
|
|
assert.Equal(t, bal, v.EffectiveBalance())
|
|
}
|
|
|
|
func TestReadOnlyValidator_ActivationEligibilityEpoch(t *testing.T) {
|
|
epoch := types.Epoch(234)
|
|
v, err := statenative.NewValidator(ðpb.Validator{ActivationEligibilityEpoch: epoch})
|
|
require.NoError(t, err)
|
|
assert.Equal(t, epoch, v.ActivationEligibilityEpoch())
|
|
}
|
|
|
|
func TestReadOnlyValidator_ActivationEpoch(t *testing.T) {
|
|
epoch := types.Epoch(234)
|
|
v, err := statenative.NewValidator(ðpb.Validator{ActivationEpoch: epoch})
|
|
require.NoError(t, err)
|
|
assert.Equal(t, epoch, v.ActivationEpoch())
|
|
}
|
|
|
|
func TestReadOnlyValidator_WithdrawableEpoch(t *testing.T) {
|
|
epoch := types.Epoch(234)
|
|
v, err := statenative.NewValidator(ðpb.Validator{WithdrawableEpoch: epoch})
|
|
require.NoError(t, err)
|
|
assert.Equal(t, epoch, v.WithdrawableEpoch())
|
|
}
|
|
|
|
func TestReadOnlyValidator_ExitEpoch(t *testing.T) {
|
|
epoch := types.Epoch(234)
|
|
v, err := statenative.NewValidator(ðpb.Validator{ExitEpoch: epoch})
|
|
require.NoError(t, err)
|
|
assert.Equal(t, epoch, v.ExitEpoch())
|
|
}
|
|
|
|
func TestReadOnlyValidator_PublicKey(t *testing.T) {
|
|
key := [fieldparams.BLSPubkeyLength]byte{0xFA, 0xCC}
|
|
v, err := statenative.NewValidator(ðpb.Validator{PublicKey: key[:]})
|
|
require.NoError(t, err)
|
|
assert.Equal(t, key, v.PublicKey())
|
|
}
|
|
|
|
func TestReadOnlyValidator_WithdrawalCredentials(t *testing.T) {
|
|
creds := []byte{0xFA, 0xCC}
|
|
v, err := statenative.NewValidator(ðpb.Validator{WithdrawalCredentials: creds})
|
|
require.NoError(t, err)
|
|
assert.DeepEqual(t, creds, v.WithdrawalCredentials())
|
|
}
|
|
|
|
func TestReadOnlyValidator_Slashed(t *testing.T) {
|
|
v, err := statenative.NewValidator(ðpb.Validator{Slashed: true})
|
|
require.NoError(t, err)
|
|
assert.Equal(t, true, v.Slashed())
|
|
}
|