Skip to content

Commit

Permalink
handling case
Browse files Browse the repository at this point in the history
  • Loading branch information
james-prysm committed Jan 30, 2025
1 parent 4ce8d67 commit 8268f02
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions beacon-chain/rpc/eth/blob/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func (s *Server) Blobs(w http.ResponseWriter, r *http.Request) {
httputil.HandleError(w, "Could not fetch block: "+err.Error(), http.StatusInternalServerError)
return
}
if blk == nil {
httputil.HandleError(w, "Block not found", http.StatusNotFound)
return
}

if httputil.RespondWithSsz(r) {
sszResp, err := buildSidecarsSSZResponse(verifiedBlobs)
Expand Down
17 changes: 17 additions & 0 deletions beacon-chain/rpc/eth/blob/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,23 @@ func TestBlobs(t *testing.T) {
require.Equal(t, false, resp.ExecutionOptimistic)
require.Equal(t, false, resp.Finalized)
})
t.Run("slot not found", func(t *testing.T) {
u := "http://foo.example/122"
request := httptest.NewRequest("GET", u, nil)
writer := httptest.NewRecorder()
writer.Body = &bytes.Buffer{}
s.Blocker = &lookup.BeaconDbBlocker{
ChainInfoFetcher: &mockChain.ChainService{Block: denebBlock},
BeaconDB: db,
GenesisTimeFetcher: &testutil.MockGenesisTimeFetcher{
Genesis: time.Now(),
},
BlobStorage: bs,
}
s.Blobs(writer, request)

assert.Equal(t, http.StatusNotFound, writer.Code)
})
t.Run("one blob only", func(t *testing.T) {
u := "http://foo.example/123?indices=2"
request := httptest.NewRequest("GET", u, nil)
Expand Down

0 comments on commit 8268f02

Please sign in to comment.