-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable consolidation_request spectests
- Loading branch information
1 parent
0ec068d
commit 0e7772a
Showing
2 changed files
with
21 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 21 additions & 4 deletions
25
testing/spectest/shared/electra/operations/consolidations.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,49 @@ | ||
package operations | ||
|
||
import ( | ||
"context" | ||
"path" | ||
"testing" | ||
|
||
"github.com/golang/snappy" | ||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/electra" | ||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state" | ||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces" | ||
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" | ||
eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" | ||
"github.com/prysmaticlabs/prysm/v5/testing/require" | ||
"github.com/prysmaticlabs/prysm/v5/testing/spectest/utils" | ||
"github.com/prysmaticlabs/prysm/v5/testing/util" | ||
) | ||
|
||
func RunConsolidationTest(t *testing.T, config string) { | ||
t.Skip("Failing until spectests are updated to v1.5.0-alpha.3") | ||
require.NoError(t, utils.SetConfig(t, config)) | ||
testFolders, testsFolderPath := utils.TestFolders(t, config, "electra", "operations/consolidation/pyspec_tests") | ||
testFolders, testsFolderPath := utils.TestFolders(t, config, "electra", "operations/consolidation_request/pyspec_tests") | ||
require.NotEqual(t, 0, len(testFolders), "missing tests for consolidation operation in folder") | ||
for _, folder := range testFolders { | ||
t.Run(folder.Name(), func(t *testing.T) { | ||
folderPath := path.Join(testsFolderPath, folder.Name()) | ||
consolidationFile, err := util.BazelFileBytes(folderPath, "consolidation.ssz_snappy") | ||
consolidationFile, err := util.BazelFileBytes(folderPath, "consolidation_request.ssz_snappy") | ||
require.NoError(t, err) | ||
consolidationSSZ, err := snappy.Decode(nil /* dst */, consolidationFile) | ||
require.NoError(t, err, "Failed to decompress") | ||
consolidation := &enginev1.ConsolidationRequest{} | ||
require.NoError(t, consolidation.UnmarshalSSZ(consolidationSSZ), "Failed to unmarshal") | ||
|
||
t.Fatal("Implement me") | ||
body := ð.BeaconBlockBodyElectra{ExecutionPayload: &enginev1.ExecutionPayloadElectra{ | ||
ConsolidationRequests: []*enginev1.ConsolidationRequest{consolidation}, | ||
}} | ||
RunBlockOperationTest(t, folderPath, body, func(ctx context.Context, s state.BeaconState, b interfaces.ReadOnlySignedBeaconBlock) (state.BeaconState, error) { | ||
ed, err := b.Block().Body().Execution() | ||
if err != nil { | ||
return nil, err | ||
} | ||
eed, ok := ed.(interfaces.ExecutionDataElectra) | ||
if !ok { | ||
t.Fatal("block does not have execution data for electra") | ||
} | ||
return s, electra.ProcessConsolidationRequests(ctx, s, eed.ConsolidationRequests()) | ||
}) | ||
}) | ||
} | ||
} |