Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better answer message on ErrNotFound #690

Merged
merged 1 commit into from Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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