Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
define a constant for the error message so auctioneer can skip
Browse files Browse the repository at this point in the history
Signed-off-by: Merlin Ran <[email protected]>
  • Loading branch information
merlinran committed Sep 1, 2021
1 parent c045e53 commit 0c48cd6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/auction/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const (
// HTTPCarHeaderOnly is a HTTP header indicating that the bidbot wants
// only the CAR file header, as a hint to the HTTP server.
HTTPCarHeaderOnly = "X-Bidbot-Car-Header-Only"

// ErrStringWouldExceedRunningBytesLimit is the error message bidbot responds to wins
// message if proceeding with the bid would exceed the running bytes
// limit.
ErrStringWouldExceedRunningBytesLimit = "would exceed running bytes limit"
)

// BidID is a unique identifier for a Bid.
Expand Down
4 changes: 3 additions & 1 deletion service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ var (

// dataURIValidateTimeout is the timeout used when validating a data uri.
dataURIValidateTimeout = time.Minute

errWouldExceedRunningBytesLimit = errors.New(auction.ErrStringWouldExceedRunningBytesLimit)
)

// Config defines params for Service configuration.
Expand Down Expand Up @@ -492,7 +494,7 @@ func (s *Service) winsHandler(from core.ID, topic string, msg []byte) ([]byte, e
// the auction.
granted := s.bytesLimiter.Request(win.AuctionId, bid.DealSize, BidsExpiration)
if !granted {
return nil, errors.New("actively reject to avoid hitting running bytes limit")
return nil, errWouldExceedRunningBytesLimit
}
}

Expand Down
2 changes: 2 additions & 0 deletions service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ func TestBytesLimit(t *testing.T) {
if !expectGoodResponse {
require.Error(t, winsResponseError,
fmt.Sprintf("should have responded error for wins in auction %s", auctionID))
require.Equal(t, core.ErrStringWouldExceedRunningBytesLimit, winsResponseError.Error(),
fmt.Sprintf("should have responded expected error message in auction %s", auctionID))
} else {
require.NoError(t, winsResponseError,
fmt.Sprintf("should have had not error for wins in auction %s", auctionID))
Expand Down

0 comments on commit 0c48cd6

Please sign in to comment.