prysm-pulse/validator/db/testing/setup_db.go
Raul Jordan 36b6a71af4
Configurable DB Mmap Size for Beacon Node and Validator Client (#8448)
* add flag to beacon and validator

* gaz

* fuzz

* add dep viz

* add to tools
2021-02-15 20:29:47 +00:00

29 lines
682 B
Go

package testing
import (
"context"
"testing"
"github.com/prysmaticlabs/prysm/validator/db/iface"
"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) iface.ValidatorDB {
db, err := kv.NewKVStore(context.Background(), t.TempDir(), &kv.Config{
PubKeys: 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
}