github.com/prysmaticlabs/prysm@v1.4.4/beacon-chain/cache/attestation_data_test.go (about) 1 package cache_test 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/prysmaticlabs/prysm/beacon-chain/cache" 8 ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" 9 "github.com/prysmaticlabs/prysm/shared/testutil/assert" 10 "google.golang.org/protobuf/proto" 11 ) 12 13 func TestAttestationCache_RoundTrip(t *testing.T) { 14 ctx := context.Background() 15 c := cache.NewAttestationCache() 16 17 req := ðpb.AttestationDataRequest{ 18 CommitteeIndex: 0, 19 Slot: 1, 20 } 21 22 response, err := c.Get(ctx, req) 23 assert.NoError(t, err) 24 assert.Equal(t, (*ethpb.AttestationData)(nil), response) 25 26 assert.NoError(t, c.MarkInProgress(req)) 27 28 res := ðpb.AttestationData{ 29 Target: ðpb.Checkpoint{Epoch: 5, Root: make([]byte, 32)}, 30 } 31 32 assert.NoError(t, c.Put(ctx, req, res)) 33 assert.NoError(t, c.MarkNotInProgress(req)) 34 35 response, err = c.Get(ctx, req) 36 assert.NoError(t, err) 37 38 if !proto.Equal(response, res) { 39 t.Error("Expected equal protos to return from cache") 40 } 41 }