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 0bb7e2c
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 Down Expand Up @@ -150,6 +147,10 @@ func (s *DispersalServerV2) validateDispersalRequest(ctx context.Context, req *p
return api.NewErrorInvalidArg(fmt.Sprintf("invalid blob version %d; valid blob versions are: %v", blobHeaderProto.GetVersion(), onchainState.BlobVersionParameters.Keys()))
}

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

// handle payments and check rate limits
reservationPeriod := blobHeaderProto.GetPaymentHeader().GetReservationPeriod()
cumulativePayment := new(big.Int).SetBytes(blobHeaderProto.GetPaymentHeader().GetCumulativePayment())
Expand Down

0 comments on commit 0bb7e2c

Please sign in to comment.