diff --git a/lib/trie/trie_test.go b/lib/trie/trie_test.go index e05587477b..ff5144a698 100644 --- a/lib/trie/trie_test.go +++ b/lib/trie/trie_test.go @@ -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 {