### Question:
State { public void receiveGossipMessage(Peer peer, Bytes message) { peerRepository.considerNewPeer(peer); MessageHandler handler = messageHandlers.computeIfAbsent(messageHashingFunction.hash(message), MessageHandler::new); handler.fullMessageReceived(peer, message); } State(
      PeerRepository peerRepository,
      MessageHashing messageHashingFunction,
      MessageSender messageSender,
      Consumer<Bytes> messageListener,
      MessageValidator messageValidator);  State(
      PeerRepository peerRepository,
      MessageHashing messageHashingFunction,
      MessageSender messageSender,
      Consumer<Bytes> messageListener,
      MessageValidator messageValidator,
      long graftDelay,
      long lazyQueueInterval); void addPeer(Peer peer); void removePeer(Peer peer); void receiveGossipMessage(Peer peer, Bytes message); void receiveIHaveMessage(Peer peer, Bytes messageHash); void receivePruneMessage(Peer peer); void receiveGraftMessage(Peer peer, Bytes messageHash); void sendGossipMessage(Bytes message); void stop();  }### Answer:
@Test void receiveFullMessageFromUnknownPeer() { EphemeralPeerRepository repo = new EphemeralPeerRepository(); MockMessageSender messageSender = new MockMessageSender(); State state = new State(repo, Hash::keccak256, messageSender, messageRef::set, (message, peer) -> true); Peer peer = new PeerImpl(); Bytes message = Bytes32.random(); state.receiveGossipMessage(peer, message); assertEquals(1, repo.eagerPushPeers().size()); assertEquals(0, repo.lazyPushPeers().size()); assertEquals(peer, repo.eagerPushPeers().iterator().next()); }
@Test void prunePeerWhenReceivingTwiceTheSameFullMessage() { EphemeralPeerRepository repo = new EphemeralPeerRepository(); MockMessageSender messageSender = new MockMessageSender(); State state = new State(repo, Hash::keccak256, messageSender, messageRef::set, (message, peer) -> true); Peer peer = new PeerImpl(); Peer secondPeer = new PeerImpl(); Bytes message = Bytes32.random(); state.receiveGossipMessage(peer, message); state.receiveGossipMessage(secondPeer, message); assertEquals(1, repo.eagerPushPeers().size()); assertEquals(1, repo.lazyPushPeers().size()); assertNull(messageSender.payload); assertEquals(secondPeer, messageSender.peer); assertEquals(MessageSender.Verb.PRUNE, messageSender.verb); }