prysm-pulse/slasher/db/kv/chain_data_test.go
Raul Jordan 5aac06f04e
Move EthereumAPIs Into Prysm (#8968)
* begin move

* use same import path

* imports

* regen protos

* regen

* no rename

* generate ssz

* gaz

* fmt

* edit build file

* imports

* modify

* remove generated files

* remove protos

* edit imports in prysm

* beacon chain all builds

* edit script

* add generated pbs

* add replace rules

* license for ethereumapis protos

* change visibility

* fmt

* update build files to gaz ignore

* use proper form

* edit imports

* wrap block

* revert scripts

* revert go mod
2021-06-02 18:49:52 -05:00

49 lines
911 B
Go

package kv
import (
"context"
"testing"
ethpb "github.com/prysmaticlabs/prysm/proto/eth/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: &ethpb.ChainHead{
HeadSlot: 20,
HeadEpoch: 20,
FinalizedSlot: 10,
FinalizedEpoch: 10,
JustifiedSlot: 10,
JustifiedEpoch: 10,
},
},
{
head: &ethpb.ChainHead{
HeadSlot: 1,
},
},
{
head: &ethpb.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)
}
}