2020-06-27 02:37:43 +00:00
|
|
|
package kv
|
2020-01-08 18:16:17 +00:00
|
|
|
|
|
|
|
import (
|
2020-12-11 18:31:35 +00:00
|
|
|
"context"
|
2021-01-11 23:59:17 +00:00
|
|
|
"io/ioutil"
|
2020-01-08 18:16:17 +00:00
|
|
|
"testing"
|
2020-06-26 14:58:47 +00:00
|
|
|
|
2020-07-23 01:13:52 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
2021-01-11 23:59:17 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2020-01-08 18:16:17 +00:00
|
|
|
)
|
|
|
|
|
2021-01-11 23:59:17 +00:00
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
|
|
logrus.SetOutput(ioutil.Discard)
|
|
|
|
|
|
|
|
m.Run()
|
|
|
|
}
|
|
|
|
|
2020-06-27 02:37:43 +00:00
|
|
|
// setupDB instantiates and returns a DB instance for the validator client.
|
|
|
|
func setupDB(t testing.TB, pubkeys [][48]byte) *Store {
|
2021-02-15 20:29:47 +00:00
|
|
|
db, err := NewKVStore(context.Background(), t.TempDir(), &Config{
|
|
|
|
PubKeys: pubkeys,
|
|
|
|
})
|
2020-07-23 01:13:52 +00:00
|
|
|
require.NoError(t, err, "Failed to instantiate DB")
|
2020-11-26 16:50:55 +00:00
|
|
|
err = db.UpdatePublicKeysBuckets(pubkeys)
|
2020-10-15 19:35:31 +00:00
|
|
|
require.NoError(t, err, "Failed to create old buckets for public keys")
|
2020-05-04 01:14:34 +00:00
|
|
|
t.Cleanup(func() {
|
2020-07-23 01:13:52 +00:00
|
|
|
require.NoError(t, db.Close(), "Failed to close database")
|
|
|
|
require.NoError(t, db.ClearDB(), "Failed to clear database")
|
2020-05-04 01:14:34 +00:00
|
|
|
})
|
2020-01-08 18:16:17 +00:00
|
|
|
return db
|
|
|
|
}
|