Skip to content

Commit

Permalink
better answer message on ErrNotFound
Browse files Browse the repository at this point in the history
  • Loading branch information
nonsense committed Mar 8, 2022
1 parent b328bea commit 5e7372b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions retrievalmarket/impl/integration_test.go
Expand Up @@ -59,6 +59,7 @@ func TestClientCanMakeQueryToProvider(t *testing.T) {
t.Run("when piece is not found, returns unavailable", func(t *testing.T) {
expectedQR.PieceCIDFound = retrievalmarket.QueryItemUnavailable
expectedQR.Status = retrievalmarket.QueryResponseUnavailable
expectedQR.Message = "piece info for cid not found (deal has not been added to a piece yet)"
expectedQR.Size = 0
actualQR, err := client.Query(bgCtx, retrievalPeer, missingPiece, retrievalmarket.QueryParams{})
actualQR.MaxPaymentInterval = expectedQR.MaxPaymentInterval
Expand Down
2 changes: 2 additions & 0 deletions retrievalmarket/impl/provider.go
Expand Up @@ -344,6 +344,8 @@ func (p *Provider) HandleQueryStream(stream rmnet.RetrievalQueryStream) {
if !xerrors.Is(err, retrievalmarket.ErrNotFound) {
answer.Status = retrievalmarket.QueryResponseError
answer.Message = fmt.Sprintf("failed to fetch piece to retrieve from: %s", err)
} else {
answer.Message = "piece info for cid not found (deal has not been added to a piece yet)"
}

sendResp(answer)
Expand Down
2 changes: 2 additions & 0 deletions retrievalmarket/impl/provider_test.go
Expand Up @@ -815,6 +815,7 @@ func TestHandleQueryStream(t *testing.T) {
expResp: retrievalmarket.QueryResponse{
Status: retrievalmarket.QueryResponseUnavailable,
PieceCIDFound: retrievalmarket.QueryItemUnavailable,
Message: "piece info for cid not found (deal has not been added to a piece yet)",
},
expectedPricePerByte: big.Zero(),
expectedPaymentInterval: 0,
Expand All @@ -830,6 +831,7 @@ func TestHandleQueryStream(t *testing.T) {
expResp: retrievalmarket.QueryResponse{
Status: retrievalmarket.QueryResponseUnavailable,
PieceCIDFound: retrievalmarket.QueryItemUnavailable,
Message: "piece info for cid not found (deal has not been added to a piece yet)",
},
expectedPricePerByte: big.Zero(),
expectedPaymentInterval: 0,
Expand Down

0 comments on commit 5e7372b

Please sign in to comment.