Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Fix non-deterministic test caused by variable size of generated trans…
Browse files Browse the repository at this point in the history
…actions (#1399)

Fix non-deterministic test caused by variable size of generated transactions. 
Validate transactions against a size range rather than a fixed size
* Use assertj instead of own method.
  • Loading branch information
AbdelStark authored May 6, 2019
1 parent c07849e commit a2535ce
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package tech.pegasys.pantheon.ethereum.eth.messages;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static tech.pegasys.pantheon.ethereum.eth.messages.LimitedTransactionsMessages.LIMIT;
Expand Down Expand Up @@ -40,12 +41,13 @@ public class LimitedTransactionsMessagesTest {
public void createLimited() {
final Set<Transaction> txs = generator.transactions(6000);
final LimitedTransactionsMessages firstMessage = LimitedTransactionsMessages.createLimited(txs);
assertEquals(5219, firstMessage.getIncludedTransactions().size());
assertThat(firstMessage.getIncludedTransactions().size()).isBetween(4990, 5250);

txs.removeAll(firstMessage.getIncludedTransactions());
assertEquals(781, txs.size());
assertThat(txs.size()).isBetween(700, 800);
final LimitedTransactionsMessages secondMessage =
LimitedTransactionsMessages.createLimited(txs);
assertEquals(781, secondMessage.getIncludedTransactions().size());
assertThat(secondMessage.getIncludedTransactions().size()).isBetween(700, 800);
txs.removeAll(secondMessage.getIncludedTransactions());
assertEquals(0, txs.size());
assertTrue(
Expand Down

0 comments on commit a2535ce

Please sign in to comment.