Skip to content

Commit

Permalink
fix: reorder auth checks for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Dec 18, 2024
1 parent c923767 commit 11eec21
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions disperser/apiserver/disperse_blob_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ func (s *DispersalServerV2) validateDispersalRequest(ctx context.Context, req *p
if blobHeader.PaymentMetadata == (core.PaymentMetadata{}) {
return api.NewErrorInvalidArg("payment metadata is required")
}
if err = s.authenticator.AuthenticateBlobRequest(blobHeader); err != nil {
return api.NewErrorInvalidArg(fmt.Sprintf("authentication failed: %s", err.Error()))
}

if len(blobHeader.PaymentMetadata.AccountID) == 0 || blobHeader.PaymentMetadata.ReservationPeriod == 0 || blobHeader.PaymentMetadata.CumulativePayment == nil {
return api.NewErrorInvalidArg("invalid payment metadata")
Expand All @@ -139,6 +136,10 @@ func (s *DispersalServerV2) validateDispersalRequest(ctx context.Context, req *p
}
}

if err = s.authenticator.AuthenticateBlobRequest(blobHeader); err != nil {
return api.NewErrorInvalidArg(fmt.Sprintf("authentication failed: %s", err.Error()))
}

// validate every 32 bytes is a valid field element
_, err = rs.ToFrArray(data)
if err != nil {
Expand Down

0 comments on commit 11eec21

Please sign in to comment.