package ssz_static import ( "errors" "testing" fssz "github.com/prysmaticlabs/fastssz" enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1" ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" common "github.com/prysmaticlabs/prysm/v4/testing/spectest/shared/common/ssz_static" ) // RunSSZStaticTests executes "ssz_static" tests. func RunSSZStaticTests(t *testing.T, config string) { t.Skip("skipping tests at commit with incompatible ssz schema") common.RunSSZStaticTests(t, config, "deneb", unmarshalledSSZ, nil) } // unmarshalledSSZ unmarshalls serialized input. func unmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (interface{}, error) { var obj interface{} switch folderName { case "ExecutionPayload": obj = &enginev1.ExecutionPayloadDeneb{} case "ExecutionPayloadHeader": obj = &enginev1.ExecutionPayloadHeaderDeneb{} case "Attestation": obj = ðpb.Attestation{} case "AttestationData": obj = ðpb.AttestationData{} case "AttesterSlashing": obj = ðpb.AttesterSlashing{} case "AggregateAndProof": obj = ðpb.AggregateAttestationAndProof{} case "BeaconBlock": obj = ðpb.BeaconBlockDeneb{} case "BeaconBlockBody": obj = ðpb.BeaconBlockBodyDeneb{} case "BeaconBlockHeader": obj = ðpb.BeaconBlockHeader{} case "BeaconState": obj = ðpb.BeaconStateDeneb{} case "Checkpoint": obj = ðpb.Checkpoint{} case "Deposit": obj = ðpb.Deposit{} case "DepositMessage": obj = ðpb.DepositMessage{} case "DepositData": obj = ðpb.Deposit_Data{} case "Eth1Data": obj = ðpb.Eth1Data{} case "Eth1Block": t.Skip("Unused type") return nil, nil case "Fork": obj = ðpb.Fork{} case "ForkData": obj = ðpb.ForkData{} case "HistoricalBatch": obj = ðpb.HistoricalBatch{} case "IndexedAttestation": obj = ðpb.IndexedAttestation{} case "PendingAttestation": obj = ðpb.PendingAttestation{} case "ProposerSlashing": obj = ðpb.ProposerSlashing{} case "SignedAggregateAndProof": obj = ðpb.SignedAggregateAttestationAndProof{} case "SignedBeaconBlock": obj = ðpb.SignedBeaconBlockDeneb{} case "SignedBeaconBlockHeader": obj = ðpb.SignedBeaconBlockHeader{} case "SignedVoluntaryExit": obj = ðpb.SignedVoluntaryExit{} case "SigningData": obj = ðpb.SigningData{} case "Validator": obj = ðpb.Validator{} case "VoluntaryExit": obj = ðpb.VoluntaryExit{} case "SyncCommitteeMessage": obj = ðpb.SyncCommitteeMessage{} case "SyncCommitteeContribution": obj = ðpb.SyncCommitteeContribution{} case "ContributionAndProof": obj = ðpb.ContributionAndProof{} case "SignedContributionAndProof": obj = ðpb.SignedContributionAndProof{} case "SyncAggregate": obj = ðpb.SyncAggregate{} case "SyncAggregatorSelectionData": obj = ðpb.SyncAggregatorSelectionData{} case "SyncCommittee": obj = ðpb.SyncCommittee{} case "LightClientOptimisticUpdate": t.Skip("not a beacon node type, this is a light node type") return nil, nil case "LightClientFinalityUpdate": t.Skip("not a beacon node type, this is a light node type") return nil, nil case "LightClientBootstrap": t.Skip("not a beacon node type, this is a light node type") return nil, nil case "LightClientSnapshot": t.Skip("not a beacon node type, this is a light node type") return nil, nil case "LightClientUpdate": t.Skip("not a beacon node type, this is a light node type") return nil, nil case "LightClientHeader": t.Skip("not a beacon node type, this is a light node type") return nil, nil case "BlobIdentifier": obj = ðpb.BlobIdentifier{} case "BlobSidecar": obj = ðpb.BlobSidecar{} case "SignedBlobSidecar": obj = ðpb.SignedBlobSidecar{} case "PowBlock": obj = ðpb.PowBlock{} case "Withdrawal": obj = &enginev1.Withdrawal{} case "HistoricalSummary": obj = ðpb.HistoricalSummary{} case "BLSToExecutionChange": obj = ðpb.BLSToExecutionChange{} case "SignedBLSToExecutionChange": obj = ðpb.SignedBLSToExecutionChange{} default: return nil, errors.New("type not found") } var err error if o, ok := obj.(fssz.Unmarshaler); ok { err = o.UnmarshalSSZ(serializedBytes) } else { err = errors.New("could not unmarshal object, not a fastssz compatible object") } return obj, err }