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

Commit

Permalink
IBFT Acceptance tests updated with longer timeout on first block (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
rain-on authored and ajsutton committed Feb 28, 2019
1 parent 5986da9 commit fd89f41
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class WaitUtils {
public static void waitFor(final ThrowingRunnable condition) {
Awaitility.await().ignoreExceptions().atMost(30, TimeUnit.SECONDS).untilAsserted(condition);
waitFor(30, condition);
}

public static void waitFor(final int timeout, final ThrowingRunnable condition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@
public class ExpectBlockNumberAbove implements Condition {
private final EthTransactions eth;
private final BigInteger blockNumber;
private final int timeout;

public ExpectBlockNumberAbove(final EthTransactions eth, final BigInteger blockNumber) {
this(eth, blockNumber, 30);
}

public ExpectBlockNumberAbove(
final EthTransactions eth, final BigInteger blockNumber, final int timeout) {
this.eth = eth;
this.blockNumber = blockNumber;
this.timeout = timeout;
}

@Override
public void verify(final Node node) {
waitFor(() -> assertThat(node.execute(eth.blockNumber())).isGreaterThanOrEqualTo(blockNumber));
waitFor(
timeout,
() -> assertThat(node.execute(eth.blockNumber())).isGreaterThanOrEqualTo(blockNumber));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ public WaitCondition chainHeadHasProgressedByAtLeast(
return new ExpectBlockNumberAbove(eth, futureBlock)::verify;
}

public WaitCondition chainHeadHasProgressedByAtLeast(
final PantheonNode node, final int blocksAheadOfLatest, final int timeout) {
final BigInteger futureBlock =
node.execute(eth.blockNumber()).add(BigInteger.valueOf(blocksAheadOfLatest));
return new ExpectBlockNumberAbove(eth, futureBlock, timeout)::verify;
}

public WaitCondition cliqueValidatorsChanged(final Node node) {
return new WaitUntilSignersChanged(node.execute(clique.createGetSigners(LATEST)), clique);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class IbftMiningAcceptanceTest extends AcceptanceTestBase {
public void shouldMineOnSingleNode() throws IOException {
final PantheonNode minerNode = pantheon.createIbftNode("miner1");
cluster.start(minerNode);

cluster.waitUntil(wait.chainHeadHasProgressedByAtLeast(minerNode, 1));

final Account sender = accounts.createAccount("account1");
Expand All @@ -50,7 +51,7 @@ public void shouldMineOnMultipleNodes() throws IOException {
final PantheonNode minerNode4 = pantheon.createIbftNode("miner4");
cluster.start(minerNode1, minerNode2, minerNode3, minerNode4);

cluster.waitUntil(wait.chainHeadHasProgressedByAtLeast(minerNode1, 1));
cluster.waitUntil(wait.chainHeadHasProgressedByAtLeast(minerNode1, 1, 85));

final Account sender = accounts.createAccount("account1");
final Account receiver = accounts.createAccount("account2");
Expand Down Expand Up @@ -78,7 +79,7 @@ public void shouldMineOnMultipleNodesEvenWhenClusterContainsNonValidator() throw
pantheon.createIbftNodeWithValidators("non-validator", validators);
cluster.start(validator1, validator2, validator3, nonValidatorNode);

cluster.waitUntil(wait.chainHeadHasProgressedByAtLeast(validator1, 1));
cluster.waitUntil(wait.chainHeadHasProgressedByAtLeast(validator1, 1, 85));

final Account sender = accounts.createAccount("account1");
final Account receiver = accounts.createAccount("account2");
Expand All @@ -105,7 +106,7 @@ public void shouldStillMineWhenANonProposerNodeFailsAndHasSufficientValidators()
final PantheonNode nonProposerNode = validators.get(validators.size() - 1);
cluster.start(validators);

cluster.waitUntil(wait.chainHeadHasProgressedByAtLeast(validators.get(0), 1));
cluster.waitUntil(wait.chainHeadHasProgressedByAtLeast(minerNode1, 1, 85));

final Account receiver = accounts.createAccount("account2");

Expand Down

0 comments on commit fd89f41

Please sign in to comment.