2019-01-30 19:48:50 +00:00
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
2019-03-17 02:56:05 +00:00
|
|
|
"context"
|
2019-01-30 19:48:50 +00:00
|
|
|
"testing"
|
|
|
|
|
2019-07-22 14:03:57 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
|
2019-01-30 19:48:50 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBeaconDB_HasExit(t *testing.T) {
|
|
|
|
db := setupDB(t)
|
|
|
|
defer teardownDB(t, db)
|
|
|
|
|
2019-07-22 14:03:57 +00:00
|
|
|
d := ðpb.VoluntaryExit{
|
2019-02-08 21:53:36 +00:00
|
|
|
Epoch: 100,
|
2019-01-30 19:48:50 +00:00
|
|
|
}
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
2019-03-17 02:56:05 +00:00
|
|
|
if err := db.SaveExit(context.Background(), d); err != nil {
|
2019-01-30 19:48:50 +00:00
|
|
|
t.Fatalf("Failed to save exit request: %v", err)
|
|
|
|
}
|
|
|
|
if !db.HasExit(hash) {
|
|
|
|
t.Fatal("Expected HasExit to return true")
|
|
|
|
}
|
|
|
|
}
|