prysm-pulse/beacon-chain/operations/attestations/kv/seen_bits_test.go
Preston Van Loon 78a25f99c3
Update fastssz (#6760)
* Update fastssz
* Merge branch 'master' of github.com:prysmaticlabs/prysm into update-fssz
* fmt
* gaz
* Merge refs/heads/master into update-fssz
* goimports
* Merge refs/heads/master into update-fssz
* Merge refs/heads/master into update-fssz
* Merge refs/heads/master into update-fssz
* Merge refs/heads/master into update-fssz
* Merge refs/heads/master into update-fssz
* Fix
* fix ethereumapis
* fix again
* kafka
* fix gen file
* fix compute signing root
* gofmt
* checkpoint progress
* progress
* checkpoint
* progress
* Fix build
* checkpoint
* helpers
* Another test fixed
* gaz
* another test fix
* gofmt
* some fixes
* Merge branch 'master' of github.com:prysmaticlabs/prysm into update-fssz
* fix one test
* Merge branch 'master' of github.com:prysmaticlabs/prysm into update-fssz
* fill empty checkpoint roots
* more padding
* more padding
* Fix //beacon-chain/rpc/debug:go_default_test
* fix //beacon-chain/core/state:go_default_test
* fix //beacon-chain/core/state:go_default_test
* fix some htr errors
* fix //slasher/rpc:go_default_test
* Progress on //beacon-chain/core/blocks:go_default_test
* Progress on //beacon-chain/core/blocks:go_default_test
* Progress on //beacon-chain/core/blocks:go_default_test
* fix //slasher/db/kv:go_default_test
* progress
* fix //beacon-chain/sync/initial-sync:go_raceon_test
* gofmt and gaz
* fix one more test, taking a break
* Fix //beacon-chain/core/blocks:go_default_test
* Complete beacon-chain/powchain
* Do most of beacon-chain/rpc/beacon/
* Do most of beacon-chain/blockchain
* fix //beacon-chain/operations/attestations/kv:go_default_test
* Fix //beacon-chain/cache/depositcache:go_default_test
* Fix //slasher/detection:go_default_test
* Progress
* fix //beacon-chain/rpc/validator:go_default_test
* gofmt
* fix //validator/client:go_default_test
* fix
* fix //beacon-chain/blockchain:go_raceoff_test
* fix //beacon-chain/rpc/beacon:go_default_test
* fix 1 of 4 shards in //beacon-chain/sync:go_default_test
* Fix //beacon-chain/sync:go_default_test and gofmt
* prevent panic
* fix //beacon-chain/state/stategen:go_default_test
* fix
* Merge branch 'master' of github.com:prysmaticlabs/prysm into update-fssz
* fix most tests
* Self review, go mod tidy, run regen scripts
* fix slasher
* Update ethereumapis
* disable spawn strategy override
* Merge refs/heads/master into update-fssz
* Merge refs/heads/master into update-fssz
* Remove extra line in imports
* Remove extra line in imports
* Gofmt
* PR feedback from @nisdas
2020-08-24 01:46:17 +00:00

41 lines
1.7 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{
Source: &ethpb.Checkpoint{Root: make([]byte, 32)},
Target: &ethpb.Checkpoint{Root: make([]byte, 32)},
BeaconBlockRoot: make([]byte, 32),
}
seenA1 := &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b10000011}, Signature: make([]byte, 96)}
seenA2 := &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b11100000}, Signature: make([]byte, 96)}
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}, Signature: make([]byte, 96)}, want: true},
{att: &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b10000001}, Signature: make([]byte, 96)}, want: true},
{att: &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b11100000}, Signature: make([]byte, 96)}, want: true},
{att: &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b10000011}, Signature: make([]byte, 96)}, want: true},
{att: &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b00001000}, Signature: make([]byte, 96)}, want: false},
{att: &ethpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b11110111}, Signature: make([]byte, 96)}, 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)
}
}
}