mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
d077483577
* v3 import renamings * tidy * fmt * rev * Update beacon-chain/core/epoch/precompute/reward_penalty_test.go * Update beacon-chain/core/helpers/validators_test.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/iface/BUILD.bazel * Update beacon-chain/db/kv/kv.go * Update beacon-chain/db/kv/state.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/sync/initial-sync/service.go * fix deps * fix bad replacements * fix bad replacements * change back * gohashtree version * fix deps Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com>
57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
package db
|
|
|
|
import (
|
|
"flag"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/cmd"
|
|
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
|
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
|
dbtest "github.com/prysmaticlabs/prysm/v3/validator/db/testing"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
func TestMigrateUp_NoDBFound(t *testing.T) {
|
|
app := cli.App{}
|
|
set := flag.NewFlagSet("test", 0)
|
|
set.String(cmd.DataDirFlag.Name, "", "")
|
|
require.NoError(t, set.Set(cmd.DataDirFlag.Name, ""))
|
|
cliCtx := cli.NewContext(&app, set, nil)
|
|
err := MigrateUp(cliCtx)
|
|
assert.ErrorContains(t, "No validator db found at path", err)
|
|
}
|
|
|
|
func TestMigrateUp_OK(t *testing.T) {
|
|
validatorDB := dbtest.SetupDB(t, nil)
|
|
dbPath := validatorDB.DatabasePath()
|
|
require.NoError(t, validatorDB.Close())
|
|
app := cli.App{}
|
|
set := flag.NewFlagSet("test", 0)
|
|
set.String(cmd.DataDirFlag.Name, dbPath, "")
|
|
require.NoError(t, set.Set(cmd.DataDirFlag.Name, dbPath))
|
|
cliCtx := cli.NewContext(&app, set, nil)
|
|
assert.NoError(t, MigrateUp(cliCtx))
|
|
}
|
|
|
|
func TestMigrateDown_NoDBFound(t *testing.T) {
|
|
app := cli.App{}
|
|
set := flag.NewFlagSet("test", 0)
|
|
set.String(cmd.DataDirFlag.Name, "", "")
|
|
require.NoError(t, set.Set(cmd.DataDirFlag.Name, ""))
|
|
cliCtx := cli.NewContext(&app, set, nil)
|
|
err := MigrateDown(cliCtx)
|
|
assert.ErrorContains(t, "No validator db found at path", err)
|
|
}
|
|
|
|
func TestMigrateDown_OK(t *testing.T) {
|
|
validatorDB := dbtest.SetupDB(t, nil)
|
|
dbPath := validatorDB.DatabasePath()
|
|
require.NoError(t, validatorDB.Close())
|
|
app := cli.App{}
|
|
set := flag.NewFlagSet("test", 0)
|
|
set.String(cmd.DataDirFlag.Name, dbPath, "")
|
|
require.NoError(t, set.Set(cmd.DataDirFlag.Name, dbPath))
|
|
cliCtx := cli.NewContext(&app, set, nil)
|
|
assert.NoError(t, MigrateDown(cliCtx))
|
|
}
|