mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
0326be86b5
* starting on patch * finish determining all required patches * properly redefine the patch rules * new patch * rem double semicolon * fix patch file * Merge branch 'master' of github.com:prysmaticlabs/prysm into deprecate-eth-protos * building the deps * test target passes using ethereumapis * compile gateway * attempting to build everything * e2e use ethereumapis * more fixes for slasher * other item * getting closer to compiling slasher * build slasher package * Merge branch 'master' into deprecate-eth-protos * Merge branch 'master' into deprecate-eth-protos * fix benches * lint gazelle * Merge branch 'deprecate-eth-protos' of github.com:prysmaticlabs/prysm into deprecate-eth-protos * proper gateway * lint * Merge branch 'master' into deprecate-eth-protos * fix build * Merge branch 'deprecate-eth-protos' of github.com:prysmaticlabs/prysm into deprecate-eth-protos * use swag * resolve * ignore change * include new patch changes * fix test * builds * fix e2e * gaz
56 lines
1.0 KiB
Go
56 lines
1.0 KiB
Go
package cache_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
|
|
)
|
|
|
|
func TestAttestationCache_RoundTrip(t *testing.T) {
|
|
ctx := context.Background()
|
|
c := cache.NewAttestationCache()
|
|
|
|
req := &pb.AttestationRequest{
|
|
CommitteeIndex: 0,
|
|
Slot: 1,
|
|
}
|
|
|
|
response, err := c.Get(ctx, req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
if response != nil {
|
|
t.Errorf("Empty cache returned an object: %v", response)
|
|
}
|
|
|
|
if err := c.MarkInProgress(req); err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
res := ðpb.AttestationData{
|
|
Target: ðpb.Checkpoint{Epoch: 5},
|
|
}
|
|
|
|
if err = c.Put(ctx, req, res); err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
if err := c.MarkNotInProgress(req); err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
response, err = c.Get(ctx, req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
if !proto.Equal(response, res) {
|
|
t.Error("Expected equal protos to return from cache")
|
|
}
|
|
}
|