diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java index f2bae445806..fd8566e3826 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java @@ -120,6 +120,11 @@ private void startClusterAndVerifyProducingBlocks( final BesuNode minerNode1, final BesuNode minerNode2, final BesuNode minerNode3) { cluster.start(minerNode1, minerNode2, minerNode3); + // verify nodes are fully connected otherwise blocks could not be propagated + minerNode1.verify(net.awaitPeerCount(2)); + minerNode2.verify(net.awaitPeerCount(2)); + minerNode3.verify(net.awaitPeerCount(2)); + // verify that we have started producing blocks waitForBlockHeight(minerNode1, 1); final var minerChainHead = minerNode1.execute(ethTransactions.block()); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposeRpcAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposeRpcAcceptanceTest.java index 1674c551a4b..405f56fd93b 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposeRpcAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposeRpcAcceptanceTest.java @@ -33,6 +33,8 @@ public void shouldAddValidators() throws IOException { final BesuNode minerNode3 = besu.createCliqueNodeWithValidators("miner3", initialValidators); cluster.start(minerNode1, minerNode2, minerNode3); + waitForNodesConnectedAndInSync(minerNode1, minerNode2, minerNode3); + cluster.verify(clique.validatorsEqual(minerNode1, minerNode2)); minerNode1.execute(cliqueTransactions.createAddProposal(minerNode3)); minerNode2.execute(cliqueTransactions.createAddProposal(minerNode3)); @@ -47,6 +49,8 @@ public void shouldRemoveValidators() throws IOException { final BesuNode minerNode3 = besu.createCliqueNodeWithValidators("miner3", initialValidators); cluster.start(minerNode1, minerNode2, minerNode3); + waitForNodesConnectedAndInSync(minerNode1, minerNode2, minerNode3); + cluster.verify(clique.validatorsEqual(minerNode1, minerNode2, minerNode3)); final Condition cliqueValidatorsChanged = clique.awaitSignerSetChange(minerNode1); minerNode1.execute(cliqueTransactions.createRemoveProposal(minerNode3)); @@ -63,6 +67,8 @@ public void shouldNotAddValidatorWhenInsufficientVotes() throws IOException { final BesuNode minerNode3 = besu.createCliqueNodeWithValidators("miner3", initialValidators); cluster.start(minerNode1, minerNode2, minerNode3); + waitForNodesConnectedAndInSync(minerNode1, minerNode2, minerNode3); + cluster.verify(clique.validatorsEqual(minerNode1, minerNode2)); minerNode1.execute(cliqueTransactions.createAddProposal(minerNode3)); minerNode1.verify(blockchain.reachesHeight(minerNode1, 1)); @@ -76,6 +82,8 @@ public void shouldNotRemoveValidatorWhenInsufficientVotes() throws IOException { final BesuNode minerNode3 = besu.createCliqueNode("miner3"); cluster.start(minerNode1, minerNode2, minerNode3); + waitForNodesConnectedAndInSync(minerNode1, minerNode2, minerNode3); + cluster.verify(clique.validatorsEqual(minerNode1, minerNode2, minerNode3)); minerNode1.execute(cliqueTransactions.createRemoveProposal(minerNode3)); minerNode1.verify(blockchain.reachesHeight(minerNode1, 1)); @@ -90,6 +98,8 @@ public void shouldIncludeVoteInBlockHeader() throws IOException { final BesuNode minerNode3 = besu.createCliqueNodeWithValidators("miner3", initialValidators); cluster.start(minerNode1, minerNode2, minerNode3); + waitForNodesConnectedAndInSync(minerNode1, minerNode2, minerNode3); + minerNode1.execute(cliqueTransactions.createAddProposal(minerNode3)); minerNode1.verify(blockchain.reachesHeight(minerNode1, 1)); minerNode1.verify(blockchain.beneficiaryEquals(minerNode3)); @@ -100,4 +110,18 @@ public void shouldIncludeVoteInBlockHeader() throws IOException { minerNode1.verify(blockchain.beneficiaryEquals(minerNode2)); minerNode1.verify(clique.nonceVoteEquals(CLIQUE_NONCE_VOTE.DROP)); } + + private void waitForNodesConnectedAndInSync( + final BesuNode minerNode1, final BesuNode minerNode2, final BesuNode minerNode3) { + // verify nodes are fully connected otherwise blocks could not be propagated + minerNode1.verify(net.awaitPeerCount(2)); + minerNode2.verify(net.awaitPeerCount(2)); + minerNode3.verify(net.awaitPeerCount(2)); + + // verify that the miner started producing blocks and all other nodes are syncing from it + waitForBlockHeight(minerNode1, 1); + final var minerChainHead = minerNode1.execute(ethTransactions.block()); + minerNode2.verify(blockchain.minimumHeight(minerChainHead.getNumber().longValue())); + minerNode3.verify(blockchain.minimumHeight(minerChainHead.getNumber().longValue())); + } }