package operations import ( "path" "testing" "github.com/golang/snappy" ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" ) // RunAttestationTest executes "operations/attestation" tests. func RunAttestationTest(t *testing.T, config string) { require.NoError(t, utils.SetConfig(t, config)) testFolders, testsFolderPath := utils.TestFolders(t, config, "phase0", "operations/attestation/pyspec_tests") for _, folder := range testFolders { t.Run(folder.Name(), func(t *testing.T) { folderPath := path.Join(testsFolderPath, folder.Name()) attestationFile, err := testutil.BazelFileBytes(folderPath, "attestation.ssz_snappy") require.NoError(t, err) attestationSSZ, err := snappy.Decode(nil /* dst */, attestationFile) require.NoError(t, err, "Failed to decompress") att := ðpb.Attestation{} require.NoError(t, att.UnmarshalSSZ(attestationSSZ), "Failed to unmarshal") body := ðpb.BeaconBlockBody{Attestations: []*ethpb.Attestation{att}} RunBlockOperationTest(t, folderPath, body, blocks.ProcessAttestations) }) } }