Skip to content

Commit

Permalink
add test case for nonexistent key
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardmack committed Jun 16, 2022
1 parent 12ff686 commit 6d45df8
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions lib/trie/trie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3573,6 +3573,42 @@ func Test_Trie_delete(t *testing.T) {
},
updated: true,
},
"handle nonexistent key (no op)": {
trie: Trie{
generation: 1,
},
parent: &Node{
Key: []byte{1, 0, 2, 3},
Descendants: 1,
Children: padRightChildren([]*Node{
{ // full key 1, 0, 2
Key: []byte{2},
Value: []byte{1},
},
{ // full key 1, 1, 2
Key: []byte{2},
Value: []byte{2},
},
}),
},
key: []byte{1, 0, 2},
newParent: &Node{
Key: []byte{1, 0, 2, 3},
Descendants: 1,
Children: padRightChildren([]*Node{
{ // full key 1, 0, 2
Key: []byte{2},
Value: []byte{1},
},
{ // full key 1, 1, 2
Key: []byte{2},
Value: []byte{2},
},
}),
},
updated: false,
nodesRemoved: 0,
},
}

for name, testCase := range testCases {
Expand Down

0 comments on commit 6d45df8

Please sign in to comment.