mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +00:00
2f11e55869
* use t.TempDir() * remove redundant delete * simplify setupDB() * simplify db/testing/setup_db * fix tests
26 lines
610 B
Go
26 lines
610 B
Go
package testing
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/validator/db"
|
|
"github.com/prysmaticlabs/prysm/validator/db/kv"
|
|
)
|
|
|
|
// SetupDB instantiates and returns a DB instance for the validator client.
|
|
func SetupDB(t testing.TB, pubkeys [][48]byte) db.Database {
|
|
db, err := kv.NewKVStore(t.TempDir(), pubkeys)
|
|
if err != nil {
|
|
t.Fatalf("Failed to instantiate DB: %v", err)
|
|
}
|
|
t.Cleanup(func() {
|
|
if err := db.Close(); err != nil {
|
|
t.Fatalf("Failed to close database: %v", err)
|
|
}
|
|
if err := db.ClearDB(); err != nil {
|
|
t.Fatalf("Failed to clear database: %v", err)
|
|
}
|
|
})
|
|
return db
|
|
}
|