From 25ebd335cb68a3ca4181229201ae3dfe9fb9725c Mon Sep 17 00:00:00 2001 From: minh-bq <97180373+minh-bq@users.noreply.github.com> Date: Sat, 8 Jul 2023 02:26:02 +0700 Subject: [PATCH] Fix bls signature batch unit test (#12602) We randomly observe this failure when running unit test go test -test.v -run=^TestSignatureBatch_AggregateBatch/common_and_uncommon_messages_in_batch_with_multiple_messages === RUN TestSignatureBatch_AggregateBatch === RUN TestSignatureBatch_AggregateBatch/common_and_uncommon_messages_in_batch_with_multiple_messages signature_batch_test.go:643: AggregateBatch() Descriptions got = [test signature bls aggregated signature test signature bls aggregated signature test signature bls aggregated signature], want [bls aggregated signature test signature bls aggregated signature test signature bls aggregated signature test signature] --- FAIL: TestSignatureBatch_AggregateBatch (0.02s) --- FAIL: TestSignatureBatch_AggregateBatch/common_and_uncommon_messages_in_batch_with_multiple_messages (0.02s) The problem is that the signature sort forgets to swap the description when a swap occurs. This commit adds the description swap when swap occurs. Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com> --- crypto/bls/signature_batch_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/crypto/bls/signature_batch_test.go b/crypto/bls/signature_batch_test.go index 48a8530d9..6c9df3836 100644 --- a/crypto/bls/signature_batch_test.go +++ b/crypto/bls/signature_batch_test.go @@ -737,6 +737,7 @@ func (s sorter) Swap(i, j int) { s.set.Signatures[i], s.set.Signatures[j] = s.set.Signatures[j], s.set.Signatures[i] s.set.PublicKeys[i], s.set.PublicKeys[j] = s.set.PublicKeys[j], s.set.PublicKeys[i] s.set.Messages[i], s.set.Messages[j] = s.set.Messages[j], s.set.Messages[i] + s.set.Descriptions[i], s.set.Descriptions[j] = s.set.Descriptions[j], s.set.Descriptions[i] } func (s sorter) Less(i, j int) bool {