Skip to content

Commit

Permalink
Modify unit tests with more generation checks
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jan 21, 2022
1 parent f92fd8b commit 796e577
Show file tree
Hide file tree
Showing 2 changed files with 238 additions and 137 deletions.
4 changes: 4 additions & 0 deletions lib/trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ func (t *Trie) tryPut(key, value []byte) {
// insert attempts to insert a key with value into the trie
func (t *Trie) insert(parent Node, key []byte, value Node) Node {
newParent := t.maybeUpdateGeneration(parent)
value.SetGeneration(t.generation)

if newParent == nil {
value.SetKey(key)
return value
Expand Down Expand Up @@ -807,6 +809,8 @@ func handleDeletion(p *node.Branch, key []byte) Node {
for i, grandchild := range c.Children {
if grandchild != nil {
br.Children[i] = grandchild
// No need to copy and update the generation
// of the grand children since they are not modified.
}
}

Expand Down
Loading

0 comments on commit 796e577

Please sign in to comment.