diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java index e50fd9b43ce..eb25ca3a6a2 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java @@ -18,6 +18,7 @@ import static org.apache.logging.log4j.LogManager.getLogger; import static org.apache.tuweni.io.file.Files.copyResource; +import org.hyperledger.besu.cli.config.NetworkName; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.KeyPairUtil; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; @@ -97,6 +98,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable private Optional permissioningConfiguration; private final GenesisConfigurationProvider genesisConfigProvider; private final boolean devMode; + private final NetworkName network; private final boolean discoveryEnabled; private final List bootnodes = new ArrayList<>(); private final boolean bootnodeEligible; @@ -123,6 +125,7 @@ public BesuNode( final Optional permissioningConfiguration, final Optional keyfilePath, final boolean devMode, + final NetworkName network, final GenesisConfigurationProvider genesisConfigProvider, final boolean p2pEnabled, final NetworkingConfiguration networkingConfiguration, @@ -156,6 +159,7 @@ public BesuNode( this.permissioningConfiguration = permissioningConfiguration; this.genesisConfigProvider = genesisConfigProvider; this.devMode = devMode; + this.network = network; this.p2pEnabled = p2pEnabled; this.networkingConfiguration = networkingConfiguration; this.discoveryEnabled = discoveryEnabled; @@ -579,6 +583,10 @@ public boolean isDevMode() { return devMode; } + public NetworkName getNetwork() { + return network; + } + public boolean isSecp256k1Native() { return secp256k1Native; } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java index 4e994eea822..2c7bd5b7dab 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java @@ -81,6 +81,9 @@ public void startNode(final BesuNode node) { if (node.isDevMode()) { params.add("--network"); params.add("DEV"); + } else if (node.getNetwork() != null) { + params.add("--network"); + params.add(node.getNetwork().name()); } params.add("--sync-mode"); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java index 10646daddce..cea80f15ae6 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java @@ -14,6 +14,7 @@ */ package org.hyperledger.besu.tests.acceptance.dsl.node.configuration; +import org.hyperledger.besu.cli.config.NetworkName; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; import org.hyperledger.besu.ethereum.core.MiningParameters; @@ -52,6 +53,7 @@ public class BesuNodeConfiguration { private final boolean isDnsEnabled; private final Optional privacyParameters; private final List runCommand; + private final NetworkName network; BesuNodeConfiguration( final String name, @@ -63,6 +65,7 @@ public class BesuNodeConfiguration { final Optional permissioningConfiguration, final Optional keyFilePath, final boolean devMode, + final NetworkName network, final GenesisConfigurationProvider genesisConfigProvider, final boolean p2pEnabled, final NetworkingConfiguration networkingConfiguration, @@ -86,6 +89,7 @@ public class BesuNodeConfiguration { this.keyFilePath = keyFilePath; this.dataPath = dataPath; this.devMode = devMode; + this.network = network; this.genesisConfigProvider = genesisConfigProvider; this.p2pEnabled = p2pEnabled; this.networkingConfiguration = networkingConfiguration; @@ -193,4 +197,8 @@ public Optional getPrivacyParameters() { public List getRunCommand() { return runCommand; } + + public NetworkName getNetwork() { + return network; + } } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java index 7dd0840e3b2..1fadece77bc 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java @@ -17,6 +17,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import static java.util.Collections.singletonList; +import org.hyperledger.besu.cli.config.NetworkName; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis; import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; @@ -55,6 +56,7 @@ public class BesuNodeConfigurationBuilder { private boolean discoveryEnabled = true; private boolean bootnodeEligible = true; private boolean revertReasonEnabled = false; + private NetworkName network = null; private boolean secp256K1Native = false; private boolean altbn128Native = false; private final List plugins = new ArrayList<>(); @@ -165,6 +167,11 @@ public BesuNodeConfigurationBuilder metricsConfiguration( return this; } + public BesuNodeConfigurationBuilder network(final NetworkName network) { + this.network = network; + return this; + } + public BesuNodeConfigurationBuilder webSocketEnabled() { final WebSocketConfiguration config = WebSocketConfiguration.createDefault(); config.setEnabled(true); @@ -295,6 +302,7 @@ public BesuNodeConfiguration build() { permissioningConfiguration, Optional.ofNullable(keyFilePath), devMode, + network, genesisConfigProvider, p2pEnabled, networkingConfiguration, diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java index 6582130034c..fdca8442ca8 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java @@ -60,6 +60,7 @@ public BesuNode create(final BesuNodeConfiguration config) throws IOException { config.getPermissioningConfiguration(), config.getKeyFilePath(), config.isDevMode(), + config.getNetwork(), config.getGenesisConfigProvider(), config.isP2pEnabled(), config.getNetworkingConfiguration(), diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java index 308440f94d5..49a02c91183 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java @@ -94,6 +94,7 @@ public PrivacyNode(final PrivacyNodeConfiguration privacyConfiguration, final Ve besuConfig.getPermissioningConfiguration(), besuConfig.getKeyFilePath(), besuConfig.isDevMode(), + besuConfig.getNetwork(), besuConfig.getGenesisConfigProvider(), besuConfig.isP2pEnabled(), besuConfig.getNetworkingConfiguration(), diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/mining/KeccakMiningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/mining/KeccakMiningAcceptanceTest.java new file mode 100644 index 00000000000..d2e182dcb61 --- /dev/null +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/mining/KeccakMiningAcceptanceTest.java @@ -0,0 +1,67 @@ +/* + * Copyright ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.tests.acceptance.mining; + +import org.hyperledger.besu.cli.config.NetworkName; +import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; +import org.hyperledger.besu.tests.acceptance.dsl.account.Account; +import org.hyperledger.besu.tests.acceptance.dsl.node.Node; +import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeConfigurationBuilder; + +import org.junit.Before; +import org.junit.Test; + +public class KeccakMiningAcceptanceTest extends AcceptanceTestBase { + + private Node minerNode; + + @Before + public void setUp() throws Exception { + minerNode = + besu.create( + new BesuNodeConfigurationBuilder() + .name("miner1") + .devMode(false) + .network(NetworkName.ECIP1049_DEV) + .miningEnabled() + .jsonRpcEnabled() + .webSocketEnabled() + .build()); + cluster.start(minerNode); + } + + @Test + public void shouldMineTransactions() { + final Account sender = accounts.createAccount("account1"); + final Account receiver = accounts.createAccount("account2"); + minerNode.execute(accountTransactions.createTransfer(sender, 50)); + cluster.verify(sender.balanceEquals(50)); + + minerNode.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 1)); + cluster.verify(receiver.balanceEquals(1)); + + minerNode.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 2)); + cluster.verify(receiver.balanceEquals(3)); + + minerNode.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 3)); + cluster.verify(receiver.balanceEquals(6)); + + minerNode.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 4)); + cluster.verify(receiver.balanceEquals(10)); + + minerNode.execute(accountTransactions.createIncrementalTransfers(sender, receiver, 5)); + cluster.verify(receiver.balanceEquals(15)); + } +}