### Question:
PendingTransactionsMessageProcessor { void processNewPooledTransactionHashesMessage( final EthPeer peer, final NewPooledTransactionHashesMessage transactionsMessage, final Instant startedAt, final Duration keepAlive) { if (startedAt.plus(keepAlive).isAfter(now())) { this.processNewPooledTransactionHashesMessage(peer, transactionsMessage); } else { totalSkippedTransactionsMessageCounter.inc(); } } PendingTransactionsMessageProcessor(
      final PeerPendingTransactionTracker transactionTracker,
      final TransactionPool transactionPool,
      final Counter metricsCounter,
      final EthContext ethContext,
      final MetricsSystem metricsSystem,
      final SyncState syncState);   }### Answer:
@Test public void shouldMarkAllReceivedTransactionsAsSeen() { messageHandler.processNewPooledTransactionHashesMessage( peer1, NewPooledTransactionHashesMessage.create(asList(hash1, hash2, hash3)), now(), ofMinutes(1)); verify(transactionTracker) .markTransactionsHashesAsSeen(peer1, Arrays.asList(hash1, hash2, hash3)); verifyNoMoreInteractions(transactionTracker); }
@Test public void shouldAddInitiatedRequestingTransactions() { when(syncState.isInSync(anyLong())).thenReturn(true); messageHandler.processNewPooledTransactionHashesMessage( peer1, NewPooledTransactionHashesMessage.create(asList(hash1, hash2, hash3)), now(), ofMinutes(1)); verify(transactionPool).addTransactionHash(hash1); verify(transactionPool).addTransactionHash(hash2); verify(transactionPool).addTransactionHash(hash3); verifyNoMoreInteractions(transactionPool); }
@Test public void shouldNotAddInitiatedRequestingTransactionsWhemOutOfSync() { when(syncState.isInSync(anyLong())).thenReturn(false); messageHandler.processNewPooledTransactionHashesMessage( peer1, NewPooledTransactionHashesMessage.create(asList(hash1, hash2, hash3)), now(), ofMinutes(1)); verifyNoInteractions(transactionPool); }
@Test public void shouldNotMarkReceivedExpiredTransactionsAsSeen() { messageHandler.processNewPooledTransactionHashesMessage( peer1, NewPooledTransactionHashesMessage.create(asList(hash1, hash2, hash3)), now().minus(ofMinutes(1)), ofMillis(1)); verifyNoInteractions(transactionTracker); verify(totalSkippedTransactionsMessageCounter).inc(1); verifyNoMoreInteractions(totalSkippedTransactionsMessageCounter); }
@Test public void shouldNotAddReceivedTransactionsToTransactionPoolIfExpired() { messageHandler.processNewPooledTransactionHashesMessage( peer1, NewPooledTransactionHashesMessage.create(asList(hash1, hash2, hash3)), now().minus(ofMinutes(1)), ofMillis(1)); verifyNoInteractions(transactionPool); verify(totalSkippedTransactionsMessageCounter).inc(1); verifyNoMoreInteractions(totalSkippedTransactionsMessageCounter); }