test: fix fuse tests, they were broken some time ago

They wouldn't compile

License: MIT
Signed-off-by: default avatarJakub Sztandera <kubuxu@protonmail.ch>
parent a8b56d3a
...@@ -22,7 +22,6 @@ import ( ...@@ -22,7 +22,6 @@ import (
ci "github.com/ipfs/go-ipfs/thirdparty/testutil/ci" ci "github.com/ipfs/go-ipfs/thirdparty/testutil/ci"
uio "github.com/ipfs/go-ipfs/unixfs/io" uio "github.com/ipfs/go-ipfs/unixfs/io"
cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid"
node "gx/ipfs/QmYDscK7dmdo2GZ9aumS8s5auUUAH5mR1jvj5pYhWusfK7/go-ipld-node" node "gx/ipfs/QmYDscK7dmdo2GZ9aumS8s5auUUAH5mR1jvj5pYhWusfK7/go-ipld-node"
u "gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util" u "gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util"
fstest "gx/ipfs/QmaFNtBAXX4nVMQWbUqNysXyhevUj1k4B1y5uS45LC7Vw9/fuse/fs/fstestutil" fstest "gx/ipfs/QmaFNtBAXX4nVMQWbUqNysXyhevUj1k4B1y5uS45LC7Vw9/fuse/fs/fstestutil"
...@@ -117,7 +116,7 @@ func TestIpfsStressRead(t *testing.T) { ...@@ -117,7 +116,7 @@ func TestIpfsStressRead(t *testing.T) {
nd, mnt := setupIpfsTest(t, nil) nd, mnt := setupIpfsTest(t, nil)
defer mnt.Close() defer mnt.Close()
var ks []*cid.Cid var nodes []node.Node
var paths []string var paths []string
nobj := 50 nobj := 50
...@@ -126,9 +125,8 @@ func TestIpfsStressRead(t *testing.T) { ...@@ -126,9 +125,8 @@ func TestIpfsStressRead(t *testing.T) {
// Make a bunch of objects // Make a bunch of objects
for i := 0; i < nobj; i++ { for i := 0; i < nobj; i++ {
fi, _ := randObj(t, nd, rand.Int63n(50000)) fi, _ := randObj(t, nd, rand.Int63n(50000))
c := fi.Cid() nodes = append(nodes, fi)
ks = append(ks, c) paths = append(paths, fi.Cid().String())
paths = append(paths, c.String())
} }
// Now make a bunch of dirs // Now make a bunch of dirs
...@@ -136,19 +134,24 @@ func TestIpfsStressRead(t *testing.T) { ...@@ -136,19 +134,24 @@ func TestIpfsStressRead(t *testing.T) {
db := uio.NewDirectory(nd.DAG) db := uio.NewDirectory(nd.DAG)
for j := 0; j < 1+rand.Intn(10); j++ { for j := 0; j < 1+rand.Intn(10); j++ {
name := fmt.Sprintf("child%d", j) name := fmt.Sprintf("child%d", j)
err := db.AddChild(nd.Context(), name, ks[rand.Intn(len(ks))])
err := db.AddChild(nd.Context(), name, nodes[rand.Intn(len(nodes))])
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }
newdir := db.GetNode() newdir, err := db.GetNode()
k, err := nd.DAG.Add(newdir) if err != nil {
t.Fatal(err)
}
_, err = nd.DAG.Add(newdir)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
ks = append(ks, k) nodes = append(nodes, newdir)
npaths := getPaths(t, nd, k.String(), newdir) npaths := getPaths(t, nd, newdir.Cid().String(), newdir.(*dag.ProtoNode))
paths = append(paths, npaths...) paths = append(paths, npaths...)
} }
...@@ -208,16 +211,19 @@ func TestIpfsBasicDirRead(t *testing.T) { ...@@ -208,16 +211,19 @@ func TestIpfsBasicDirRead(t *testing.T) {
// Make a 'file' // Make a 'file'
fi, data := randObj(t, nd, 10000) fi, data := randObj(t, nd, 10000)
k := fi.Cid()
// Make a directory and put that file in it // Make a directory and put that file in it
db := uio.NewDirectory(nd.DAG) db := uio.NewDirectory(nd.DAG)
err := db.AddChild(nd.Context(), "actual", k) err := db.AddChild(nd.Context(), "actual", fi)
if err != nil {
t.Fatal(err)
}
d1nd, err := db.GetNode()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
d1nd := db.GetNode()
d1ndk, err := nd.DAG.Add(d1nd) d1ndk, err := nd.DAG.Add(d1nd)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment