prysm-pulse/validator/db/kv/db_test.go
Raul Jordan d97596348e
Add Back New Attester Protection DB Logic (#8242)
* Revert "Revert New Attester Protection DB Logic (#8237)"

This reverts commit 6738fa3493.

* Batch Attestation Records and Flush All at Once in Validator DB (#8243)

* begin flushing logic

* finalize logic before starting tests

* make code DRY

* better log fields

* gaz

* tweak parameter

* rename

* clarifying comment on error handling in event feed

* comprehensive tests

* more comments

* explain parameters in comments

* renamed consts

* Apply suggestions from code review

* gaz

* simplify

* typo

* comments
2021-01-11 23:59:17 +00:00

31 lines
790 B
Go

package kv
import (
"context"
"io/ioutil"
"testing"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/sirupsen/logrus"
)
func TestMain(m *testing.M) {
logrus.SetLevel(logrus.DebugLevel)
logrus.SetOutput(ioutil.Discard)
m.Run()
}
// setupDB instantiates and returns a DB instance for the validator client.
func setupDB(t testing.TB, pubkeys [][48]byte) *Store {
db, err := NewKVStore(context.Background(), t.TempDir(), pubkeys)
require.NoError(t, err, "Failed to instantiate DB")
err = db.UpdatePublicKeysBuckets(pubkeys)
require.NoError(t, err, "Failed to create old buckets for public keys")
t.Cleanup(func() {
require.NoError(t, db.Close(), "Failed to close database")
require.NoError(t, db.ClearDB(), "Failed to clear database")
})
return db
}