mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
49 lines
913 B
Go
49 lines
913 B
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
)
|
|
|
|
func TestChainHead(t *testing.T) {
|
|
db := setupDB(t)
|
|
ctx := context.Background()
|
|
|
|
tests := []struct {
|
|
head *ethpb.ChainHead
|
|
}{
|
|
{
|
|
head: ðpb.ChainHead{
|
|
HeadSlot: 20,
|
|
HeadEpoch: 20,
|
|
FinalizedSlot: 10,
|
|
FinalizedEpoch: 10,
|
|
JustifiedSlot: 10,
|
|
JustifiedEpoch: 10,
|
|
},
|
|
},
|
|
{
|
|
head: ðpb.ChainHead{
|
|
HeadSlot: 1,
|
|
},
|
|
},
|
|
{
|
|
head: ðpb.ChainHead{
|
|
HeadBlockRoot: make([]byte, 32),
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
require.NoError(t, db.SaveChainHead(ctx, tt.head))
|
|
head, err := db.ChainHead(ctx)
|
|
require.NoError(t, err, "Failed to get block")
|
|
assert.NotNil(t, head)
|
|
assert.DeepEqual(t, tt.head, head)
|
|
}
|
|
}
|