1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-28 00:39:31 +08:00

clean up ipns test and add more asserts

This commit is contained in:
Jeromy
2014-10-04 08:30:24 +00:00
parent 5423a00894
commit c64add1959
2 changed files with 10 additions and 14 deletions

View File

@ -1,7 +1,9 @@
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)
}
if n != len(rbuf) {
t.Fatal("Failed to read correct amount!")
}
fi.Close()
if !bytes.Equal(rbuf, data) {
t.Fatal("Incorrect Read!")
}
}

View File

@ -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