### Question:
State { public void receiveGossipMessage(Peer peer, String attributes, Bytes message, Bytes messageHash) { Bytes checkHash = messageHashingFunction.hash(message); if (!checkHash.equals(messageHash)) { return; } peerRepository.considerNewPeer(peer); MessageHandler handler = messageHandlers.computeIfAbsent(messageHash, MessageHandler::new); handler.fullMessageReceived(peer, attributes, message); } State(
      PeerRepository peerRepository,
      MessageHashing messageHashingFunction,
      MessageSender messageSender,
      MessageListener messageListener,
      MessageValidator messageValidator,
      PeerPruning peerPruningFunction);  State(
      PeerRepository peerRepository,
      MessageHashing messageHashingFunction,
      MessageSender messageSender,
      MessageListener messageListener,
      MessageValidator messageValidator,
      PeerPruning peerPruningFunction,
      long graftDelay,
      long lazyQueueInterval); void addPeer(Peer peer); void removePeer(Peer peer); void receiveGossipMessage(Peer peer, String attributes, Bytes message, Bytes messageHash); void receiveIHaveMessage(Peer peer, Bytes messageHash); void receivePruneMessage(Peer peer); void receiveGraftMessage(Peer peer, Bytes messageHash); Bytes sendGossipMessage(String attributes, Bytes message); void stop();  }### Answer:
@Test void receiveFullMessageFromUnknownPeer() { EphemeralPeerRepository repo = new EphemeralPeerRepository(); MockMessageSender messageSender = new MockMessageSender(); State state = new State(repo, Hash::keccak256, messageSender, messageListener, (message, peer) -> true, (peer) -> true); Peer peer = new PeerImpl(); Bytes message = Bytes32.random(); String attributes = "{\"message_type\": \"BLOCK\"}"; state.receiveGossipMessage(peer, attributes, message, Hash.keccak256(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, messageListener, (message, peer) -> true, (peer) -> true); Peer peer = new PeerImpl(); Peer secondPeer = new PeerImpl(); Bytes message = Bytes32.random(); String attributes = "{\"message_type\": \"BLOCK\"}"; state.receiveGossipMessage(peer, attributes, message, Hash.keccak256(message)); state.receiveGossipMessage(secondPeer, attributes, message, Hash.keccak256(message)); assertEquals(2, repo.eagerPushPeers().size()); assertEquals(0, repo.lazyPushPeers().size()); assertNull(messageSender.payload); assertEquals(secondPeer, messageSender.peer); assertEquals(MessageSender.Verb.PRUNE, messageSender.verb); }