From 5ac225442f60fb068898241a2e51a3276b5b2f0e Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Mon, 22 Apr 2024 18:12:08 +1000 Subject: [PATCH] check nodes are producing blocks and synced before sending tx (#6975) Signed-off-by: Sally MacFarlane --- .../clique/CliqueMiningAcceptanceTest.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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 50c58f8b34b..f6718b4ded1 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 @@ -86,7 +86,7 @@ public void shouldMineTransactionsOnMultipleNodes() throws IOException { final BesuNode minerNode1 = besu.createCliqueNode("miner1"); final BesuNode minerNode2 = besu.createCliqueNode("miner2"); final BesuNode minerNode3 = besu.createCliqueNode("miner3"); - cluster.start(minerNode1, minerNode2, minerNode3); + startClusterAndVerifyProducingBlocks(minerNode1, minerNode2, minerNode3); final Account sender = accounts.createAccount("account1"); final Account receiver = accounts.createAccount("account2"); @@ -106,7 +106,7 @@ public void shouldStallMiningWhenInsufficientValidators() throws IOException { final BesuNode minerNode1 = besu.createCliqueNode("miner1"); final BesuNode minerNode2 = besu.createCliqueNode("miner2"); final BesuNode minerNode3 = besu.createCliqueNode("miner3"); - cluster.start(minerNode1, minerNode2, minerNode3); + startClusterAndVerifyProducingBlocks(minerNode1, minerNode2, minerNode3); cluster.stopNode(minerNode2); cluster.stopNode(minerNode3); @@ -116,12 +116,23 @@ public void shouldStallMiningWhenInsufficientValidators() throws IOException { minerNode1.verify(clique.noNewBlockCreated(minerNode1)); } + private void startClusterAndVerifyProducingBlocks( + final BesuNode minerNode1, final BesuNode minerNode2, final BesuNode minerNode3) { + cluster.start(minerNode1, minerNode2, minerNode3); + + // verify that we have started producing blocks + waitForBlockHeight(minerNode1, 1); + final var minerChainHead = minerNode1.execute(ethTransactions.block()); + minerNode2.verify(blockchain.minimumHeight(minerChainHead.getNumber().longValue())); + minerNode3.verify(blockchain.minimumHeight(minerChainHead.getNumber().longValue())); + } + @Test public void shouldStillMineWhenANodeFailsAndHasSufficientValidators() throws IOException { final BesuNode minerNode1 = besu.createCliqueNode("miner1"); final BesuNode minerNode2 = besu.createCliqueNode("miner2"); final BesuNode minerNode3 = besu.createCliqueNode("miner3"); - cluster.start(minerNode1, minerNode2, minerNode3); + startClusterAndVerifyProducingBlocks(minerNode1, minerNode2, minerNode3); cluster.verifyOnActiveNodes(blockchain.reachesHeight(minerNode1, 1, 85));