diff --git a/beacon-chain/db/kv/testing_helpers.go b/beacon-chain/db/kv/testing_helpers.go index 4844daaa78..80de48898e 100644 --- a/beacon-chain/db/kv/testing_helpers.go +++ b/beacon-chain/db/kv/testing_helpers.go @@ -2,6 +2,7 @@ package kv import ( "encoding/binary" + "testing" "go.etcd.io/bbolt" ) @@ -9,7 +10,7 @@ import ( // 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 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. err := s.db.Update(func(tx *bbolt.Tx) error { bucket := tx.Bucket(stateDiffBucket) @@ -21,6 +22,7 @@ func (s *Store) InitStateDiffCacheForTesting(offset uint64) error { binary.LittleEndian.PutUint64(offsetBytes, offset) return bucket.Put([]byte("offset"), offsetBytes) }) + if err != nil { return err } diff --git a/beacon-chain/state/stategen/migrate_test.go b/beacon-chain/state/stategen/migrate_test.go index 840048afd1..b965546e5e 100644 --- a/beacon-chain/state/stategen/migrate_test.go +++ b/beacon-chain/state/stategen/migrate_test.go @@ -251,7 +251,7 @@ func TestMigrateToColdHdiff_CanUpdateFinalizedInfo(t *testing.T) { setStateDiffExponents() beaconDB := testDB.SetupDB(t) // 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. resetCfg := features.InitWithReset(&features.Flags{EnableStateDiff: true}) defer resetCfg() @@ -307,7 +307,7 @@ func TestMigrateToColdHdiff_SkipsSlotsNotInDiffTree(t *testing.T) { setStateDiffExponents() beaconDB := testDB.SetupDB(t) // 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. resetCfg := features.InitWithReset(&features.Flags{EnableStateDiff: true}) defer resetCfg() @@ -359,7 +359,7 @@ func TestMigrateToColdHdiff_NoOpWhenFinalizedSlotNotAdvanced(t *testing.T) { setStateDiffExponents() beaconDB := testDB.SetupDB(t) // 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. resetCfg := features.InitWithReset(&features.Flags{EnableStateDiff: true}) defer resetCfg()