### Question:
TransactionsMessageSender { public void sendTransactionsToPeers() { StreamSupport.stream(transactionTracker.getEthPeersWithUnsentTransactions().spliterator(), true) .parallel() .forEach(this::sendTransactionsToPeer); } TransactionsMessageSender(final PeerTransactionTracker transactionTracker); void sendTransactionsToPeers();  }### Answer:
@Test public void shouldSendTransactionsToEachPeer() 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<Transaction> transactions = generator.transactions(6000); 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() == EthPV62.TRANSACTIONS); final Set<Transaction> firstBatch = getTransactionsFromMessage(sentMessages.get(0)); final Set<Transaction> secondBatch = getTransactionsFromMessage(sentMessages.get(1)); final int expectedFirstBatchSize = 5219, expectedSecondBatchSize = 781, toleranceDelta = 50; assertThat(firstBatch) .hasSizeBetween( expectedFirstBatchSize - toleranceDelta, expectedFirstBatchSize + toleranceDelta); assertThat(secondBatch) .hasSizeBetween( expectedSecondBatchSize - toleranceDelta, expectedSecondBatchSize + toleranceDelta); assertThat(Sets.union(firstBatch, secondBatch)).isEqualTo(transactions); }