mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-13 13:43:30 +00:00
a468a12ef0
* move flags * backup db output dir flag * fix build * fix up broken backup test * Radek's feedback Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
33 lines
774 B
Go
33 lines
774 B
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
"io/ioutil"
|
|
"path"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
)
|
|
|
|
func TestStore_Backup(t *testing.T) {
|
|
db := setupDB(t)
|
|
ctx := context.Background()
|
|
|
|
head := testutil.NewBeaconBlock()
|
|
head.Block.Slot = 5000
|
|
|
|
require.NoError(t, db.SaveBlock(ctx, head))
|
|
root, err := head.Block.HashTreeRoot()
|
|
require.NoError(t, err)
|
|
st := testutil.NewBeaconState()
|
|
require.NoError(t, db.SaveState(ctx, st, root))
|
|
require.NoError(t, db.SaveHeadBlockRoot(ctx, root))
|
|
|
|
require.NoError(t, db.Backup(ctx, ""))
|
|
|
|
files, err := ioutil.ReadDir(path.Join(db.databasePath, backupsDirectoryName))
|
|
require.NoError(t, err)
|
|
require.NotEqual(t, 0, len(files), "No backups created")
|
|
}
|