prysm-pulse/beacon-chain/operations/attestations/kv/seen_bits_test.go
terence tsao b954db9704
Revert "Update fastssz" (#7100)
* Revert "Update fastssz (#6760)"

This reverts commit 78a25f99c3.
* Merge refs/heads/master into revert-6760-update-fssz
2020-08-24 20:06:28 +00:00

37 lines
1.4 KiB
Go

package kv
import (
"testing"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-bitfield"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
func TestAttCaches_hasSeenBit(t *testing.T) {
c := NewAttCaches()
d := &ethpb.AttestationData{}
seenA1 := &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b10000011}}
seenA2 := &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b11100000}}
require.NoError(t, c.insertSeenBit(seenA1))
require.NoError(t, c.insertSeenBit(seenA2))
tests := []struct {
att *ethpb.Attestation
want bool
}{
{att: &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b10000000}}, want: true},
{att: &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b10000001}}, want: true},
{att: &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b11100000}}, want: true},
{att: &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b10000011}}, want: true},
{att: &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b00001000}}, want: false},
{att: &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b11110111}}, want: false},
}
for _, tt := range tests {
got, err := c.hasSeenBit(tt.att)
require.NoError(t, err)
if got != tt.want {
t.Errorf("hasSeenBit() got = %v, want %v", got, tt.want)
}
}
}