diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/WaitUtils.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/WaitUtils.java index 235553adee..a02701d0a8 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/WaitUtils.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/WaitUtils.java @@ -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) { diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/blockchain/ExpectBlockNumberAbove.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/blockchain/ExpectBlockNumberAbove.java index 9f67cd5127..471d3024c0 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/blockchain/ExpectBlockNumberAbove.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/blockchain/ExpectBlockNumberAbove.java @@ -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)); } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/waitcondition/WaitConditions.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/waitcondition/WaitConditions.java index 6a17848d90..ebb3b8ede2 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/waitcondition/WaitConditions.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/waitcondition/WaitConditions.java @@ -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); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftMiningAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftMiningAcceptanceTest.java index 192f256a1a..fcbf42fd28 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftMiningAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftMiningAcceptanceTest.java @@ -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"); @@ -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"); @@ -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"); @@ -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");