### Question:
PendingTransactionsMessageSender { public void sendTransactionsToPeers() { StreamSupport.stream(transactionTracker.getEthPeersWithUnsentTransactions().spliterator(), true) .parallel() .forEach(this::sendTransactionsToPeer); } PendingTransactionsMessageSender(final PeerPendingTransactionTracker transactionTracker); void sendTransactionsToPeers();  }### Answer:
@Test public void shouldSendPendingTransactionsToEachPeer() throws Exception { transactionTracker.addToPeerSendQueue(peer1, transaction1); transactionTracker.addToPeerSendQueue(peer1, transaction2); transactionTracker.addToPeerSendQueue(peer2, transaction3); messageSender.sendTransactionsToPeers(); verify(peer1).send(transactionsMessageContaining(transaction1, transaction2)); verify(peer2).send(transactionsMessageContaining(transaction3)); verifyNoMoreInteractions(peer1, peer2); }
@Test public void shouldSendTransactionsInBatchesWithLimit() throws Exception { final Set<Hash> transactions = generator.transactions(6000).stream().map(Transaction::getHash).collect(Collectors.toSet()); transactions.forEach(transaction -> transactionTracker.addToPeerSendQueue(peer1, transaction)); messageSender.sendTransactionsToPeers(); final ArgumentCaptor<MessageData> messageDataArgumentCaptor = ArgumentCaptor.forClass(MessageData.class); verify(peer1, times(2)).send(messageDataArgumentCaptor.capture()); final List<MessageData> sentMessages = messageDataArgumentCaptor.getAllValues(); assertThat(sentMessages).hasSize(2); assertThat(sentMessages) .allMatch(message -> message.getCode() == EthPV65.NEW_POOLED_TRANSACTION_HASHES); final Set<Hash> firstBatch = getTransactionsFromMessage(sentMessages.get(0)); final Set<Hash> secondBatch = getTransactionsFromMessage(sentMessages.get(1)); final int expectedFirstBatchSize = 4096, expectedSecondBatchSize = 1904, toleranceDelta = 0; assertThat(firstBatch) .hasSizeBetween( expectedFirstBatchSize - toleranceDelta, expectedFirstBatchSize + toleranceDelta); assertThat(secondBatch) .hasSizeBetween( expectedSecondBatchSize - toleranceDelta, expectedSecondBatchSize + toleranceDelta); assertThat(Sets.union(firstBatch, secondBatch)).isEqualTo(transactions); }