mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-05-02 03:02:54 -04:00
Sort received atts by sig (#4287)
This commit is contained in:
committed by
Preston Van Loon
parent
89e1200b73
commit
8724dcd41b
@@ -1,8 +1,10 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"math"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -30,8 +32,8 @@ func TestKV_Unaggregated_CanSaveRetrieve(t *testing.T) {
|
||||
|
||||
data := ðpb.AttestationData{Slot: 100, CommitteeIndex: 99}
|
||||
att1 := ðpb.Attestation{Data: ðpb.AttestationData{}, AggregationBits: bitfield.Bitlist{0b101}}
|
||||
att2 := ðpb.Attestation{Data: data, Signature: []byte{'A'}, AggregationBits: bitfield.Bitlist{0b110}}
|
||||
att3 := ðpb.Attestation{Data: data, Signature: []byte{'B'}, AggregationBits: bitfield.Bitlist{0b110}}
|
||||
att2 := ðpb.Attestation{Data: data, Signature: []byte{0,0}, AggregationBits: bitfield.Bitlist{0b110}}
|
||||
att3 := ðpb.Attestation{Data: data, Signature: []byte{0,1}, AggregationBits: bitfield.Bitlist{0b110}}
|
||||
atts := []*ethpb.Attestation{att1, att2, att3}
|
||||
|
||||
for _, att := range atts {
|
||||
@@ -41,8 +43,11 @@ func TestKV_Unaggregated_CanSaveRetrieve(t *testing.T) {
|
||||
}
|
||||
|
||||
returned := cache.UnaggregatedAttestation(data.Slot, data.CommitteeIndex)
|
||||
wanted := []*ethpb.Attestation{att2, att3}
|
||||
sort.Slice(returned, func(i, j int) bool {
|
||||
return binary.BigEndian.Uint16(returned[i].Signature) < binary.BigEndian.Uint16(returned[j].Signature)
|
||||
})
|
||||
|
||||
wanted := []*ethpb.Attestation{att2, att3}
|
||||
if !reflect.DeepEqual(wanted, returned) {
|
||||
t.Error("Did not receive correct unaggregated atts")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user