Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feat/support-padding
Browse files Browse the repository at this point in the history
  • Loading branch information
ribasushi committed Jul 23, 2021
2 parents ccfb7d1 + aa86bc2 commit 75bdbfc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1
orbs:
go: gotest/[email protected]
codecov: codecov/[email protected]
node: circleci/node@3.0.0
node: circleci/node@4.5.1

executors:
golang:
Expand Down
9 changes: 5 additions & 4 deletions retrievalmarket/impl/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func TestClientCanMakeDealWithProvider(t *testing.T) {
}

// ------- SET UP CLIENT
ctx, cancel := context.WithTimeout(bgCtx, 10*time.Second)
ctx, cancel := context.WithTimeout(bgCtx, 60*time.Second)
defer cancel()

provider := setupProvider(bgCtx, t, testData, payloadCID, pieceInfo, expectedQR,
Expand Down Expand Up @@ -550,11 +550,12 @@ CurrentInterval: %d
}
assert.Equal(t, retrievalmarket.DealStatusCompleted, clientDealState.Status)
}
ctx, cancel = context.WithTimeout(bgCtx, 5*time.Second)
defer cancel()

ctxProv, cancelProv := context.WithTimeout(bgCtx, 10*time.Second)
defer cancelProv()
var providerDealState retrievalmarket.ProviderDealState
select {
case <-ctx.Done():
case <-ctxProv.Done():
t.Error("provider never saw completed deal")
t.FailNow()
case providerDealState = <-providerDealStateChan:
Expand Down
8 changes: 0 additions & 8 deletions storagemarket/impl/requestvalidation/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
// Will succeed only if:
// - voucher has correct type
// - voucher references an active deal
// - referenced deal matches the client
// - referenced deal matches the given base CID
// - referenced deal is in an acceptable state
func ValidatePush(
Expand All @@ -34,9 +33,6 @@ func ValidatePush(
if err != nil {
return xerrors.Errorf("Proposal CID %s: %w", dealVoucher.Proposal.String(), ErrNoDeal)
}
if deal.Client != sender {
return xerrors.Errorf("Deal Peer %s, Data Transfer Peer %s: %w", deal.Client.String(), sender.String(), ErrWrongPeer)
}

if !deal.Ref.Root.Equals(baseCid) {
return xerrors.Errorf("Deal Payload CID %s, Data Transfer CID %s: %w", deal.Proposal.PieceCID.String(), baseCid.String(), ErrWrongPiece)
Expand All @@ -53,7 +49,6 @@ func ValidatePush(
// Will succeed only if:
// - voucher has correct type
// - voucher references an active deal
// - referenced deal matches the receiver (miner)
// - referenced deal matches the given base CID
// - referenced deal is in an acceptable state
func ValidatePull(
Expand All @@ -71,9 +66,6 @@ func ValidatePull(
return xerrors.Errorf("Proposal CID %s: %w", dealVoucher.Proposal.String(), ErrNoDeal)
}

if deal.Miner != receiver {
return xerrors.Errorf("Deal Peer %s, Data Transfer Peer %s: %w", deal.Miner.String(), receiver.String(), ErrWrongPeer)
}
if !deal.DataRef.Root.Equals(baseCid) {
return xerrors.Errorf("Deal Payload CID %s, Data Transfer CID %s: %w", deal.Proposal.PieceCID.String(), baseCid.String(), ErrWrongPiece)
}
Expand Down
30 changes: 0 additions & 30 deletions storagemarket/impl/requestvalidation/request_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,6 @@ func AssertPushValidator(t *testing.T, validator datatransfer.RequestValidator,
t.Fatal("Push should fail if there is no deal stored")
}
})
t.Run("ValidatePush fails wrong miner", func(t *testing.T) {
otherClient := peer.ID("otherclient")
minerDeal, err := newMinerDeal(otherClient, storagemarket.StorageDealProposalAccepted)
if err != nil {
t.Fatal("error creating client deal")
}
if err := state.Begin(minerDeal.ProposalCid, &minerDeal); err != nil {
t.Fatal("deal tracking failed")
}
ref := minerDeal.Ref
_, err = validator.ValidatePush(false, datatransfer.ChannelID{}, sender, &rv.StorageDataTransferVoucher{minerDeal.ProposalCid}, ref.Root, nil)
if !xerrors.Is(err, rv.ErrWrongPeer) {
t.Fatal("Push should fail if miner address is incorrect")
}
})
t.Run("ValidatePush fails wrong piece ref", func(t *testing.T) {
minerDeal, err := newMinerDeal(sender, storagemarket.StorageDealProposalAccepted)
if err != nil {
Expand Down Expand Up @@ -249,21 +234,6 @@ func AssertValidatesPulls(t *testing.T, validator datatransfer.RequestValidator,
t.Fatal("Pull should fail if there is no deal stored")
}
})
t.Run("ValidatePull fails wrong client", func(t *testing.T) {
otherMiner := peer.ID("otherminer")
clientDeal, err := newClientDeal(otherMiner, storagemarket.StorageDealProposalAccepted)
if err != nil {
t.Fatal("error creating client deal")
}
if err := state.Begin(clientDeal.ProposalCid, &clientDeal); err != nil {
t.Fatal("deal tracking failed")
}
payloadCid := clientDeal.DataRef.Root
_, err = validator.ValidatePull(false, datatransfer.ChannelID{}, receiver, &rv.StorageDataTransferVoucher{clientDeal.ProposalCid}, payloadCid, nil)
if !xerrors.Is(err, rv.ErrWrongPeer) {
t.Fatal("Pull should fail if miner address is incorrect")
}
})
t.Run("ValidatePull fails wrong piece ref", func(t *testing.T) {
clientDeal, err := newClientDeal(receiver, storagemarket.StorageDealProposalAccepted)
if err != nil {
Expand Down

0 comments on commit 75bdbfc

Please sign in to comment.