@cryptotaxi247 / kubo / commits / c64add195

clean up ipns test and add more asserts

Jeromy committed Oct 4, 2014 at 08:30 UTC c64add1959e6d45bcd7b6ec1930bd780356cce55
2 files changed +9 -13
fuse/ipns/ipns_test.go
+7 -6
@@ -1,7 +1,9 @@
1 package ipns
2
3 import (
4 + "bytes"
5 "crypto/rand"
6 + "io/ioutil"
7 "os"
8 "testing"
9
@@ -29,6 +31,7 @@ func TestIpnsBasicIO(t *testing.T) {
31 if err != nil {
32 t.Fatal(err)
33 }
34 + defer mnt.Close()
35
36 data := randBytes(12345)
37 fi, err := os.Create(mnt.Dir + "/local/testfile")
@@ -54,16 +57,14 @@ func TestIpnsBasicIO(t *testing.T) {
57 t.Fatal(err)
58 }
59
57 - rbuf := make([]byte, len(data))
58 - n, err = fi.Read(rbuf)
60 + rbuf, err := ioutil.ReadAll(fi)
61 if err != nil {
62 t.Fatal(err)
63 }
64 + fi.Close()
65
63 - if n != len(rbuf) {
64 - t.Fatal("Failed to read correct amount!")
66 + if !bytes.Equal(rbuf, data) {
67 + t.Fatal("Incorrect Read!")
68 }
69
67 - fi.Close()
68 -
70 }
fuse/ipns/ipns_unix.go
+2 -7
@@ -2,7 +2,6 @@ package ipns
2
3 import (
4 "bytes"
5 - "fmt"
5 "io/ioutil"
6 "os"
7 "path/filepath"
@@ -294,10 +293,6 @@ func (s *Node) ReadAll(intr fs.Intr) ([]byte, fuse.Error) {
293 log.Error("[%s] Readall error: %s", s.name, err)
294 return nil, err
295 }
297 - if len(b) > 4 {
298 - log.Debug("ReadAll trailing bytes: %v", b[len(b)-4:])
299 - }
300 - fmt.Println(b)
296 return b, nil
297 }
298
@@ -342,7 +337,7 @@ func (n *Node) Flush(req *fuse.FlushRequest, intr fs.Intr) fuse.Error {
337 }
338 n.Nd = newNode
339
345 - //TEMP
340 + /*/TEMP
341 dr, err := mdag.NewDagReader(n.Nd, n.Ipfs.DAG)
342 if err != nil {
343 log.Critical("Verification read failed.")
@@ -355,7 +350,7 @@ func (n *Node) Flush(req *fuse.FlushRequest, intr fs.Intr) fuse.Error {
350 fmt.Printf("READ %d BYTES\n", len(b))
351 fmt.Println(string(b))
352 fmt.Println(b)
358 - //
353 + //*/
354
355 n.writerBuf = nil
356