Skip to content

Commit fb94a5e

Browse files
committed
Add test for fetching duplicate indices
1 parent 8b58d7e commit fb94a5e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

api/service/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,14 @@ func filterBlobs(blobs []*deneb.BlobSidecar, indices string) ([]*deneb.BlobSidec
218218
return blobs, nil
219219
}
220220

221-
indicesMap := map[deneb.BlobIndex]bool{}
221+
indicesMap := map[deneb.BlobIndex]struct{}{}
222222
for _, index := range splits {
223223
parsedInt, err := strconv.ParseUint(index, 10, 64)
224224
if err != nil {
225225
return nil, newIndicesError(index)
226226
}
227227
blobIndex := deneb.BlobIndex(parsedInt)
228-
indicesMap[blobIndex] = true
228+
indicesMap[blobIndex] = struct{}{}
229229
}
230230

231231
filteredBlobs := make([]*deneb.BlobSidecar, 0)

api/service/api_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,16 @@ func TestAPIService(t *testing.T) {
162162
},
163163
},
164164
},
165+
{
166+
name: "deduplicates indices",
167+
path: "/eth/v1/beacon/blob_sidecars/1234?indices=1,1,1",
168+
status: 200,
169+
expected: &storage.BlobSidecars{
170+
Data: []*deneb.BlobSidecar{
171+
blockTwo.BlobSidecars.Data[1],
172+
},
173+
},
174+
},
165175
{
166176
name: "indices out of bounds returns empty array",
167177
path: "/eth/v1/beacon/blob_sidecars/1234?indices=3",

0 commit comments

Comments
 (0)