public void Extension_can_accept_visitors() { ITreeVisitor visitor = Substitute.For <ITreeVisitor>(); TrieVisitContext context = new(); TrieNode ignore = TrieNodeFactory.CreateLeaf(HexPrefix.Leaf("ccc"), Array.Empty <byte>()); TrieNode node = TrieNodeFactory.CreateExtension(HexPrefix.Extension("aa"), ignore); node.Accept(visitor, NullTrieNodeResolver.Instance, context); visitor.Received().VisitExtension(node, context); }
public void Extension_with_leaf_can_be_visited() { Context ctx = new(); ITreeVisitor visitor = Substitute.For <ITreeVisitor>(); visitor.ShouldVisit(Arg.Any <Keccak>()).Returns(true); TrieVisitContext context = new(); TrieNode node = TrieNodeFactory.CreateExtension(HexPrefix.Extension("aa"), ctx.AccountLeaf); node.Accept(visitor, NullTrieNodeResolver.Instance, context); visitor.Received().VisitExtension(node, context); visitor.Received().VisitLeaf(ctx.AccountLeaf, context, ctx.AccountLeaf.Value); }