mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 04:54:05 -05:00
Change signature of testing helper
This commit is contained in:
@@ -2,6 +2,7 @@ package kv
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
)
|
)
|
||||||
@@ -9,7 +10,7 @@ import (
|
|||||||
// InitStateDiffCacheForTesting initializes the state diff cache with the given offset.
|
// InitStateDiffCacheForTesting initializes the state diff cache with the given offset.
|
||||||
// This is intended for testing purposes when setting up state diff after database creation.
|
// This is intended for testing purposes when setting up state diff after database creation.
|
||||||
// This file is only compiled when the "testing" build tag is set.
|
// This file is only compiled when the "testing" build tag is set.
|
||||||
func (s *Store) InitStateDiffCacheForTesting(offset uint64) error {
|
func (s *Store) InitStateDiffCacheForTesting(t testing.TB, offset uint64) error {
|
||||||
// First, set the offset in the database.
|
// First, set the offset in the database.
|
||||||
err := s.db.Update(func(tx *bbolt.Tx) error {
|
err := s.db.Update(func(tx *bbolt.Tx) error {
|
||||||
bucket := tx.Bucket(stateDiffBucket)
|
bucket := tx.Bucket(stateDiffBucket)
|
||||||
@@ -21,6 +22,7 @@ func (s *Store) InitStateDiffCacheForTesting(offset uint64) error {
|
|||||||
binary.LittleEndian.PutUint64(offsetBytes, offset)
|
binary.LittleEndian.PutUint64(offsetBytes, offset)
|
||||||
return bucket.Put([]byte("offset"), offsetBytes)
|
return bucket.Put([]byte("offset"), offsetBytes)
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ func TestMigrateToColdHdiff_CanUpdateFinalizedInfo(t *testing.T) {
|
|||||||
setStateDiffExponents()
|
setStateDiffExponents()
|
||||||
beaconDB := testDB.SetupDB(t)
|
beaconDB := testDB.SetupDB(t)
|
||||||
// Initialize the state diff cache via the method on *kv.Store (not in interface).
|
// Initialize the state diff cache via the method on *kv.Store (not in interface).
|
||||||
require.NoError(t, beaconDB.(*kv.Store).InitStateDiffCacheForTesting(0))
|
require.NoError(t, beaconDB.(*kv.Store).InitStateDiffCacheForTesting(t, 0))
|
||||||
// Now enable the feature flag.
|
// Now enable the feature flag.
|
||||||
resetCfg := features.InitWithReset(&features.Flags{EnableStateDiff: true})
|
resetCfg := features.InitWithReset(&features.Flags{EnableStateDiff: true})
|
||||||
defer resetCfg()
|
defer resetCfg()
|
||||||
@@ -307,7 +307,7 @@ func TestMigrateToColdHdiff_SkipsSlotsNotInDiffTree(t *testing.T) {
|
|||||||
setStateDiffExponents()
|
setStateDiffExponents()
|
||||||
beaconDB := testDB.SetupDB(t)
|
beaconDB := testDB.SetupDB(t)
|
||||||
// Initialize the state diff cache via the method on *kv.Store (not in interface).
|
// Initialize the state diff cache via the method on *kv.Store (not in interface).
|
||||||
require.NoError(t, beaconDB.(*kv.Store).InitStateDiffCacheForTesting(0))
|
require.NoError(t, beaconDB.(*kv.Store).InitStateDiffCacheForTesting(t, 0))
|
||||||
// Now enable the feature flag.
|
// Now enable the feature flag.
|
||||||
resetCfg := features.InitWithReset(&features.Flags{EnableStateDiff: true})
|
resetCfg := features.InitWithReset(&features.Flags{EnableStateDiff: true})
|
||||||
defer resetCfg()
|
defer resetCfg()
|
||||||
@@ -359,7 +359,7 @@ func TestMigrateToColdHdiff_NoOpWhenFinalizedSlotNotAdvanced(t *testing.T) {
|
|||||||
setStateDiffExponents()
|
setStateDiffExponents()
|
||||||
beaconDB := testDB.SetupDB(t)
|
beaconDB := testDB.SetupDB(t)
|
||||||
// Initialize the state diff cache via the method on *kv.Store (not in interface).
|
// Initialize the state diff cache via the method on *kv.Store (not in interface).
|
||||||
require.NoError(t, beaconDB.(*kv.Store).InitStateDiffCacheForTesting(0))
|
require.NoError(t, beaconDB.(*kv.Store).InitStateDiffCacheForTesting(t, 0))
|
||||||
// Now enable the feature flag.
|
// Now enable the feature flag.
|
||||||
resetCfg := features.InitWithReset(&features.Flags{EnableStateDiff: true})
|
resetCfg := features.InitWithReset(&features.Flags{EnableStateDiff: true})
|
||||||
defer resetCfg()
|
defer resetCfg()
|
||||||
|
|||||||
Reference in New Issue
Block a user