mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-07 10:12:19 +00:00
7a46cc0681
* Enforce stronger head state operations * fix genesis state generation * one test left to fix * all tests passing now * gofmt * Update beacon-chain/db/kv/state_test.go Co-Authored-By: Raul Jordan <raul@prysmaticlabs.com> * Update beacon-chain/db/kv/state.go Co-Authored-By: Raul Jordan <raul@prysmaticlabs.com> * fix tests
48 lines
910 B
Go
48 lines
910 B
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
"io/ioutil"
|
|
"path"
|
|
"testing"
|
|
|
|
eth "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/go-ssz"
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
)
|
|
|
|
func TestStore_Backup(t *testing.T) {
|
|
db := setupDB(t)
|
|
defer teardownDB(t, db)
|
|
ctx := context.Background()
|
|
|
|
head := ð.BeaconBlock{}
|
|
head.Slot = 5000
|
|
|
|
if err := db.SaveBlock(ctx, head); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
root, err := ssz.SigningRoot(head)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := db.SaveState(ctx, &pb.BeaconState{}, root); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := db.SaveHeadBlockRoot(ctx, root); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if err := db.Backup(ctx); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
files, err := ioutil.ReadDir(path.Join(db.databasePath, backupsDirectoryName))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(files) == 0 {
|
|
t.Fatal("No backups created.")
|
|
}
|
|
}
|