2020-06-27 02:37:43 +00:00
|
|
|
package testing
|
2020-01-08 18:16:17 +00:00
|
|
|
|
|
|
|
import (
|
2020-12-11 18:31:35 +00:00
|
|
|
"context"
|
2020-01-08 18:16:17 +00:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
2020-06-27 02:37:43 +00:00
|
|
|
|
2021-09-23 18:53:46 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
2020-06-27 02:37:43 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/validator/db/kv"
|
2020-01-08 18:16:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestClearDB(t *testing.T) {
|
2020-05-04 01:14:34 +00:00
|
|
|
// Setting up manually is required, since SetupDB() will also register a teardown procedure.
|
2021-02-15 20:29:47 +00:00
|
|
|
testDB, err := kv.NewKVStore(context.Background(), t.TempDir(), &kv.Config{
|
|
|
|
PubKeys: nil,
|
|
|
|
})
|
2020-07-23 01:13:52 +00:00
|
|
|
require.NoError(t, err, "Failed to instantiate DB")
|
|
|
|
require.NoError(t, testDB.ClearDB())
|
2020-01-08 18:16:17 +00:00
|
|
|
|
2020-06-27 02:37:43 +00:00
|
|
|
if _, err := os.Stat(filepath.Join(testDB.DatabasePath(), "validator.db")); !os.IsNotExist(err) {
|
2020-01-08 18:16:17 +00:00
|
|
|
t.Fatalf("DB was not cleared: %v", err)
|
|
|
|
}
|
|
|
|
}
|