2019-08-12 19:33:07 +00:00
|
|
|
package kv
|
|
|
|
|
|
|
|
import (
|
2020-12-15 22:07:01 +00:00
|
|
|
"context"
|
2019-08-12 19:33:07 +00:00
|
|
|
"testing"
|
|
|
|
|
2022-08-16 12:20:13 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v3/config/features"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
2022-07-13 17:18:30 +00:00
|
|
|
bolt "go.etcd.io/bbolt"
|
2019-08-12 19:33:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// setupDB instantiates and returns a Store instance.
|
|
|
|
func setupDB(t testing.TB) *Store {
|
2022-08-17 12:22:41 +00:00
|
|
|
db, err := NewKVStore(context.Background(), t.TempDir())
|
2020-08-08 18:39:01 +00:00
|
|
|
require.NoError(t, err, "Failed to instantiate DB")
|
2020-05-04 01:14:34 +00:00
|
|
|
t.Cleanup(func() {
|
2020-08-08 18:39:01 +00:00
|
|
|
require.NoError(t, db.Close(), "Failed to close database")
|
2020-05-04 01:14:34 +00:00
|
|
|
})
|
2019-08-12 19:33:07 +00:00
|
|
|
return db
|
|
|
|
}
|
2022-07-13 17:18:30 +00:00
|
|
|
|
|
|
|
func Test_checkNeedsResync(t *testing.T) {
|
|
|
|
store := setupDB(t)
|
|
|
|
resetFn := features.InitWithReset(&features.Flags{
|
|
|
|
EnableOnlyBlindedBeaconBlocks: false,
|
|
|
|
})
|
|
|
|
defer resetFn()
|
|
|
|
require.NoError(t, store.db.Update(func(tx *bolt.Tx) error {
|
|
|
|
bkt := tx.Bucket(migrationsBucket)
|
|
|
|
return bkt.Put(migrationBlindedBeaconBlocksKey, migrationCompleted)
|
|
|
|
}))
|
|
|
|
err := store.checkNeedsResync()
|
|
|
|
require.ErrorContains(t, "your node must resync", err)
|
|
|
|
}
|