Commit 717b235c authored by Eric Myhre's avatar Eric Myhre

Track LastBlock correctly in traversal.Focus.

And test.
Signed-off-by: default avatarEric Myhre <hash@exultant.us>
parent fa670628
......@@ -78,6 +78,8 @@ func (tp TraversalProgress) Focus(n ipld.Node, p ipld.Path, fn VisitFn) error {
if err != nil {
return fmt.Errorf("error traversing node at %q: could not load link %q: %s", p.Truncate(i+1), lnk, err)
}
tp.LastBlock.Path = p.Truncate(i + 1)
tp.LastBlock.Link = lnk
prev, n = n, next
}
}
......
......@@ -150,6 +150,8 @@ func TestFocusWithLinkLoading(t *testing.T) {
}.Focus(rootNode, ipld.ParsePath("linkedMap/nested/nonlink"), func(tp traversal.TraversalProgress, n ipld.Node) error {
Wish(t, n, ShouldEqual, fnb.CreateString("zoo"))
Wish(t, tp.Path, ShouldEqual, ipld.ParsePath("linkedMap/nested/nonlink"))
Wish(t, tp.LastBlock.Link, ShouldEqual, middleMapNodeLnk)
Wish(t, tp.LastBlock.Path, ShouldEqual, ipld.ParsePath("linkedMap"))
return nil
})
Wish(t, err, ShouldEqual, nil)
......
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