github.com/prysmaticlabs/prysm@v1.4.4/beacon-chain/sync/fuzz_exports.go (about) 1 // +build libfuzzer 2 3 package sync 4 5 import ( 6 "context" 7 "time" 8 9 "github.com/libp2p/go-libp2p-core/peer" 10 pubsub "github.com/libp2p/go-libp2p-pubsub" 11 gcache "github.com/patrickmn/go-cache" 12 ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" 13 "google.golang.org/protobuf/proto" 14 ) 15 16 // NewRegularSyncFuzz service without registering handlers. 17 func NewRegularSyncFuzz(cfg *Config) *Service { 18 rLimiter := newRateLimiter(cfg.P2P) 19 ctx, cancel := context.WithCancel(context.Background()) 20 r := &Service{ 21 cfg: cfg, 22 ctx: ctx, 23 cancel: cancel, 24 slotToPendingBlocks: gcache.New(time.Second, 2*time.Second), 25 seenPendingBlocks: make(map[[32]byte]bool), 26 blkRootToPendingAtts: make(map[[32]byte][]*ethpb.SignedAggregateAttestationAndProof), 27 rateLimiter: rLimiter, 28 } 29 30 return r 31 } 32 33 // FuzzValidateBeaconBlockPubSub exports private method validateBeaconBlockPubSub for fuzz testing. 34 func (s *Service) FuzzValidateBeaconBlockPubSub(ctx context.Context, pid peer.ID, msg *pubsub.Message) pubsub.ValidationResult { 35 return s.validateBeaconBlockPubSub(ctx, pid, msg) 36 } 37 38 // FuzzBeaconBlockSubscriber exports private method beaconBlockSubscriber for fuzz testing. 39 func (s *Service) FuzzBeaconBlockSubscriber(ctx context.Context, msg proto.Message) error { 40 return s.beaconBlockSubscriber(ctx, msg) 41 } 42 43 func (s *Service) InitCaches() error { 44 return s.initCaches() 45 }