From c20eb15bd52574fdbc49c04d6daa7d173778c7a9 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Mon, 12 Jul 2021 18:17:39 +0300 Subject: [PATCH] [#688] pkg/ir/governance: Add `unsorted` test case Signed-off-by: Pavel Karpy --- pkg/innerring/processors/governance/list_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/innerring/processors/governance/list_test.go b/pkg/innerring/processors/governance/list_test.go index 06c3c84fa8..3b41372042 100644 --- a/pkg/innerring/processors/governance/list_test.go +++ b/pkg/innerring/processors/governance/list_test.go @@ -55,6 +55,19 @@ func TestNewAlphabetList(t *testing.T) { require.True(t, equalPublicKeyLists(list, rounds[i])) } }) + + t.Run("unsorted keys", func(t *testing.T) { + orig := keys.PublicKeys{k[1], k[2], k[3], k[4]} + main := keys.PublicKeys{k[1], k[2], k[5], k[4]} + + exp := make(keys.PublicKeys, len(main)) + copy(exp, main) + sort.Sort(exp) + + got, err := newAlphabetList(orig, main) + require.NoError(t, err) + require.True(t, equalPublicKeyLists(exp, got)) // expect {1, 2, 4, 5}, not {1, 2, 3, 5} + }) } func TestUpdateInnerRing(t *testing.T) {