1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 09:52:20 +08:00

rework dagreader to have a dagservice for node resolution

This commit is contained in:
Jeromy
2014-09-06 22:11:44 +00:00
parent dad9751754
commit 275b03f814
6 changed files with 66 additions and 29 deletions

View File

@ -32,3 +32,27 @@ func TestFileConsistency(t *testing.T) {
t.Fatal("Output not the same as input.")
}
}
//Test where calls to read are smaller than the chunk size
func TestFileConsistencyLargeBlocks(t *testing.T) {
buf := new(bytes.Buffer)
io.CopyN(buf, rand.Reader, 4096*32)
should := buf.Bytes()
nd, err := NewDagFromReaderWithSplitter(buf, SplitterBySize(4096))
if err != nil {
t.Fatal(err)
}
r, err := dag.NewDagReader(nd)
if err != nil {
t.Fatal(err)
}
out, err := ioutil.ReadAll(r)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(out, should) {
t.Fatal("Output not the same as input.")
}
}