mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
54772596e0
* Add rest of state v2 * Update BUILD.bazel
89 lines
1.9 KiB
Go
89 lines
1.9 KiB
Go
package v2
|
|
|
|
import (
|
|
"runtime/debug"
|
|
"sync"
|
|
"testing"
|
|
|
|
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
)
|
|
|
|
func TestBeaconState_SlotDataRace(t *testing.T) {
|
|
headState, err := InitializeFromProto(&statepb.BeaconStateAltair{Slot: 1})
|
|
require.NoError(t, err)
|
|
|
|
wg := sync.WaitGroup{}
|
|
wg.Add(2)
|
|
go func() {
|
|
require.NoError(t, headState.SetSlot(0))
|
|
wg.Done()
|
|
}()
|
|
go func() {
|
|
headState.Slot()
|
|
wg.Done()
|
|
}()
|
|
|
|
wg.Wait()
|
|
}
|
|
|
|
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
|
|
}
|