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

Include pieceinfo for deal decider #738

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion retrievalmarket/impl/integration_test.go
Expand Up @@ -208,7 +208,7 @@ func TestClientCanMakeDealWithProvider(t *testing.T) {
}).Node()

var customDeciderRan bool

var customDeciderPiece cid.Cid
testCases := []struct {
name string
decider retrievalimpl.DealDecider
Expand Down Expand Up @@ -311,6 +311,9 @@ func TestClientCanMakeDealWithProvider(t *testing.T) {
{name: "succeeds when using a custom decider function",
decider: func(ctx context.Context, state retrievalmarket.ProviderDealState) (bool, string, error) {
customDeciderRan = true
if state.PieceInfo != nil {
customDeciderPiece = state.PieceInfo.PieceCID
}
return true, "", nil
},
filename: "lorem_under_1_block.txt",
Expand Down Expand Up @@ -596,6 +599,7 @@ CurrentInterval: %d
// https://github.com/filecoin-project/go-fil-markets/issues/65
if testCase.decider != nil {
assert.True(t, customDeciderRan)
assert.Equal(t, pieceInfo.PieceCID, customDeciderPiece)
}
// verify that the nodes we interacted with behaved as expected
clientNode.VerifyExpectations(t)
Expand Down
4 changes: 2 additions & 2 deletions retrievalmarket/impl/requestvalidation/requestvalidation.go
Expand Up @@ -164,6 +164,8 @@ func (rv *ProviderRequestValidator) acceptDeal(deal *retrievalmarket.ProviderDea
return retrievalmarket.DealStatusErrored, err
}

deal.PieceInfo = &pieceInfo

ctx, cancel := context.WithTimeout(context.TODO(), askTimeout)
defer cancel()

Expand All @@ -187,8 +189,6 @@ func (rv *ProviderRequestValidator) acceptDeal(deal *retrievalmarket.ProviderDea
return retrievalmarket.DealStatusRejected, errors.New(reason)
}

deal.PieceInfo = &pieceInfo

if deal.UnsealPrice.GreaterThan(big.Zero()) {
return retrievalmarket.DealStatusFundsNeededUnseal, nil
}
Expand Down