mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-28 17:03:58 +08:00
clean up ipns test and add more asserts
This commit is contained in:
@ -1,7 +1,9 @@
|
|||||||
package ipns
|
package ipns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -29,6 +31,7 @@ func TestIpnsBasicIO(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
defer mnt.Close()
|
||||||
|
|
||||||
data := randBytes(12345)
|
data := randBytes(12345)
|
||||||
fi, err := os.Create(mnt.Dir + "/local/testfile")
|
fi, err := os.Create(mnt.Dir + "/local/testfile")
|
||||||
@ -54,16 +57,14 @@ func TestIpnsBasicIO(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rbuf := make([]byte, len(data))
|
rbuf, err := ioutil.ReadAll(fi)
|
||||||
n, err = fi.Read(rbuf)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if n != len(rbuf) {
|
|
||||||
t.Fatal("Failed to read correct amount!")
|
|
||||||
}
|
|
||||||
|
|
||||||
fi.Close()
|
fi.Close()
|
||||||
|
|
||||||
|
if !bytes.Equal(rbuf, data) {
|
||||||
|
t.Fatal("Incorrect Read!")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package ipns
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"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)
|
log.Error("[%s] Readall error: %s", s.name, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(b) > 4 {
|
|
||||||
log.Debug("ReadAll trailing bytes: %v", b[len(b)-4:])
|
|
||||||
}
|
|
||||||
fmt.Println(b)
|
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +337,7 @@ func (n *Node) Flush(req *fuse.FlushRequest, intr fs.Intr) fuse.Error {
|
|||||||
}
|
}
|
||||||
n.Nd = newNode
|
n.Nd = newNode
|
||||||
|
|
||||||
//TEMP
|
/*/TEMP
|
||||||
dr, err := mdag.NewDagReader(n.Nd, n.Ipfs.DAG)
|
dr, err := mdag.NewDagReader(n.Nd, n.Ipfs.DAG)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Critical("Verification read failed.")
|
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.Printf("READ %d BYTES\n", len(b))
|
||||||
fmt.Println(string(b))
|
fmt.Println(string(b))
|
||||||
fmt.Println(b)
|
fmt.Println(b)
|
||||||
//
|
//*/
|
||||||
|
|
||||||
n.writerBuf = nil
|
n.writerBuf = nil
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user