Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Altair: Add sync committee spec test #8967

Merged
merged 1 commit into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spectest/mainnet/altair/operations/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ go_test(
"block_header_test.go",
"deposit_test.go",
"proposer_slashing_test.go",
"sync_committee_test.go",
"voluntary_exit_test.go",
],
data = glob(["*.yaml"]) + [
Expand Down
11 changes: 11 additions & 0 deletions spectest/mainnet/altair/operations/sync_committee_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package operations

import (
"testing"

"github.com/prysmaticlabs/prysm/spectest/shared/altair/operations"
)

func TestMainnet_Altair_Operations_SyncCommittee(t *testing.T) {
operations.RunSyncCommitteeTest(t, "mainnet")
}
1 change: 1 addition & 0 deletions spectest/minimal/altair/operations/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ go_test(
"block_header_test.go",
"deposit_test.go",
"proposer_slashing_test.go",
"sync_committee_test.go",
"voluntary_exit_test.go",
],
data = glob(["*.yaml"]) + [
Expand Down
11 changes: 11 additions & 0 deletions spectest/minimal/altair/operations/sync_committee_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package operations

import (
"testing"

"github.com/prysmaticlabs/prysm/spectest/shared/altair/operations"
)

func TestMinimal_Altair_Operations_SyncCommittee(t *testing.T) {
operations.RunProposerSlashingTest(t, "minimal")
}
1 change: 1 addition & 0 deletions spectest/shared/altair/operations/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ go_library(
"deposit.go",
"helpers.go",
"proposer_slashing.go",
"sync_committee.go",
"voluntary_exit.go",
],
importpath = "github.com/prysmaticlabs/prysm/spectest/shared/altair/operations",
Expand Down
37 changes: 37 additions & 0 deletions spectest/shared/altair/operations/sync_committee.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package operations

import (
"context"
"path"
"testing"

"github.com/golang/snappy"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/beacon-chain/core/altair"
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
"github.com/prysmaticlabs/prysm/shared/interfaces"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/prysmaticlabs/prysm/spectest/utils"
)

func RunSyncCommitteeTest(t *testing.T, config string) {
require.NoError(t, utils.SetConfig(t, config))
testFolders, testsFolderPath := utils.TestFolders(t, config, "altair", "operations/sync_committee/pyspec_tests")
for _, folder := range testFolders {
t.Run(folder.Name(), func(t *testing.T) {
folderPath := path.Join(testsFolderPath, folder.Name())
syncCommitteeFile, err := testutil.BazelFileBytes(folderPath, "sync_aggregate.ssz_snappy")
require.NoError(t, err)
syncCommitteeSSZ, err := snappy.Decode(nil /* dst */, syncCommitteeFile)
require.NoError(t, err, "Failed to decompress")
sc := &ethpb.SyncAggregate{}
require.NoError(t, sc.UnmarshalSSZ(syncCommitteeSSZ), "Failed to unmarshal")

body := &ethpb.BeaconBlockBodyAltair{SyncAggregate: sc}
RunBlockOperationTest(t, folderPath, body, func(ctx context.Context, s iface.BeaconState, b interfaces.SignedBeaconBlock) (iface.BeaconState, error) {
return altair.ProcessSyncCommittee(s, body.SyncAggregate)
})
})
}
}