Commit ce1f8da0 authored by Jeromy's avatar Jeromy

add another ipns test to simulate coalesced writes

parent a7bca102
...@@ -187,6 +187,47 @@ func TestMultiWrite(t *testing.T) { ...@@ -187,6 +187,47 @@ func TestMultiWrite(t *testing.T) {
} }
} }
func TestMultiWriteCoal(t *testing.T) {
dserv := getMockDagServ(t)
_, n := getNode(t, dserv, 0)
dagmod, err := NewDagModifier(n, dserv, &chunk.SizeSplitter{512})
if err != nil {
t.Fatal(err)
}
data := make([]byte, 4000)
u.NewFastRand().Read(data)
for i := 0; i < len(data); i++ {
n, err := dagmod.WriteAt(data[:i+1], 0)
if err != nil {
t.Fatal(err)
}
if n != i+1 {
t.Fatal("Somehow wrote the wrong number of bytes! (n != 1)")
}
}
nd, err := dagmod.GetNode()
if err != nil {
t.Fatal(err)
}
read, err := NewDagReader(nd, dserv)
if err != nil {
t.Fatal(err)
}
rbuf, err := ioutil.ReadAll(read)
if err != nil {
t.Fatal(err)
}
err = arrComp(rbuf, data)
if err != nil {
t.Fatal(err)
}
}
func arrComp(a, b []byte) error { func arrComp(a, b []byte) error {
if len(a) != len(b) { if len(a) != len(b) {
return fmt.Errorf("Arrays differ in length. %d != %d", len(a), len(b)) return fmt.Errorf("Arrays differ in length. %d != %d", len(a), len(b))
......
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