mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-05-02 03:02:54 -04:00
@@ -3,7 +3,9 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test")
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"deprecated_getters.go",
|
||||
"field_trie.go",
|
||||
"getters.go",
|
||||
"state_trie.go",
|
||||
"types.go",
|
||||
],
|
||||
@@ -23,12 +25,18 @@ go_library(
|
||||
"//tools/pcli:__pkg__",
|
||||
],
|
||||
deps = [
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateutil:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/copyutil:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/version:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
|
||||
"@org_golang_google_protobuf//proto:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -36,7 +44,9 @@ go_library(
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"deprecated_getters_test.go",
|
||||
"field_trie_test.go",
|
||||
"getters_test.go",
|
||||
"state_trie_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
|
||||
16
beacon-chain/state/v2/deprecated_getters.go
Normal file
16
beacon-chain/state/v2/deprecated_getters.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
)
|
||||
|
||||
// PreviousEpochAttestations is not supported for HF1 beacon state.
|
||||
func (b *BeaconState) PreviousEpochAttestations() ([]*statepb.PendingAttestation, error) {
|
||||
return nil, errors.New("PreviousEpochAttestations is not supported for hard fork 1 beacon state")
|
||||
}
|
||||
|
||||
// CurrentEpochAttestations is not supported for HF1 beacon state.
|
||||
func (b *BeaconState) CurrentEpochAttestations() ([]*statepb.PendingAttestation, error) {
|
||||
return nil, errors.New("CurrentEpochAttestations is not supported for hard fork 1 beacon state")
|
||||
}
|
||||
19
beacon-chain/state/v2/deprecated_getters_test.go
Normal file
19
beacon-chain/state/v2/deprecated_getters_test.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
|
||||
func TestBeaconState_CurrentEpochAttestations(t *testing.T) {
|
||||
s := &BeaconState{}
|
||||
_, err := s.CurrentEpochAttestations()
|
||||
require.ErrorContains(t, "CurrentEpochAttestations is not supported for hard fork 1 beacon state", err)
|
||||
}
|
||||
|
||||
func TestBeaconState_PreviousEpochAttestations(t *testing.T) {
|
||||
s := &BeaconState{}
|
||||
_, err := s.PreviousEpochAttestations()
|
||||
require.ErrorContains(t, "PreviousEpochAttestations is not supported for hard fork 1 beacon state", err)
|
||||
}
|
||||
1181
beacon-chain/state/v2/getters.go
Normal file
1181
beacon-chain/state/v2/getters.go
Normal file
File diff suppressed because it is too large
Load Diff
66
beacon-chain/state/v2/getters_test.go
Normal file
66
beacon-chain/state/v2/getters_test.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"runtime/debug"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNilState_NoPanic(t *testing.T) {
|
||||
var st *BeaconState
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Errorf("Method panicked when it was not supposed to: %v\n%v\n", r, string(debug.Stack()))
|
||||
}
|
||||
}()
|
||||
// retrieve elements from nil state
|
||||
_ = st.GenesisTime()
|
||||
_ = st.GenesisValidatorRoot()
|
||||
_ = st.GenesisUnixTime()
|
||||
_ = st.GenesisValidatorRoot()
|
||||
_ = st.Slot()
|
||||
_ = st.Fork()
|
||||
_ = st.LatestBlockHeader()
|
||||
_ = st.ParentRoot()
|
||||
_ = st.BlockRoots()
|
||||
_, err := st.BlockRootAtIndex(0)
|
||||
_ = err
|
||||
_ = st.StateRoots()
|
||||
_ = st.HistoricalRoots()
|
||||
_ = st.Eth1Data()
|
||||
_ = st.Eth1DataVotes()
|
||||
_ = st.Eth1DepositIndex()
|
||||
_, err = st.ValidatorAtIndex(0)
|
||||
_ = err
|
||||
_, err = st.ValidatorAtIndexReadOnly(0)
|
||||
_ = err
|
||||
_, _ = st.ValidatorIndexByPubkey([48]byte{})
|
||||
_ = st.PubkeyAtIndex(0)
|
||||
_ = st.NumValidators()
|
||||
_ = st.Balances()
|
||||
_, err = st.BalanceAtIndex(0)
|
||||
_ = err
|
||||
_ = st.BalancesLength()
|
||||
_ = st.RandaoMixes()
|
||||
_, err = st.RandaoMixAtIndex(0)
|
||||
_ = err
|
||||
_ = st.RandaoMixesLength()
|
||||
_ = st.Slashings()
|
||||
_, err = st.CurrentEpochParticipation()
|
||||
_ = err
|
||||
_, err = st.PreviousEpochParticipation()
|
||||
_ = err
|
||||
_ = st.JustificationBits()
|
||||
_ = st.PreviousJustifiedCheckpoint()
|
||||
_ = st.CurrentJustifiedCheckpoint()
|
||||
_ = st.FinalizedCheckpoint()
|
||||
_, err = st.CurrentEpochParticipation()
|
||||
_ = err
|
||||
_, err = st.PreviousEpochParticipation()
|
||||
_ = err
|
||||
_, err = st.InactivityScores()
|
||||
_ = err
|
||||
_, err = st.CurrentSyncCommittee()
|
||||
_ = err
|
||||
_, err = st.NextSyncCommittee()
|
||||
_ = err
|
||||
}
|
||||
Reference in New Issue
Block a user