prysm-pulse/beacon-chain/db/kv/backup_test.go
Raul Jordan a468a12ef0
Allow Specifying Output Directory When Creating DB Backups (#7630)
* 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>
2020-10-26 18:20:54 +00:00

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")
}