2021-08-23 20:09:24 +00:00
|
|
|
package epoch_processing
|
|
|
|
|
|
|
|
import (
|
2021-09-26 15:27:57 +00:00
|
|
|
"context"
|
2021-08-23 20:09:24 +00:00
|
|
|
"path"
|
|
|
|
"testing"
|
|
|
|
|
2024-02-15 05:46:47 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/epoch"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/testing/spectest/utils"
|
2021-08-23 20:09:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// RunRegistryUpdatesTests executes "epoch_processing/registry_updates" tests.
|
|
|
|
func RunRegistryUpdatesTests(t *testing.T, config string) {
|
|
|
|
require.NoError(t, utils.SetConfig(t, config))
|
|
|
|
|
|
|
|
testFolders, testsFolderPath := utils.TestFolders(t, config, "altair", "epoch_processing/registry_updates/pyspec_tests")
|
2022-11-30 17:32:10 +00:00
|
|
|
if len(testFolders) == 0 {
|
|
|
|
t.Fatalf("No test folders found for %s/%s/%s", config, "altair", "epoch_processing/registry_updates/pyspec_tests")
|
|
|
|
}
|
2021-08-23 20:09:24 +00:00
|
|
|
for _, folder := range testFolders {
|
|
|
|
t.Run(folder.Name(), func(t *testing.T) {
|
2021-09-11 01:33:31 +00:00
|
|
|
// Important to clear cache for every test or else the old value of active validator count gets reused.
|
|
|
|
helpers.ClearCache()
|
2021-08-23 20:09:24 +00:00
|
|
|
folderPath := path.Join(testsFolderPath, folder.Name())
|
|
|
|
RunEpochOperationTest(t, folderPath, processRegistryUpdatesWrapper)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-23 21:10:19 +00:00
|
|
|
func processRegistryUpdatesWrapper(_ *testing.T, state state.BeaconState) (state.BeaconState, error) {
|
|
|
|
return epoch.ProcessRegistryUpdates(context.Background(), state)
|
2021-08-23 20:09:24 +00:00
|
|
|
}
|