@ -12,9 +12,13 @@
* /
package tech.pegasys.pantheon.ethereum.eth.transactions ;
import static java.time.Duration.ofMillis ;
import static java.time.Duration.ofMinutes ;
import static java.time.Instant.now ;
import static java.util.Arrays.asList ;
import static org.mockito.Mockito.mock ;
import static org.mockito.Mockito.verify ;
import static org.mockito.Mockito.verifyZeroInteractions ;
import tech.pegasys.pantheon.ethereum.core.BlockDataGenerator ;
import tech.pegasys.pantheon.ethereum.core.Transaction ;
@ -41,7 +45,10 @@ public class TransactionsMessageProcessorTest {
@Test
public void shouldMarkAllReceivedTransactionsAsSeen ( ) {
messageHandler . processTransactionsMessage (
peer1 , TransactionsMessage . create ( asList ( transaction1 , transaction2 , transaction3 ) ) ) ;
peer1 ,
TransactionsMessage . create ( asList ( transaction1 , transaction2 , transaction3 ) ) ,
now ( ) ,
ofMinutes ( 1 ) ) ;
verify ( transactionTracker )
. markTransactionsAsSeen ( peer1 , ImmutableSet . of ( transaction1 , transaction2 , transaction3 ) ) ;
@ -50,9 +57,31 @@ public class TransactionsMessageProcessorTest {
@Test
public void shouldAddReceivedTransactionsToTransactionPool ( ) {
messageHandler . processTransactionsMessage (
peer1 , TransactionsMessage . create ( asList ( transaction1 , transaction2 , transaction3 ) ) ) ;
peer1 ,
TransactionsMessage . create ( asList ( transaction1 , transaction2 , transaction3 ) ) ,
now ( ) ,
ofMinutes ( 1 ) ) ;
verify ( transactionPool )
. addRemoteTransactions ( ImmutableSet . of ( transaction1 , transaction2 , transaction3 ) ) ;
}
@Test
public void shouldNotMarkReceivedExpiredTransactionsAsSeen ( ) {
messageHandler . processTransactionsMessage (
peer1 ,
TransactionsMessage . create ( asList ( transaction1 , transaction2 , transaction3 ) ) ,
now ( ) . minus ( ofMinutes ( 1 ) ) ,
ofMillis ( 1 ) ) ;
verifyZeroInteractions ( transactionTracker ) ;
}
@Test
public void shouldNotAddReceivedTransactionsToTransactionPoolIfExpired ( ) {
messageHandler . processTransactionsMessage (
peer1 ,
TransactionsMessage . create ( asList ( transaction1 , transaction2 , transaction3 ) ) ,
now ( ) . minus ( ofMinutes ( 1 ) ) ,
ofMillis ( 1 ) ) ;
verifyZeroInteractions ( transactionPool ) ;
}
}