2020-02-13 09:19:46 -07:00
|
|
|
package testing
|
2019-09-26 21:59:10 +05:30
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2020-12-03 16:28:57 -06:00
|
|
|
"path/filepath"
|
2019-09-26 21:59:10 +05:30
|
|
|
"testing"
|
2020-05-04 04:14:34 +03:00
|
|
|
|
2020-08-18 15:41:25 +03:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
2020-05-04 04:14:34 +03:00
|
|
|
slasherDB "github.com/prysmaticlabs/prysm/slasher/db"
|
|
|
|
"github.com/prysmaticlabs/prysm/slasher/db/kv"
|
2019-09-26 21:59:10 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
func TestClearDB(t *testing.T) {
|
2020-05-04 04:14:34 +03:00
|
|
|
// Setting up manually is required, since SetupDB() will also register a teardown procedure.
|
|
|
|
cfg := &kv.Config{}
|
2020-11-11 01:45:17 +03:00
|
|
|
db, err := slasherDB.NewDB(t.TempDir(), cfg)
|
2020-08-18 15:41:25 +03:00
|
|
|
require.NoError(t, err, "Failed to instantiate DB")
|
2020-05-29 15:09:04 +03:00
|
|
|
db.EnableSpanCache(false)
|
2020-08-18 15:41:25 +03:00
|
|
|
require.NoError(t, db.ClearDB())
|
2020-12-03 16:28:57 -06:00
|
|
|
_, err = os.Stat(filepath.Join(db.DatabasePath(), "slasher.db"))
|
2020-08-18 15:41:25 +03:00
|
|
|
require.Equal(t, true, os.IsNotExist(err), "Db wasnt cleared %v", err)
|
2019-09-26 21:59:10 +05:30
|
|
|
}
|