Skip to content

Commit

Permalink
Finish storage diff testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dimartiro committed Mar 20, 2024
1 parent cc878ff commit a15b1f5
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/runtime/storage/storagediff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,4 +522,42 @@ func Test_ApplyToTrie(t *testing.T) {
diff.applyToTrie(state)
require.Equal(t, expected, state)
})

t.Run("create_new_child_trie", func(t *testing.T) {
t.Parallel()

state := trie.NewEmptyTrie()

childKey := "child"
key := "key1"
value := []byte("value1")

diff := newStorageDiff()
diff.upsertChild(childKey, key, value)

expected := trie.NewEmptyTrie()
expected.PutIntoChild([]byte(childKey), []byte(key), value)

diff.applyToTrie(state)
require.Equal(t, expected, state)
})

t.Run("remove_from_child_trie", func(t *testing.T) {
t.Parallel()

childKey := "child"
key := "key1"
value := []byte("value1")

state := trie.NewEmptyTrie()
state.PutIntoChild([]byte(childKey), []byte(key), value)

expected := trie.NewEmptyTrie()

diff := newStorageDiff()
diff.deleteFromChild(childKey, key)

diff.applyToTrie(state)
require.Equal(t, expected, state)
})
}

0 comments on commit a15b1f5

Please sign in to comment.