cli: add db reset command

Close #2576.
This commit is contained in:
Anna Shaleva 2022-10-20 13:59:35 +03:00
parent bd6bb9e9e2
commit 30cfe4d8c8
3 changed files with 69 additions and 1 deletions

View file

@ -351,3 +351,18 @@ func TestInitBlockChain(t *testing.T) {
require.Error(t, err)
})
}
func TestResetDB(t *testing.T) {
d := t.TempDir()
err := os.Chdir(d)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, os.Chdir(serverTestWD)) })
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
set.String("config-path", filepath.Join(serverTestWD, "..", "..", "config"), "")
set.Bool("privnet", true, "")
set.Bool("debug", true, "")
set.Int("height", 0, "")
ctx := cli.NewContext(cli.NewApp(), set, nil)
err = resetDB(ctx)
require.NoError(t, err)
}