Skip to content

Commit

Permalink
fix: set nodes known to be absent to Empty, to differentiate from unk…
Browse files Browse the repository at this point in the history
…nown nodes (#353)

* fix: set nodes known to be absent to Empty, to differentiate from unknown nodes

* fix failing test
  • Loading branch information
gballet committed May 11, 2023
1 parent b02bc4f commit ab52d15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,8 @@ func TestStatelessDeserializeMissginChildNode(t *testing.T) {
t.Fatal("differing commitment for child #0")
}

if droot.(*InternalNode).children[64] != UnknownNode(struct{}{}) {
t.Fatalf("non-nil child #64: %v", droot.(*InternalNode).children[64])
if droot.(*InternalNode).children[64] != Empty(struct{}{}) {
t.Fatalf("non-empty child #64: %v", droot.(*InternalNode).children[64])
}
}

Expand Down
5 changes: 4 additions & 1 deletion tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,10 @@ func (n *InternalNode) CreatePath(path []byte, stemInfo stemInfo, comms []*Point
if len(path) == 1 {
switch stemInfo.stemType & 3 {
case extStatusAbsentEmpty:
// nothing to do
// Set child to Empty so that, in a stateless context,
// a node known to be absent is differentiated from an
// unknown node.
n.children[path[0]] = Empty{}
case extStatusAbsentOther:
// insert poa stem
case extStatusPresent:
Expand Down

0 comments on commit ab52d15

Please sign in to comment.