Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions daemon/algod/api/server/v2/delta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package v2

import (
"bytes"
"sort"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -138,6 +140,10 @@ func TestDelta(t *testing.T) {
require.Equal(t, expAppDelta.Addr.String(), actAppDelta.Address)
require.Equal(t, expAppDelta.Params.Deleted, actAppDelta.AppDeleted)
require.Equal(t, len(original.KvMods), len(*converted.KvMods))
// sort the result so we have deterministic order
sort.Slice(*converted.KvMods, func(i, j int) bool {
return bytes.Compare(*(*converted.KvMods)[i].Key, *(*converted.KvMods)[j].Key) < 0
})
Comment on lines +143 to +146
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a require.ElementsMatch feature which claims to ignore the order

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I wasn't sure if that would do a deep equals or not.

require.Equal(t, []uint8("box1"), *(*converted.KvMods)[0].Key)
require.Equal(t, original.KvMods["box1"].Data, *(*converted.KvMods)[0].Value)
require.Equal(t, []uint8("box2"), *(*converted.KvMods)[1].Key)
Expand Down