2021-07-22 22:31:14 +00:00
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-03-15 18:32:09 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
|
|
|
testtmpl "github.com/prysmaticlabs/prysm/beacon-chain/state/testing"
|
2021-07-29 21:45:17 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
2021-07-22 22:31:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestBeaconState_LatestBlockHeader(t *testing.T) {
|
2022-03-15 18:32:09 +00:00
|
|
|
testtmpl.VerifyBeaconStateLatestBlockHeader(
|
|
|
|
t,
|
|
|
|
func() (state.BeaconState, error) {
|
|
|
|
return InitializeFromProto(ðpb.BeaconState{})
|
|
|
|
},
|
|
|
|
func(BH *ethpb.BeaconBlockHeader) (state.BeaconState, error) {
|
|
|
|
return InitializeFromProto(ðpb.BeaconState{LatestBlockHeader: BH})
|
|
|
|
},
|
|
|
|
)
|
2021-07-22 22:31:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestBeaconState_BlockRoots(t *testing.T) {
|
2022-03-15 18:32:09 +00:00
|
|
|
testtmpl.VerifyBeaconStateBlockRoots(
|
|
|
|
t,
|
|
|
|
func() (state.BeaconState, error) {
|
|
|
|
return InitializeFromProto(ðpb.BeaconState{})
|
|
|
|
},
|
|
|
|
func(BR [][]byte) (state.BeaconState, error) {
|
|
|
|
return InitializeFromProto(ðpb.BeaconState{BlockRoots: BR})
|
|
|
|
},
|
|
|
|
)
|
2021-07-22 22:31:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestBeaconState_BlockRootAtIndex(t *testing.T) {
|
2022-03-15 18:32:09 +00:00
|
|
|
testtmpl.VerifyBeaconStateBlockRootAtIndex(
|
|
|
|
t,
|
|
|
|
func() (state.BeaconState, error) {
|
|
|
|
return InitializeFromProto(ðpb.BeaconState{})
|
|
|
|
},
|
|
|
|
func(BR [][]byte) (state.BeaconState, error) {
|
|
|
|
return InitializeFromProto(ðpb.BeaconState{BlockRoots: BR})
|
|
|
|
},
|
|
|
|
)
|
2021-07-22 22:31:14 +00:00
|
|
|
}
|