From edf36dfce87691e75bf35f4cf97d56478d9a9563 Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta <45264458+abdelhamidbakhta@users.noreply.github.com> Date: Mon, 8 Jul 2019 21:28:19 +0200 Subject: [PATCH] [PAN-2871] Intermittent Test Failures in TransactionsMessageSenderTest (#1653) Add tolerance delta in test. Generated transaction data sizes are sometimes differents, the number of transactions in each batch may vary a bit, the tolerance delta helps dealing with such cases. The most important thing in this test is the assertion verifying that the union of all batches equals to the original list of messages to send. --- .../eth/transactions/TransactionsMessageSenderTest.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionsMessageSenderTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionsMessageSenderTest.java index 27d26d32b0..36beb0595c 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionsMessageSenderTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionsMessageSenderTest.java @@ -79,8 +79,13 @@ public void shouldSendTransactionsInBatchesWithLimit() throws Exception { final Set firstBatch = getTransactionsFromMessage(sentMessages.get(0)); final Set secondBatch = getTransactionsFromMessage(sentMessages.get(1)); - assertThat(firstBatch).hasSize(5219); - assertThat(secondBatch).hasSize(781); + 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); }