Skip to content

Commit

Permalink
chore(test): extract unixfs test utils to go-unixfsnode
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed May 22, 2023
1 parent 1c6e9b2 commit 9aa0bd7
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 459 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/ipfs/go-ipld-format v0.4.0
github.com/ipfs/go-libipfs v0.6.1
github.com/ipfs/go-log/v2 v2.5.1
github.com/ipfs/go-unixfsnode v1.6.0
github.com/ipfs/go-unixfsnode v1.7.0
github.com/ipld/go-car/v2 v2.9.0
github.com/ipld/go-codec-dagpb v1.6.0
github.com/ipld/go-ipld-prime v0.20.1-0.20230329011551-5056175565b0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j
github.com/ipfs/go-peertaskqueue v0.8.1 h1:YhxAs1+wxb5jk7RvS0LHdyiILpNmRIRnZVztekOF0pg=
github.com/ipfs/go-peertaskqueue v0.8.1/go.mod h1:Oxxd3eaK279FxeydSPPVGHzbwVeHjatZ2GA8XD+KbPU=
github.com/ipfs/go-unixfs v0.4.4 h1:D/dLBOJgny5ZLIur2vIXVQVW0EyDHdOMBDEhgHrt6rY=
github.com/ipfs/go-unixfsnode v1.6.0 h1:JOSA02yaLylRNi2rlB4ldPr5VcZhcnaIVj5zNLcOjDo=
github.com/ipfs/go-unixfsnode v1.6.0/go.mod h1:PVfoyZkX1B34qzT3vJO4nsLUpRCyhnMuHBznRcXirlk=
github.com/ipfs/go-unixfsnode v1.7.0 h1:OwRxGCed+WXP+esYYsRr8X7jqCMCoRlauBvDwGcK8ao=
github.com/ipfs/go-unixfsnode v1.7.0/go.mod h1:PVfoyZkX1B34qzT3vJO4nsLUpRCyhnMuHBznRcXirlk=
github.com/ipfs/go-verifcid v0.0.2 h1:XPnUv0XmdH+ZIhLGKg6U2vaPaRDXb9urMyNVCE7uvTs=
github.com/ipfs/go-verifcid v0.0.2/go.mod h1:40cD9x1y4OWnFXbLNJYRe7MpNvWlMn3LZAG5Wb4xnPU=
github.com/ipld/go-car/v2 v2.9.0 h1:mkMSfh9NpnfdFe30xBFTQiKZ6+LY+mwOPrq6r56xsPo=
Expand Down
2 changes: 1 addition & 1 deletion pkg/internal/itest/client_retrieval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
retrievaltypes "github.com/filecoin-project/go-retrieval-types"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lassie/pkg/internal/itest/mocknet"
"github.com/filecoin-project/lassie/pkg/internal/itest/unixfs"
"github.com/filecoin-project/lassie/pkg/net/client"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
Expand All @@ -20,6 +19,7 @@ import (
"github.com/ipfs/go-graphsync/storeutil"
bstore "github.com/ipfs/go-ipfs-blockstore"
"github.com/ipfs/go-unixfsnode"
unixfs "github.com/ipfs/go-unixfsnode/testutil"
"github.com/ipld/go-ipld-prime/linking"
selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion pkg/internal/itest/direct_fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"time"

"github.com/filecoin-project/lassie/pkg/internal/itest/mocknet"
"github.com/filecoin-project/lassie/pkg/internal/itest/unixfs"
"github.com/filecoin-project/lassie/pkg/internal/lp2ptransports"
"github.com/filecoin-project/lassie/pkg/lassie"
"github.com/filecoin-project/lassie/pkg/retriever"
"github.com/filecoin-project/lassie/pkg/types"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-unixfsnode"
unixfs "github.com/ipfs/go-unixfsnode/testutil"
carv2 "github.com/ipld/go-car/v2"
"github.com/ipld/go-car/v2/storage"
"github.com/ipld/go-ipld-prime/codec/dagcbor"
Expand Down
14 changes: 7 additions & 7 deletions pkg/internal/itest/http_fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
datatransfer "github.com/filecoin-project/go-data-transfer/v2"
"github.com/filecoin-project/lassie/pkg/internal/itest/mocknet"
"github.com/filecoin-project/lassie/pkg/internal/itest/testpeer"
"github.com/filecoin-project/lassie/pkg/internal/itest/unixfs"
"github.com/filecoin-project/lassie/pkg/lassie"
httpserver "github.com/filecoin-project/lassie/pkg/server/http"
"github.com/google/uuid"
"github.com/ipfs/go-cid"
unixfs "github.com/ipfs/go-unixfsnode/testutil"
carv2 "github.com/ipld/go-car/v2"
"github.com/ipld/go-car/v2/storage"
"github.com/ipld/go-ipld-prime"
Expand Down Expand Up @@ -333,7 +333,7 @@ func TestHttpFetch(t *testing.T) {
// validate we got the dag-scope entity form
validateCarBody(t, body, srcData.Root, wantCids, false)
// validate that we got the full depth form under the path
gotDir := unixfs.CarToDirEntry(t, bytes.NewReader(body), srcData.Children[1].Children[1].Children[1].Root, true)
gotDir := CarToDirEntry(t, bytes.NewReader(body), srcData.Children[1].Children[1].Children[1].Root, true)
gotDir.Path = "want0"
unixfs.CompareDirEntries(t, srcData.Children[1].Children[1].Children[1], gotDir)
}},
Expand All @@ -357,7 +357,7 @@ func TestHttpFetch(t *testing.T) {
// validate we got the dag-scope entity form
validateCarBody(t, body, srcData.Root, wantCids, false)
// validate that we got the full depth form under the path
gotDir := unixfs.CarToDirEntry(t, bytes.NewReader(body), srcData.Children[1].Children[1].Children[1].Root, true)
gotDir := CarToDirEntry(t, bytes.NewReader(body), srcData.Children[1].Children[1].Children[1].Root, true)
gotDir.Path = "want0"
unixfs.CompareDirEntries(t, srcData.Children[1].Children[1].Children[1], gotDir)
}},
Expand Down Expand Up @@ -447,7 +447,7 @@ func TestHttpFetch(t *testing.T) {
// validate we got the dag-scope entity form
validateCarBody(t, body, srcData.Root, wantCids, false)
// validate that we got the full depth form under the path
gotDir := unixfs.CarToDirEntry(t, bytes.NewReader(body), srcData.Children[1].Children[1].Children[1].Root, true)
gotDir := CarToDirEntry(t, bytes.NewReader(body), srcData.Children[1].Children[1].Children[1].Root, true)
gotDir.Path = "want0"
unixfs.CompareDirEntries(t, srcData.Children[1].Children[1].Children[1], gotDir)
}},
Expand All @@ -471,7 +471,7 @@ func TestHttpFetch(t *testing.T) {
// validate we got the dag-scope entity form
validateCarBody(t, body, srcData.Root, wantCids, false)
// validate that we got the full depth form under the path
gotDir := unixfs.CarToDirEntry(t, bytes.NewReader(body), srcData.Children[1].Children[1].Children[1].Root, true)
gotDir := CarToDirEntry(t, bytes.NewReader(body), srcData.Children[1].Children[1].Children[1].Root, true)
gotDir.Path = "want0"
unixfs.CompareDirEntries(t, srcData.Children[1].Children[1].Children[1], gotDir)
}},
Expand Down Expand Up @@ -781,8 +781,8 @@ func TestHttpFetch(t *testing.T) {
if testCase.validateBodies != nil && testCase.validateBodies[i] != nil {
testCase.validateBodies[i](t, srcData[i], body)
} else {
// gotDir := unixfs.CarToDirEntry(t, bytes.NewReader(body), srcData[i].Root, true)
gotLsys := unixfs.CarBytesLinkSystem(t, bytes.NewReader(body))
// gotDir := CarToDirEntry(t, bytes.NewReader(body), srcData[i].Root, true)
gotLsys := CarBytesLinkSystem(t, bytes.NewReader(body))
gotDir := unixfs.ToDirEntry(t, gotLsys, srcData[i].Root, true)
unixfs.CompareDirEntries(t, srcData[i], gotDir)
}
Expand Down
152 changes: 0 additions & 152 deletions pkg/internal/itest/unixfs/directory.go

This file was deleted.

Loading

0 comments on commit 9aa0bd7

Please sign in to comment.