提交 c64add19 作者: Jeromy

clean up ipns test and add more asserts

上级 5423a008
package ipns
import (
"bytes"
"crypto/rand"
"io/ioutil"
"os"
"testing"
......@@ -29,6 +31,7 @@ func TestIpnsBasicIO(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer mnt.Close()
data := randBytes(12345)
fi, err := os.Create(mnt.Dir + "/local/testfile")
......@@ -54,16 +57,14 @@ func TestIpnsBasicIO(t *testing.T) {
t.Fatal(err)
}
rbuf := make([]byte, len(data))
n, err = fi.Read(rbuf)
rbuf, err := ioutil.ReadAll(fi)
if err != nil {
t.Fatal(err)
}
fi.Close()
if n != len(rbuf) {
t.Fatal("Failed to read correct amount!")
if !bytes.Equal(rbuf, data) {
t.Fatal("Incorrect Read!")
}
fi.Close()
}
......@@ -2,7 +2,6 @@ package ipns
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
......@@ -294,10 +293,6 @@ func (s *Node) ReadAll(intr fs.Intr) ([]byte, fuse.Error) {
log.Error("[%s] Readall error: %s", s.name, err)
return nil, err
}
if len(b) > 4 {
log.Debug("ReadAll trailing bytes: %v", b[len(b)-4:])
}
fmt.Println(b)
return b, nil
}
......@@ -342,7 +337,7 @@ func (n *Node) Flush(req *fuse.FlushRequest, intr fs.Intr) fuse.Error {
}
n.Nd = newNode
//TEMP
/*/TEMP
dr, err := mdag.NewDagReader(n.Nd, n.Ipfs.DAG)
if err != nil {
log.Critical("Verification read failed.")
......@@ -355,7 +350,7 @@ func (n *Node) Flush(req *fuse.FlushRequest, intr fs.Intr) fuse.Error {
fmt.Printf("READ %d BYTES\n", len(b))
fmt.Println(string(b))
fmt.Println(b)
//
//*/
n.writerBuf = nil
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论