Skip to content

Commit

Permalink
check nodes are producing blocks and synced before sending tx (hyperl…
Browse files Browse the repository at this point in the history
…edger#6975)

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
  • Loading branch information
macfarla authored Apr 22, 2024
1 parent 381e692 commit 5ac2254
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
Expand All @@ -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));

Expand Down

0 comments on commit 5ac2254

Please sign in to comment.