mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
b5c4dc2a75
* init-sync updates * slasher/db/kv tests * beacon-chain/rpc/beacon tests * update kv_test * beacon-chain/rpc-validator tests updated * slasher/db/kv - remove teardown method * beacon-chain/sync tests updated * beacon-chain/db/kv tests updated * beacon-chain/blockchain tests updated * beacon-chain/state/stategen tests updated * beacon-chain/powchain updates * updates rest of slasher tests * validator/db tests * rest of the tests * minor comments update * gazelle * Merge refs/heads/master into teardowndb-to-cleanup
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/go-ssz"
|
|
)
|
|
|
|
func TestStore_VoluntaryExits_CRUD(t *testing.T) {
|
|
db := setupDB(t)
|
|
ctx := context.Background()
|
|
exit := ðpb.VoluntaryExit{
|
|
Epoch: 5,
|
|
}
|
|
exitRoot, err := ssz.HashTreeRoot(exit)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
retrieved, err := db.VoluntaryExit(ctx, exitRoot)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if retrieved != nil {
|
|
t.Errorf("Expected nil voluntary exit, received %v", retrieved)
|
|
}
|
|
if err := db.SaveVoluntaryExit(ctx, exit); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !db.HasVoluntaryExit(ctx, exitRoot) {
|
|
t.Error("Expected voluntary exit to exist in the db")
|
|
}
|
|
retrieved, err = db.VoluntaryExit(ctx, exitRoot)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !proto.Equal(exit, retrieved) {
|
|
t.Errorf("Wanted %v, received %v", exit, retrieved)
|
|
}
|
|
if err := db.DeleteVoluntaryExit(ctx, exitRoot); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if db.HasVoluntaryExit(ctx, exitRoot) {
|
|
t.Error("Expected voluntary exit to have been deleted from the db")
|
|
}
|
|
}
|