Skip to content

Commit

Permalink
fix(wasmer): fix flaky sort in `Test_ext_crypto_sr25519_public_keys_v…
Browse files Browse the repository at this point in the history
…ersion_1` (#2607)
  • Loading branch information
qdm12 committed Jun 17, 2022
1 parent cdc6160 commit c061b35
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/runtime/wasmer/imports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ func Test_ext_crypto_sr25519_public_keys_version_1(t *testing.T) {
ks, _ := inst.ctx.Keystore.GetKeystore(idData)
require.Equal(t, 0, ks.Size())

size := 5
const size = 5
pubKeys := make([][32]byte, size)
for i := range pubKeys {
kp, err := sr25519.GenerateKeypair()
Expand All @@ -1083,7 +1083,9 @@ func Test_ext_crypto_sr25519_public_keys_version_1(t *testing.T) {
copy(pubKeys[i][:], kp.Public().Encode())
}

sort.Slice(pubKeys, func(i int, j int) bool { return pubKeys[i][0] < pubKeys[j][0] })
sort.Slice(pubKeys, func(i int, j int) bool {
return bytes.Compare(pubKeys[i][:], pubKeys[j][:]) < 0
})

res, err := inst.Exec("rtm_ext_crypto_sr25519_public_keys_version_1", idData)
require.NoError(t, err)
Expand All @@ -1096,7 +1098,10 @@ func Test_ext_crypto_sr25519_public_keys_version_1(t *testing.T) {
err = scale.Unmarshal(out, &ret)
require.NoError(t, err)

sort.Slice(ret, func(i int, j int) bool { return ret[i][0] < ret[j][0] })
sort.Slice(ret, func(i int, j int) bool {
return bytes.Compare(ret[i][:], ret[j][:]) < 0
})

require.Equal(t, pubKeys, ret)
}

Expand Down

0 comments on commit c061b35

Please sign in to comment.