mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 19:21:19 +00:00
370cf1a6c8
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
73 lines
2.0 KiB
Go
73 lines
2.0 KiB
Go
package store
|
|
|
|
import (
|
|
"testing"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
|
)
|
|
|
|
func Test_store_PrevJustifiedCheckpt(t *testing.T) {
|
|
s := &Store{}
|
|
var cp *ethpb.Checkpoint
|
|
_, err := s.PrevJustifiedCheckpt()
|
|
require.ErrorIs(t, ErrNilCheckpoint, err)
|
|
cp = ðpb.Checkpoint{Epoch: 1, Root: []byte{'a'}}
|
|
s.SetPrevJustifiedCheckpt(cp)
|
|
got, err := s.PrevJustifiedCheckpt()
|
|
require.NoError(t, err)
|
|
require.Equal(t, cp, got)
|
|
}
|
|
|
|
func Test_store_BestJustifiedCheckpt(t *testing.T) {
|
|
s := &Store{}
|
|
var cp *ethpb.Checkpoint
|
|
_, err := s.BestJustifiedCheckpt()
|
|
require.ErrorIs(t, ErrNilCheckpoint, err)
|
|
cp = ðpb.Checkpoint{Epoch: 1, Root: []byte{'a'}}
|
|
s.SetBestJustifiedCheckpt(cp)
|
|
got, err := s.BestJustifiedCheckpt()
|
|
require.NoError(t, err)
|
|
require.Equal(t, cp, got)
|
|
}
|
|
|
|
func Test_store_JustifiedCheckpt(t *testing.T) {
|
|
s := &Store{}
|
|
var cp *ethpb.Checkpoint
|
|
_, err := s.JustifiedCheckpt()
|
|
require.ErrorIs(t, ErrNilCheckpoint, err)
|
|
cp = ðpb.Checkpoint{Epoch: 1, Root: []byte{'a'}}
|
|
h := [32]byte{'b'}
|
|
s.SetJustifiedCheckptAndPayloadHash(cp, h)
|
|
got, err := s.JustifiedCheckpt()
|
|
require.NoError(t, err)
|
|
require.Equal(t, cp, got)
|
|
require.Equal(t, h, s.JustifiedPayloadBlockHash())
|
|
}
|
|
|
|
func Test_store_FinalizedCheckpt(t *testing.T) {
|
|
s := &Store{}
|
|
var cp *ethpb.Checkpoint
|
|
_, err := s.FinalizedCheckpt()
|
|
require.ErrorIs(t, ErrNilCheckpoint, err)
|
|
cp = ðpb.Checkpoint{Epoch: 1, Root: []byte{'a'}}
|
|
h := [32]byte{'b'}
|
|
s.SetFinalizedCheckptAndPayloadHash(cp, h)
|
|
got, err := s.FinalizedCheckpt()
|
|
require.NoError(t, err)
|
|
require.Equal(t, cp, got)
|
|
require.Equal(t, h, s.FinalizedPayloadBlockHash())
|
|
}
|
|
|
|
func Test_store_PrevFinalizedCheckpt(t *testing.T) {
|
|
s := &Store{}
|
|
var cp *ethpb.Checkpoint
|
|
_, err := s.PrevFinalizedCheckpt()
|
|
require.ErrorIs(t, ErrNilCheckpoint, err)
|
|
cp = ðpb.Checkpoint{Epoch: 1, Root: []byte{'a'}}
|
|
s.SetPrevFinalizedCheckpt(cp)
|
|
got, err := s.PrevFinalizedCheckpt()
|
|
require.NoError(t, err)
|
|
require.Equal(t, cp, got)
|
|
}
|