mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
fecbec2342
* part1 * go tidy * Merge branch 'go-tidy' into apply-testutils-assertions-to-beaconchain-db * updated beacon-chain/db/kv tests * Merge branch 'master' into apply-testutils-assertions-to-beaconchain-db * Merge refs/heads/master into apply-testutils-assertions-to-beaconchain-db * Merge refs/heads/master into apply-testutils-assertions-to-beaconchain-db
34 lines
907 B
Go
34 lines
907 B
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
"io/ioutil"
|
|
"path"
|
|
"testing"
|
|
|
|
eth "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
|
|
"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 := ð.SignedBeaconBlock{Block: ð.BeaconBlock{Slot: 5000}}
|
|
|
|
require.NoError(t, db.SaveBlock(ctx, head))
|
|
root, err := stateutil.BlockRoot(head.Block)
|
|
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")
|
|
}
|