-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidation spectests from electra
WIP: epoch_processing pending_consolidations, currently failing WIP: Tests
- Loading branch information
1 parent
4bbd799
commit de6f522
Showing
15 changed files
with
146 additions
and
2 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
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package electra_test | ||
|
||
import "testing" | ||
|
||
func TestProcessPendingConsolidations(t *testing.T) { | ||
t.Fail() | ||
} | ||
|
||
func TestProcessConsolidations(t *testing.T) { | ||
t.Fail() | ||
} |
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
11 changes: 11 additions & 0 deletions
11
testing/spectest/mainnet/electra/epoch_processing/pending_consolidations_test.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package epoch_processing | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/prysmaticlabs/prysm/v5/testing/spectest/shared/electra/epoch_processing" | ||
) | ||
|
||
func TestMainnet_Electra_EpochProcessing_PendingConsolidations(t *testing.T) { | ||
epoch_processing.RunPendingConsolidationsTests(t, "mainnet") | ||
} |
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
11 changes: 11 additions & 0 deletions
11
testing/spectest/mainnet/electra/operations/consolidation_test.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package operations | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/prysmaticlabs/prysm/v5/testing/spectest/shared/electra/operations" | ||
) | ||
|
||
func TestMainnet_Electra_Operations_Consolidation(t *testing.T) { | ||
operations.RunConsolidationTest(t, "mainnet") | ||
} |
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
11 changes: 11 additions & 0 deletions
11
testing/spectest/minimal/electra/epoch_processing/pending_consolidations_test.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package epoch_processing | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/prysmaticlabs/prysm/v5/testing/spectest/shared/electra/epoch_processing" | ||
) | ||
|
||
func TestMinimal_Electra_EpochProcessing_PendingConsolidations(t *testing.T) { | ||
epoch_processing.RunPendingConsolidationsTests(t, "minimal") | ||
} |
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
11 changes: 11 additions & 0 deletions
11
testing/spectest/minimal/electra/operations/consolidation_test.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package operations | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/prysmaticlabs/prysm/v5/testing/spectest/shared/electra/operations" | ||
) | ||
|
||
func TestMinimal_Electra_Operations_Consolidation(t *testing.T) { | ||
operations.RunConsolidationTest(t, "minimal") | ||
} |
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
28 changes: 28 additions & 0 deletions
28
testing/spectest/shared/electra/epoch_processing/pending_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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package epoch_processing | ||
|
||
import ( | ||
"context" | ||
"path" | ||
"testing" | ||
|
||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/electra" | ||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state" | ||
"github.com/prysmaticlabs/prysm/v5/testing/require" | ||
"github.com/prysmaticlabs/prysm/v5/testing/spectest/utils" | ||
) | ||
|
||
func RunPendingConsolidationsTests(t *testing.T, config string) { | ||
require.NoError(t, utils.SetConfig(t, config)) | ||
|
||
testFolders, testsFolderPath := utils.TestFolders(t, config, "electra", "epoch_processing/pending_consolidations/pyspec_tests") | ||
for _, folder := range testFolders { | ||
t.Run(folder.Name(), func(t *testing.T) { | ||
folderPath := path.Join(testsFolderPath, folder.Name()) | ||
RunEpochOperationTest(t, folderPath, processPendingConsolidations) | ||
}) | ||
} | ||
} | ||
|
||
func processPendingConsolidations(t *testing.T, st state.BeaconState) (state.BeaconState, error) { | ||
return electra.ProcessPendingConsolidations(context.TODO(), st) | ||
} |
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
48 changes: 48 additions & 0 deletions
48
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
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" | ||
ethpb "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("These tests were temporarily deleted in v1.5.0-alpha.2. See https://github.com/ethereum/consensus-specs/pull/3736") | ||
require.NoError(t, utils.SetConfig(t, config)) | ||
testFolders, testsFolderPath := utils.TestFolders(t, config, "electra", "operations/consolidation/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") | ||
require.NoError(t, err) | ||
consolidationSSZ, err := snappy.Decode(nil /* dst */, consolidationFile) | ||
require.NoError(t, err, "Failed to decompress") | ||
consolidation := ðpb.SignedConsolidation{} | ||
require.NoError(t, consolidation.UnmarshalSSZ(consolidationSSZ), "Failed to unmarshal") | ||
|
||
body := ðpb.BeaconBlockBodyElectra{Consolidations: []*ethpb.SignedConsolidation{consolidation}} | ||
processConsolidationFunc := func(ctx context.Context, s state.BeaconState, b interfaces.SignedBeaconBlock) (state.BeaconState, error) { | ||
body, ok := b.Block().Body().(interfaces.ROBlockBodyElectra) | ||
if !ok { | ||
t.Error("block body is not electra") | ||
} | ||
cs := body.Consolidations() | ||
if len(cs) == 0 { | ||
t.Error("no consolidations to test") | ||
} | ||
return electra.ProcessConsolidations(ctx, s, cs) | ||
} | ||
RunBlockOperationTest(t, folderPath, body, processConsolidationFunc) | ||
}) | ||
} | ||
} |