mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-04 00:44:27 +00:00
d143187b7e
* include fixes * rev * logrus * tests for query sync status and chain head * begin tests for indexed atts * test passing for requesting historical atts * Update slasher/beaconclient/chain_data_test.go * Update slasher/beaconclient/historical_data_retrieval.go * lint * fixed up wanted vs receied * fix mock * gazelle * fix broken build * tests pass * dep * gaz * add dep * tests pass Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
57 lines
1.0 KiB
Go
57 lines
1.0 KiB
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"testing"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
func TestChainHead(t *testing.T) {
|
|
app := cli.NewApp()
|
|
set := flag.NewFlagSet("test", 0)
|
|
db := setupDB(t, cli.NewContext(app, set, nil))
|
|
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 {
|
|
if err := db.SaveChainHead(ctx, tt.head); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
head, err := db.ChainHead(ctx)
|
|
if err != nil {
|
|
t.Fatalf("failed to get block: %v", err)
|
|
}
|
|
if head == nil || !proto.Equal(head, tt.head) {
|
|
t.Errorf("Expected %v, got %v", tt.head, head)
|
|
}
|
|
}
|
|
}
|