Commit e8af7a6b authored by Kejie Zhang's avatar Kejie Zhang Committed by Lucas Molas

document testDagSync function

parent f573b7b5
...@@ -412,6 +412,8 @@ func testDagTruncate(t *testing.T, opts testu.NodeOpts) { ...@@ -412,6 +412,8 @@ func testDagTruncate(t *testing.T, opts testu.NodeOpts) {
} }
} }
// TestDagSync tests that a DAG will expand sparse during sync
// if offset > curNode's size.
func TestDagSync(t *testing.T) { func TestDagSync(t *testing.T) {
dserv := testu.GetDAGServ() dserv := testu.GetDAGServ()
nd := dag.NodeWithData(unixfs.FilePBData(nil, 0)) nd := dag.NodeWithData(unixfs.FilePBData(nil, 0))
...@@ -434,6 +436,7 @@ func TestDagSync(t *testing.T) { ...@@ -434,6 +436,7 @@ func TestDagSync(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
// Truncate leave the offset at 5 and filesize at 0
err = dagmod.Truncate(0) err = dagmod.Truncate(0)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
...@@ -444,6 +447,7 @@ func TestDagSync(t *testing.T) { ...@@ -444,6 +447,7 @@ func TestDagSync(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
// When Offset > filesize , Sync will call enpandSparse
err = dagmod.Sync() err = dagmod.Sync()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
......
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