prysm-pulse/beacon-chain/db/block_operations_test.go

33 lines
610 B
Go

package db
import (
"testing"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/hashutil"
)
func TestBeaconDB_HasExit(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)
d := &pb.Exit{
Slot: 100,
}
hash, err := hashutil.HashProto(d)
if err != nil {
t.Fatalf("could not hash exit request: %v", err)
}
if db.HasExit(hash) {
t.Fatal("Expected HasExit to return false")
}
if err := db.SaveExit(d); err != nil {
t.Fatalf("Failed to save exit request: %v", err)
}
if !db.HasExit(hash) {
t.Fatal("Expected HasExit to return true")
}
}