mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-10 19:51:20 +00:00
d06b0e8a86
* Refactor AttestingIndices to not return any error. Add tests. Add shortcut for fully attested attestation * attestationutil.ConvertToIndexed never returned error either * fix test * remove shortcut * revert test...
46 lines
943 B
Go
46 lines
943 B
Go
package attestationutil_test
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/go-bitfield"
|
|
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
|
)
|
|
|
|
func TestAttestingIndices(t *testing.T) {
|
|
type args struct {
|
|
bf bitfield.Bitfield
|
|
committee []uint64
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want []uint64
|
|
}{
|
|
{
|
|
name: "Full committee attested",
|
|
args: args{
|
|
bf: bitfield.Bitlist{0b1111},
|
|
committee: []uint64{0, 1, 2},
|
|
},
|
|
want: []uint64{0, 1, 2},
|
|
},
|
|
{
|
|
name: "Partial committee attested",
|
|
args: args{
|
|
bf: bitfield.Bitlist{0b1101},
|
|
committee: []uint64{0, 1, 2},
|
|
},
|
|
want: []uint64{0, 2},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := attestationutil.AttestingIndices(tt.args.bf, tt.args.committee)
|
|
if !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("AttestingIndices() got = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
} |