mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 05:17:22 +00:00
a9a4bb9163
* move testutil * util pkg * build * gaz Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
32 lines
1.1 KiB
Go
32 lines
1.1 KiB
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/testing/assert"
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func TestStore_VoluntaryExits_CRUD(t *testing.T) {
|
|
db := setupDB(t)
|
|
ctx := context.Background()
|
|
exit := ðpb.VoluntaryExit{
|
|
Epoch: 5,
|
|
}
|
|
exitRoot, err := exit.HashTreeRoot()
|
|
require.NoError(t, err)
|
|
retrieved, err := db.VoluntaryExit(ctx, exitRoot)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, (*ethpb.VoluntaryExit)(nil), retrieved, "Expected nil voluntary exit")
|
|
require.NoError(t, db.SaveVoluntaryExit(ctx, exit))
|
|
assert.Equal(t, true, db.HasVoluntaryExit(ctx, exitRoot), "Expected voluntary exit to exist in the db")
|
|
retrieved, err = db.VoluntaryExit(ctx, exitRoot)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, true, proto.Equal(exit, retrieved), "Wanted %v, received %v", exit, retrieved)
|
|
require.NoError(t, db.deleteVoluntaryExit(ctx, exitRoot))
|
|
assert.Equal(t, false, db.HasVoluntaryExit(ctx, exitRoot), "Expected voluntary exit to have been deleted from the db")
|
|
}
|