mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 12:27:18 +00:00
4ad1c4df01
* Cache and use justified and finalized payload block hash * Fix tests * Use real byte * Fix conflicts Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
58 lines
1.6 KiB
Go
58 lines
1.6 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
|
|
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) {
|
|
s := &Store{}
|
|
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) {
|
|
s := &Store{}
|
|
var cp *ethpb.Checkpoint
|
|
require.Equal(t, cp, s.JustifiedCheckpt())
|
|
cp = ðpb.Checkpoint{Epoch: 1, Root: []byte{'a'}}
|
|
h := [32]byte{'b'}
|
|
s.SetJustifiedCheckptAndPayloadHash(cp, h)
|
|
require.Equal(t, cp, s.JustifiedCheckpt())
|
|
require.Equal(t, h, s.JustifiedPayloadBlockHash())
|
|
}
|
|
|
|
func Test_store_FinalizedCheckpt(t *testing.T) {
|
|
s := &Store{}
|
|
var cp *ethpb.Checkpoint
|
|
require.Equal(t, cp, s.FinalizedCheckpt())
|
|
cp = ðpb.Checkpoint{Epoch: 1, Root: []byte{'a'}}
|
|
h := [32]byte{'b'}
|
|
s.SetFinalizedCheckptAndPayloadHash(cp, h)
|
|
require.Equal(t, cp, s.FinalizedCheckpt())
|
|
require.Equal(t, h, s.FinalizedPayloadBlockHash())
|
|
}
|
|
|
|
func Test_store_PrevFinalizedCheckpt(t *testing.T) {
|
|
s := &Store{}
|
|
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())
|
|
}
|