[Issue-3115] Fix mining beneficiary acceptance tests (#3415)

* Fix bft acceptance tests

Only set genesis config if it is not already set.  Throw if user attempts to verify an empty cluster.
Configure genesis file with appropriate keys for consensus type.

Signed-off-by: Meredith Baxter <meredith.baxter@palm.io>

* Fix SECP256R1AcceptanceTest

Signed-off-by: Meredith Baxter <meredith.baxter@palm.io>
pull/3415/merge
mbaxter 3 years ago committed by GitHub
parent b0de73fe57
commit ba59f2317a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java
  2. 2
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftAcceptanceTestParameterization.java
  3. 10
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftBlockRewardPaymentAcceptanceTest.java
  4. 4
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/ParameterizedBftTestBase.java
  5. 2
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java

@ -152,10 +152,12 @@ public class Cluster implements AutoCloseable {
private void startNode(final RunnableNode node, final boolean isBootNode) {
node.getConfiguration().setBootnodes(isBootNode ? emptyList() : bootnodes);
node.getConfiguration()
.getGenesisConfigProvider()
.create(originalNodes)
.ifPresent(node.getConfiguration()::setGenesisConfig);
if (node.getConfiguration().getGenesisConfig().isEmpty()) {
node.getConfiguration()
.getGenesisConfigProvider()
.create(originalNodes)
.ifPresent(node.getConfiguration()::setGenesisConfig);
}
runNodeStart(node);
}
@ -188,6 +190,9 @@ public class Cluster implements AutoCloseable {
}
public void verify(final Condition expected) {
if (nodes.size() == 0) {
throw new IllegalStateException("Attempt to verify an empty cluster");
}
for (final Node node : nodes.values()) {
expected.verify(node);
}

@ -27,7 +27,7 @@ public class BftAcceptanceTestParameterization {
ret.addAll(
List.of(
new Object[] {
"ibft",
"ibft2",
new BftAcceptanceTestParameterization(
BesuNodeFactory::createIbft2Node, BesuNodeFactory::createIbft2NodeWithValidators)
},

@ -67,8 +67,12 @@ public class BftBlockRewardPaymentAcceptanceTest extends ParameterizedBftTestBas
initialConfig
.get()
.replace(
"\"ibft2\": {",
"\"ibft2\": { \"miningbeneficiary\": \"" + miningBeneficiaryAddress + "\",");
"\"" + bftType + "\": {",
"\""
+ bftType
+ "\": { \"miningbeneficiary\": \""
+ miningBeneficiaryAddress
+ "\",");
validator1.setGenesisConfig(configWithMiningBeneficiary);
@ -76,7 +80,7 @@ public class BftBlockRewardPaymentAcceptanceTest extends ParameterizedBftTestBas
Account.create(ethTransactions, Address.fromHexString(miningBeneficiaryAddress));
// This starts a node, without executing its configGenerator
cluster.runNodeStart(validator1);
cluster.start(validator1);
final int blockRewardEth = 5;
final int blockToCheck = 2;

@ -27,6 +27,7 @@ import org.junit.runners.Parameterized.Parameters;
@Ignore("This is not a test class, it offers BFT parameterization only.")
public abstract class ParameterizedBftTestBase extends AcceptanceTestBase {
protected final String bftType;
protected final BftAcceptanceTestParameterization nodeFactory;
@Parameters(name = "{0}")
@ -35,7 +36,8 @@ public abstract class ParameterizedBftTestBase extends AcceptanceTestBase {
}
protected ParameterizedBftTestBase(
final String testname, final BftAcceptanceTestParameterization input) {
final String bftType, final BftAcceptanceTestParameterization input) {
this.bftType = bftType;
this.nodeFactory = input;
}
}

@ -85,7 +85,7 @@ public class SECP256R1AcceptanceTest extends AcceptanceTestBase {
final Hash transactionHash =
minerNode.execute(accountTransactions.createTransfer(recipient, 5, new SECP256R1()));
assertThat(transactionHash).isNotNull();
cluster.verify(recipient.balanceEquals(5));
noDiscoveryCluster.verify(recipient.balanceEquals(5));
}
@Override

Loading…
Cancel
Save