mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 03:01:19 +00:00
5442d0f486
* 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
41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
package epoch_processing
|
|
|
|
import (
|
|
"context"
|
|
"path"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/altair"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
"github.com/prysmaticlabs/prysm/spectest/utils"
|
|
)
|
|
|
|
// RunJustificationAndFinalizationTests executes "epoch_processing/justification_and_finalization" tests.
|
|
func RunJustificationAndFinalizationTests(t *testing.T, config string) {
|
|
require.NoError(t, utils.SetConfig(t, config))
|
|
|
|
testPath := "epoch_processing/justification_and_finalization/pyspec_tests"
|
|
testFolders, testsFolderPath := utils.TestFolders(t, config, "altair", testPath)
|
|
for _, folder := range testFolders {
|
|
t.Run(folder.Name(), func(t *testing.T) {
|
|
folderPath := path.Join(testsFolderPath, folder.Name())
|
|
RunEpochOperationTest(t, folderPath, processJustificationAndFinalizationPrecomputeWrapper)
|
|
})
|
|
}
|
|
}
|
|
|
|
func processJustificationAndFinalizationPrecomputeWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
|
ctx := context.Background()
|
|
vp, bp, err := altair.InitializeEpochValidators(ctx, st)
|
|
require.NoError(t, err)
|
|
_, bp, err = altair.ProcessEpochParticipation(ctx, st, bp, vp)
|
|
require.NoError(t, err)
|
|
|
|
st, err = precompute.ProcessJustificationAndFinalizationPreCompute(st, bp)
|
|
require.NoError(t, err, "Could not process justification")
|
|
|
|
return st, nil
|
|
}
|