changes as per review

This commit is contained in:
aarshkshah1992 2021-07-05 15:53:41 +05:30
parent 8ecdc929b4
commit 44985722d2
2 changed files with 33 additions and 1 deletions

View File

@ -135,10 +135,13 @@ func (rpn *retrievalProviderNode) GetRetrievalPricingInput(ctx context.Context,
}
tsk := head.Key()
var lastErr error
for _, dealID := range storageDeals {
ds, err := rpn.full.StateMarketStorageDeal(ctx, dealID, tsk)
if err != nil {
log.Warnf("failed to look up deal %d on chain: err=%w", dealID, err)
lastErr = err
continue
}
if ds.Proposal.VerifiedDeal {
@ -159,7 +162,11 @@ func (rpn *retrievalProviderNode) GetRetrievalPricingInput(ctx context.Context,
// Note: The piece size can never actually be zero. We only use it to here
// to assert that we didn't find a matching piece.
if resp.PieceSize == 0 {
return resp, xerrors.New("failed to find matching piece")
if lastErr == nil {
return resp, xerrors.New("failed to find matching piece")
} else {
return resp, xerrors.Errorf("failed to fetch storage deal state: %w", err)
}
}
return resp, nil

View File

@ -66,6 +66,31 @@ func TestGetPricingInput(t *testing.T) {
expectedErrorStr: "failed to find matching piece",
},
"error when fails to fetch deal state": {
fFnc: func(n *mocks.MockFullNode) {
out1 := &api.MarketDeal{
Proposal: market.DealProposal{
PieceCID: pcid,
PieceSize: paddedSize,
},
}
out2 := &api.MarketDeal{
Proposal: market.DealProposal{
PieceCID: testnet.GenerateCids(1)[0],
VerifiedDeal: true,
},
}
n.EXPECT().ChainHead(gomock.Any()).Return(tsk, nil).Times(1)
gomock.InOrder(
n.EXPECT().StateMarketStorageDeal(gomock.Any(), deals[0], key).Return(out1, xerrors.New("error 1")),
n.EXPECT().StateMarketStorageDeal(gomock.Any(), deals[1], key).Return(out2, xerrors.New("error 2")),
)
},
expectedErrorStr: "failed to fetch storage deal state",
},
"verified is true even if one deal is verified and we get the correct piecesize": {
fFnc: func(n *mocks.MockFullNode) {
out1 := &api.MarketDeal{