mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
Complete coverage for in beacon chain state for getters checkpoint (#10373)
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
testtmpl "github.com/prysmaticlabs/prysm/beacon-chain/state/testing"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
func TestBeaconState_JustificationBitsNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateJustificationBitsNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_JustificationBits(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateJustificationBits(
|
||||
t,
|
||||
func(bits bitfield.Bitvector4) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{JustificationBits: bits})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_PreviousJustifiedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_PreviousJustifiedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{PreviousJustifiedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_CurrentJustifiedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_CurrentJustifiedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{CurrentJustifiedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_FinalizedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateFinalizedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_FinalizedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateFinalizedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{FinalizedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
testtmpl "github.com/prysmaticlabs/prysm/beacon-chain/state/testing"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
func TestBeaconState_JustificationBitsNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateJustificationBitsNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_JustificationBits(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateJustificationBits(
|
||||
t,
|
||||
func(bits bitfield.Bitvector4) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{JustificationBits: bits})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_PreviousJustifiedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_PreviousJustifiedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{PreviousJustifiedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_CurrentJustifiedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_CurrentJustifiedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{CurrentJustifiedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_FinalizedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateFinalizedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_FinalizedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateFinalizedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{FinalizedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package v3
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
testtmpl "github.com/prysmaticlabs/prysm/beacon-chain/state/testing"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
func TestBeaconState_JustificationBitsNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateJustificationBitsNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_JustificationBits(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateJustificationBits(
|
||||
t,
|
||||
func(bits bitfield.Bitvector4) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{JustificationBits: bits})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_PreviousJustifiedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_PreviousJustifiedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{PreviousJustifiedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_CurrentJustifiedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_CurrentJustifiedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{CurrentJustifiedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_FinalizedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateFinalizedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_FinalizedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateFinalizedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{FinalizedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
srcs = [
|
||||
"getters.go",
|
||||
"getters_block.go",
|
||||
"getters_checkpoint.go",
|
||||
"getters_validator.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/state/testing",
|
||||
@@ -18,5 +19,6 @@ go_library(
|
||||
"//testing/assert:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
103
beacon-chain/state/testing/getters_checkpoint.go
Normal file
103
beacon-chain/state/testing/getters_checkpoint.go
Normal file
@@ -0,0 +1,103 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/testing/require"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func VerifyBeaconStateJustificationBitsNil(t *testing.T, factory getState) {
|
||||
s, err := factory()
|
||||
require.NoError(t, err)
|
||||
|
||||
bits := s.JustificationBits()
|
||||
require.DeepEqual(t, bitfield.Bitvector4{}.Bytes(), bits.Bytes())
|
||||
}
|
||||
|
||||
type getStateWithJustificationBits = func(bitfield.Bitvector4) (state.BeaconState, error)
|
||||
|
||||
func VerifyBeaconStateJustificationBits(t *testing.T, factory getStateWithJustificationBits) {
|
||||
s, err := factory(bitfield.Bitvector4{1, 2, 3, 4})
|
||||
require.NoError(t, err)
|
||||
|
||||
bits := s.JustificationBits()
|
||||
require.DeepEqual(t, bitfield.Bitvector4{1, 2, 3, 4}.Bytes(), bits.Bytes())
|
||||
}
|
||||
|
||||
func VerifyBeaconStatePreviousJustifiedCheckpointNil(t *testing.T, factory getState) {
|
||||
s, err := factory()
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
checkpoint := s.PreviousJustifiedCheckpoint()
|
||||
require.Equal(t, (*ethpb.Checkpoint)(nil), checkpoint)
|
||||
}
|
||||
|
||||
type getStateWithCheckpoint = func(checkpoint *ethpb.Checkpoint) (state.BeaconState, error)
|
||||
|
||||
func VerifyBeaconStatePreviousJustifiedCheckpoint(t *testing.T, factory getStateWithCheckpoint) {
|
||||
orgCheckpoint := ðpb.Checkpoint{Root: make([]byte, fieldparams.RootLength)}
|
||||
orgCheckpoint.Root[1] = 1
|
||||
orgCheckpoint.Root[2] = 2
|
||||
orgCheckpoint.Root[3] = 3
|
||||
s, err := factory(orgCheckpoint)
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
checkpoint := s.PreviousJustifiedCheckpoint()
|
||||
require.DeepEqual(t, orgCheckpoint.Root, checkpoint.Root)
|
||||
}
|
||||
|
||||
func VerifyBeaconStateCurrentJustifiedCheckpointNil(t *testing.T, factory getState) {
|
||||
s, err := factory()
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
checkpoint := s.CurrentJustifiedCheckpoint()
|
||||
require.Equal(t, (*ethpb.Checkpoint)(nil), checkpoint)
|
||||
}
|
||||
|
||||
func VerifyBeaconStateCurrentJustifiedCheckpoint(t *testing.T, factory getStateWithCheckpoint) {
|
||||
orgCheckpoint := ðpb.Checkpoint{Root: make([]byte, fieldparams.RootLength)}
|
||||
orgCheckpoint.Root[1] = 1
|
||||
orgCheckpoint.Root[2] = 2
|
||||
orgCheckpoint.Root[3] = 3
|
||||
s, err := factory(orgCheckpoint)
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
checkpoint := s.CurrentJustifiedCheckpoint()
|
||||
require.DeepEqual(t, orgCheckpoint.Root, checkpoint.Root)
|
||||
}
|
||||
|
||||
func VerifyBeaconStateFinalizedCheckpointNil(t *testing.T, factory getState) {
|
||||
s, err := factory()
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
checkpoint := s.FinalizedCheckpoint()
|
||||
require.Equal(t, (*ethpb.Checkpoint)(nil), checkpoint)
|
||||
epoch := s.FinalizedCheckpointEpoch()
|
||||
require.Equal(t, types.Epoch(0), epoch)
|
||||
}
|
||||
|
||||
func VerifyBeaconStateFinalizedCheckpoint(t *testing.T, factory getStateWithCheckpoint) {
|
||||
orgCheckpoint := ðpb.Checkpoint{Root: make([]byte, fieldparams.RootLength)}
|
||||
orgCheckpoint.Root[1] = 1
|
||||
orgCheckpoint.Root[2] = 2
|
||||
orgCheckpoint.Root[3] = 3
|
||||
orgCheckpoint.Epoch = 123
|
||||
s, err := factory(orgCheckpoint)
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
checkpoint := s.FinalizedCheckpoint()
|
||||
require.DeepEqual(t, orgCheckpoint.Root, checkpoint.Root)
|
||||
epoch := s.FinalizedCheckpointEpoch()
|
||||
require.Equal(t, orgCheckpoint.Epoch, epoch)
|
||||
}
|
||||
@@ -59,6 +59,7 @@ go_test(
|
||||
srcs = [
|
||||
"getters_attestation_test.go",
|
||||
"getters_block_test.go",
|
||||
"getters_checkpoint_test.go",
|
||||
"getters_test.go",
|
||||
"getters_validator_test.go",
|
||||
"proofs_test.go",
|
||||
|
||||
74
beacon-chain/state/v1/getters_checkpoint_test.go
Normal file
74
beacon-chain/state/v1/getters_checkpoint_test.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
testtmpl "github.com/prysmaticlabs/prysm/beacon-chain/state/testing"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
func TestBeaconState_JustificationBitsNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateJustificationBitsNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_JustificationBits(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateJustificationBits(
|
||||
t,
|
||||
func(bits bitfield.Bitvector4) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{JustificationBits: bits})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_PreviousJustifiedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_PreviousJustifiedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{PreviousJustifiedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_CurrentJustifiedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_CurrentJustifiedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{CurrentJustifiedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_FinalizedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateFinalizedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_FinalizedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateFinalizedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconState{FinalizedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
@@ -60,6 +60,7 @@ go_test(
|
||||
"deprecated_getters_test.go",
|
||||
"deprecated_setters_test.go",
|
||||
"getters_block_test.go",
|
||||
"getters_checkpoint_test.go",
|
||||
"getters_test.go",
|
||||
"getters_validator_test.go",
|
||||
"proofs_test.go",
|
||||
|
||||
74
beacon-chain/state/v2/getters_checkpoint_test.go
Normal file
74
beacon-chain/state/v2/getters_checkpoint_test.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
testtmpl "github.com/prysmaticlabs/prysm/beacon-chain/state/testing"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
func TestBeaconState_JustificationBitsNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateJustificationBitsNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_JustificationBits(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateJustificationBits(
|
||||
t,
|
||||
func(bits bitfield.Bitvector4) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{JustificationBits: bits})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_PreviousJustifiedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_PreviousJustifiedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{PreviousJustifiedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_CurrentJustifiedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_CurrentJustifiedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{CurrentJustifiedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_FinalizedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateFinalizedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_FinalizedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateFinalizedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{FinalizedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
@@ -62,6 +62,7 @@ go_test(
|
||||
"deprecated_getters_test.go",
|
||||
"deprecated_setters_test.go",
|
||||
"getters_block_test.go",
|
||||
"getters_checkpoint_test.go",
|
||||
"getters_test.go",
|
||||
"getters_validator_test.go",
|
||||
"proofs_test.go",
|
||||
|
||||
74
beacon-chain/state/v3/getters_checkpoint_test.go
Normal file
74
beacon-chain/state/v3/getters_checkpoint_test.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package v3
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
testtmpl "github.com/prysmaticlabs/prysm/beacon-chain/state/testing"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
func TestBeaconState_JustificationBitsNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateJustificationBitsNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_JustificationBits(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateJustificationBits(
|
||||
t,
|
||||
func(bits bitfield.Bitvector4) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{JustificationBits: bits})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_PreviousJustifiedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_PreviousJustifiedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{PreviousJustifiedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_CurrentJustifiedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_CurrentJustifiedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{CurrentJustifiedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_FinalizedCheckpointNil(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateFinalizedCheckpointNil(
|
||||
t,
|
||||
func() (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{})
|
||||
})
|
||||
}
|
||||
|
||||
func TestBeaconState_FinalizedCheckpoint(t *testing.T) {
|
||||
testtmpl.VerifyBeaconStateFinalizedCheckpoint(
|
||||
t,
|
||||
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
|
||||
return InitializeFromProtoUnsafe(ðpb.BeaconStateBellatrix{FinalizedCheckpoint: cp})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user