2022-01-24 19:53:05 +00:00
|
|
|
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) {
|
2022-01-25 18:47:39 +00:00
|
|
|
s := &Store{}
|
2022-01-24 19:53:05 +00:00
|
|
|
var cp *ethpb.Checkpoint
|
|
|
|
require.Equal(t, cp, s.PrevJustifiedCheckpt())
|
|
|
|
cp = ðpb.Checkpoint{Epoch: 1, Root: []byte{'a'}}
|
|
|
|
s.SetPrevJustifiedCheckpt(cp)
|
|
|
|
require.Equal(t, cp, s.PrevJustifiedCheckpt())
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_store_BestJustifiedCheckpt(t *testing.T) {
|
2022-01-25 18:47:39 +00:00
|
|
|
s := &Store{}
|
2022-01-24 19:53:05 +00:00
|
|
|
var cp *ethpb.Checkpoint
|
|
|
|
require.Equal(t, cp, s.BestJustifiedCheckpt())
|
|
|
|
cp = ðpb.Checkpoint{Epoch: 1, Root: []byte{'a'}}
|
|
|
|
s.SetBestJustifiedCheckpt(cp)
|
|
|
|
require.Equal(t, cp, s.BestJustifiedCheckpt())
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_store_JustifiedCheckpt(t *testing.T) {
|
2022-01-25 18:47:39 +00:00
|
|
|
s := &Store{}
|
2022-01-24 19:53:05 +00:00
|
|
|
var cp *ethpb.Checkpoint
|
|
|
|
require.Equal(t, cp, s.JustifiedCheckpt())
|
|
|
|
cp = ðpb.Checkpoint{Epoch: 1, Root: []byte{'a'}}
|
2022-05-10 21:20:28 +00:00
|
|
|
h := [32]byte{'b'}
|
|
|
|
s.SetJustifiedCheckptAndPayloadHash(cp, h)
|
2022-01-24 19:53:05 +00:00
|
|
|
require.Equal(t, cp, s.JustifiedCheckpt())
|
2022-05-10 21:20:28 +00:00
|
|
|
require.Equal(t, h, s.JustifiedPayloadBlockHash())
|
2022-01-24 19:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Test_store_FinalizedCheckpt(t *testing.T) {
|
2022-01-25 18:47:39 +00:00
|
|
|
s := &Store{}
|
2022-01-24 19:53:05 +00:00
|
|
|
var cp *ethpb.Checkpoint
|
|
|
|
require.Equal(t, cp, s.FinalizedCheckpt())
|
|
|
|
cp = ðpb.Checkpoint{Epoch: 1, Root: []byte{'a'}}
|
2022-05-10 21:20:28 +00:00
|
|
|
h := [32]byte{'b'}
|
|
|
|
s.SetFinalizedCheckptAndPayloadHash(cp, h)
|
2022-01-24 19:53:05 +00:00
|
|
|
require.Equal(t, cp, s.FinalizedCheckpt())
|
2022-05-10 21:20:28 +00:00
|
|
|
require.Equal(t, h, s.FinalizedPayloadBlockHash())
|
2022-01-24 19:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Test_store_PrevFinalizedCheckpt(t *testing.T) {
|
2022-01-25 18:47:39 +00:00
|
|
|
s := &Store{}
|
2022-01-24 19:53:05 +00:00
|
|
|
var cp *ethpb.Checkpoint
|
|
|
|
require.Equal(t, cp, s.PrevFinalizedCheckpt())
|
|
|
|
cp = ðpb.Checkpoint{Epoch: 1, Root: []byte{'a'}}
|
|
|
|
s.SetPrevFinalizedCheckpt(cp)
|
|
|
|
require.Equal(t, cp, s.PrevFinalizedCheckpt())
|
|
|
|
}
|