prysm-pulse/spectest/shared/altair/epoch_processing/inactivity_updates.go
Preston Van Loon 5442d0f486
Altair: Merge passing hf1 tests and shared code (#9447)
* Altair: Merge passing hf1 tests and shared code

* Remove weird files

* del commented code

* Add dynamic file fetching, remove hardcoded list of files

* Remove hard coded paths

* remove hardcoded paths from phase0 too

* nosec fixes
2021-08-23 20:09:24 +00:00

42 lines
1.3 KiB
Go

package epoch_processing
import (
"context"
"path"
"testing"
"github.com/prysmaticlabs/prysm/beacon-chain/core/altair"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/prysmaticlabs/prysm/spectest/utils"
)
// RunInactivityUpdatesTest executes "epoch_processing/inactivity_updates" tests.
func RunInactivityUpdatesTest(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
testPath := "epoch_processing/inactivity_updates/pyspec_tests"
testFolders, testsFolderPath := utils.TestFolders(t, config, "altair", testPath)
for _, folder := range testFolders {
helpers.ClearCache()
t.Run(folder.Name(), func(t *testing.T) {
folderPath := path.Join(testsFolderPath, folder.Name())
RunEpochOperationTest(t, folderPath, processInactivityUpdates)
})
}
}
func processInactivityUpdates(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
ctx := context.Background()
vp, bp, err := altair.InitializeEpochValidators(ctx, st)
require.NoError(t, err)
vp, _, err = altair.ProcessEpochParticipation(ctx, st, bp, vp)
require.NoError(t, err)
st, _, err = altair.ProcessInactivityScores(ctx, st, vp)
require.NoError(t, err, "Could not process reward")
return st, nil
}