From d2a3f22cf4b3c35d6aacfa58f69286b1d2087d9b Mon Sep 17 00:00:00 2001 From: mpoke Date: Fri, 19 Jul 2024 09:36:06 +0200 Subject: [PATCH] remove non-determinism from tests --- x/ccv/provider/types/keys.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/x/ccv/provider/types/keys.go b/x/ccv/provider/types/keys.go index 0174bb99ac..850d418d42 100644 --- a/x/ccv/provider/types/keys.go +++ b/x/ccv/provider/types/keys.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/binary" "fmt" + "sort" "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -299,9 +300,14 @@ func MustGetKeyPrefix(key string) byte { // Only used for testing func GetAllKeyPrefixes() []byte { prefixMap := getKeyPrefixes() + keys := make([]string, 0, len(prefixMap)) + for k := range prefixMap { + keys = append(keys, k) + } + sort.Strings(keys) prefixList := make([]byte, 0, len(prefixMap)) - for _, prefix := range prefixMap { - prefixList = append(prefixList, prefix) + for _, k := range keys { + prefixList = append(prefixList, prefixMap[k]) } return prefixList } @@ -310,11 +316,12 @@ func GetAllKeyPrefixes() []byte { // Only used for testing func GetAllKeyNames() []string { prefixMap := getKeyPrefixes() - keyList := make([]string, 0, len(prefixMap)) - for key := range prefixMap { - keyList = append(keyList, key) + keys := make([]string, 0, len(prefixMap)) + for k := range prefixMap { + keys = append(keys, k) } - return keyList + sort.Strings(keys) + return keys } //