mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Fix validator export failing when validator.db is in nested directory (#15351)
* files changed * added changelog file * added tests and formatting changes * fixed bugs * fixed formatting
This commit is contained in:
@@ -26,7 +26,7 @@ func TestMigrateUp_NoDBFound(t *testing.T) {
|
||||
// This, it is tested only for complete slashing protection database.
|
||||
func TestMigrateUp_OK(t *testing.T) {
|
||||
isSlashingProtectionMinimal := false
|
||||
validatorDB := dbtest.SetupDB(t, nil, isSlashingProtectionMinimal)
|
||||
validatorDB := dbtest.SetupDB(t, t.TempDir(), nil, isSlashingProtectionMinimal)
|
||||
dbPath := validatorDB.DatabasePath()
|
||||
require.NoError(t, validatorDB.Close())
|
||||
app := cli.App{}
|
||||
@@ -52,7 +52,7 @@ func TestMigrateDown_NoDBFound(t *testing.T) {
|
||||
// This, it is tested only for complete slashing protection database.
|
||||
func TestMigrateDown_OK(t *testing.T) {
|
||||
isSlashingProtectionMinimal := false
|
||||
validatorDB := dbtest.SetupDB(t, nil, isSlashingProtectionMinimal)
|
||||
validatorDB := dbtest.SetupDB(t, t.TempDir(), nil, isSlashingProtectionMinimal)
|
||||
dbPath := validatorDB.DatabasePath()
|
||||
require.NoError(t, validatorDB.Close())
|
||||
app := cli.App{}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
// SetupDB instantiates and returns a DB instance for the validator client.
|
||||
// The `minimal` flag indicates whether the DB should be instantiated with minimal, filesystem
|
||||
// slashing protection database.
|
||||
func SetupDB(t testing.TB, pubkeys [][fieldparams.BLSPubkeyLength]byte, minimal bool) iface.ValidatorDB {
|
||||
func SetupDB(t testing.TB, dataPath string, pubkeys [][fieldparams.BLSPubkeyLength]byte, minimal bool) iface.ValidatorDB {
|
||||
var (
|
||||
db iface.ValidatorDB
|
||||
err error
|
||||
@@ -22,10 +22,10 @@ func SetupDB(t testing.TB, pubkeys [][fieldparams.BLSPubkeyLength]byte, minimal
|
||||
// Create a new DB instance.
|
||||
if minimal {
|
||||
config := &filesystem.Config{PubKeys: pubkeys}
|
||||
db, err = filesystem.NewStore(t.TempDir(), config)
|
||||
db, err = filesystem.NewStore(dataPath, config)
|
||||
} else {
|
||||
config := &kv.Config{PubKeys: pubkeys}
|
||||
db, err = kv.NewKVStore(context.Background(), t.TempDir(), config)
|
||||
db, err = kv.NewKVStore(context.Background(), dataPath, config)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user