diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/transactions/PendingTransactions.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/transactions/PendingTransactions.java index 3b4db7859b..6f585465c2 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/transactions/PendingTransactions.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/transactions/PendingTransactions.java @@ -103,12 +103,8 @@ public PendingTransactions( public void evictOldTransactions() { synchronized (pendingTransactions) { - final Instant removeTransactionsBefore = clock.instant().minus(maxTransactionRetentionHours, ChronoUnit.HOURS); - - System.out.println("clock.instant(): " + clock.instant()); - System.out.println("maxTransactionRetentionHours: " + maxTransactionRetentionHours); - System.out.println("clock.instant().minus(maxTransactionRetentionHours, ChronoUnit.HOURS): " + clock.instant().minus(maxTransactionRetentionHours, ChronoUnit.HOURS)); - + final Instant removeTransactionsBefore = + clock.instant().minus(maxTransactionRetentionHours, ChronoUnit.HOURS); final List transactionsToRemove = prioritizedTransactions.stream() .filter( diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/PendingTransactionsTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/PendingTransactionsTest.java index 9178334638..77693bd794 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/PendingTransactionsTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/PendingTransactionsTest.java @@ -418,7 +418,7 @@ private Transaction createTransaction(final int transactionNumber) { @Test public void shouldEvictMultipleOldTransactions() { - final int maxTransactionRetentionHours = 1000; + final int maxTransactionRetentionHours = 1; final PendingTransactions transactions = new PendingTransactions( maxTransactionRetentionHours, MAX_TRANSACTIONS, clock, metricsSystem); @@ -428,7 +428,7 @@ public void shouldEvictMultipleOldTransactions() { transactions.addRemoteTransaction(transaction2); assertThat(transactions.size()).isEqualTo(2); - clock.stepMillis(2000); + clock.step(2L, ChronoUnit.HOURS); transactions.evictOldTransactions(); assertThat(transactions.size()).isEqualTo(0); } @@ -441,9 +441,7 @@ public void shouldEvictSingleOldTransaction() { maxTransactionRetentionHours, MAX_TRANSACTIONS, clock, metricsSystem); transactions.addRemoteTransaction(transaction1); assertThat(transactions.size()).isEqualTo(1); - clock.step(2L, ChronoUnit.HOURS); - transactions.evictOldTransactions(); assertThat(transactions.size()).isEqualTo(0); } @@ -456,7 +454,7 @@ public void shouldEvictExclusivelyOldTransactions() { maxTransactionRetentionHours, MAX_TRANSACTIONS, clock, metricsSystem); transactions.addRemoteTransaction(transaction1); assertThat(transactions.size()).isEqualTo(1); - clock.stepMillis(2001); + clock.step(3L, ChronoUnit.HOURS); transactions.addRemoteTransaction(transaction2); assertThat(transactions.size()).isEqualTo(2); transactions.evictOldTransactions(); diff --git a/testutil/src/main/java/tech/pegasys/pantheon/testutil/TestClock.java b/testutil/src/main/java/tech/pegasys/pantheon/testutil/TestClock.java index 2f9f3eb358..1ff18a8c82 100644 --- a/testutil/src/main/java/tech/pegasys/pantheon/testutil/TestClock.java +++ b/testutil/src/main/java/tech/pegasys/pantheon/testutil/TestClock.java @@ -16,7 +16,6 @@ import java.time.Instant; import java.time.ZoneId; import java.time.ZoneOffset; -import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalUnit; public class TestClock extends Clock {