prysm-pulse/validator/db/testing/setup_db.go
Raul Jordan 1fbfd52e52
Simpler and Safer Attester Slashing Protection (#8086)
* att sign validations

* eliminate old cached methods and use a simple approach in the db

* redefined db methods

* db package builds

* add multilock to attest and propose

* gaz

* removed concurrency tests that are no longer relevant

* add cache to db functions for attesting history checks

* passing

* add in feature flag --disable-attesting-history-db-cache

* remove lock

* Revert "remove lock"

This reverts commit b1a65020e406b9fa6e4f57c5cc6a5a0b2a11a240.

* comment

* gaz
2020-12-11 12:31:35 -06:00

27 lines
643 B
Go

package testing
import (
"context"
"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(context.Background(), 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
}