diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/PantheonClusterAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterAcceptanceTest.java similarity index 59% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/PantheonClusterAcceptanceTest.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterAcceptanceTest.java index a07ba5f671..acf4de79e1 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/PantheonClusterAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterAcceptanceTest.java @@ -12,30 +12,27 @@ */ package tech.pegasys.pantheon.tests.acceptance; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonMinerNode; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonNode; - import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; -import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import org.junit.Before; import org.junit.Test; -public class PantheonClusterAcceptanceTest extends AcceptanceTestBase { +public class ClusterAcceptanceTest extends AcceptanceTestBase { - private PantheonNode minerNode; - private PantheonNode fullNode; + private Node minerNode; + private Node fullNode; @Before public void setUp() throws Exception { - minerNode = cluster.create(pantheonMinerNode("node1")); - fullNode = cluster.create(pantheonNode("node2")); + minerNode = pantheon.createMinerNode("node1"); + fullNode = pantheon.createArchiveNode("node2"); cluster.start(minerNode, fullNode); } @Test public void shouldConnectToOtherPeer() { - jsonRpc.waitForPeersConnected(minerNode, 1); - jsonRpc.waitForPeersConnected(fullNode, 1); + minerNode.verify(net.awaitPeerCount(1)); + fullNode.verify(net.awaitPeerCount(1)); } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/CreateAccountAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/CreateAccountAcceptanceTest.java index 8cb08b39bf..11627e5a13 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/CreateAccountAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/CreateAccountAcceptanceTest.java @@ -13,12 +13,10 @@ package tech.pegasys.pantheon.tests.acceptance; import static org.web3j.utils.Convert.Unit.ETHER; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonMinerNode; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonNode; import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account; -import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import org.junit.Before; import org.junit.Ignore; @@ -27,12 +25,12 @@ import org.junit.Test; @Ignore public class CreateAccountAcceptanceTest extends AcceptanceTestBase { - private PantheonNode minerNode; + private Node minerNode; @Before public void setUp() throws Exception { - minerNode = cluster.create(pantheonMinerNode("node1")); - cluster.start(minerNode, cluster.create(pantheonNode("node2"))); + minerNode = pantheon.createMinerNode("node1"); + cluster.start(minerNode, pantheon.createArchiveNode("node2")); } @Test diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/RpcApisTogglesAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/RpcApisTogglesAcceptanceTest.java index 0e83832306..175795c50b 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/RpcApisTogglesAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/RpcApisTogglesAcceptanceTest.java @@ -12,10 +12,6 @@ */ package tech.pegasys.pantheon.tests.acceptance; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonNode; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonRpcDisabledNode; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.patheonNodeWithRpcApis; - import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApis; import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; @@ -34,9 +30,9 @@ public class RpcApisTogglesAcceptanceTest extends AcceptanceTestBase { @Before public void before() throws Exception { - rpcEnabledNode = cluster.create(pantheonNode("rpc-enabled")); - rpcDisabledNode = cluster.create(pantheonRpcDisabledNode("rpc-disabled")); - ethApiDisabledNode = cluster.create(patheonNodeWithRpcApis("eth-api-disabled", RpcApis.NET)); + rpcEnabledNode = pantheon.createArchiveNode("rpc-enabled"); + rpcDisabledNode = pantheon.createArchiveNodeWithRpcDisabled("rpc-disabled"); + ethApiDisabledNode = pantheon.createArchiveNodeWithRpcApis("eth-api-disabled", RpcApis.NET); cluster.start(rpcEnabledNode, rpcDisabledNode, ethApiDisabledNode); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/AcceptanceTestBase.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/AcceptanceTestBase.java index 362f2b4391..9e04a99339 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/AcceptanceTestBase.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/AcceptanceTestBase.java @@ -15,10 +15,10 @@ package tech.pegasys.pantheon.tests.acceptance.dsl; import tech.pegasys.pantheon.tests.acceptance.dsl.account.Accounts; import tech.pegasys.pantheon.tests.acceptance.dsl.blockchain.Blockchain; import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Eth; -import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.JsonRpc; import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Net; import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Web3; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Cluster; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeFactory; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transactions; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth.EthTransactions; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.NetTransactions; @@ -31,22 +31,22 @@ public class AcceptanceTestBase { protected final Accounts accounts; protected final Blockchain blockchain; protected final Cluster cluster; - protected final JsonRpc jsonRpc; protected final Transactions transactions; protected final Web3 web3; protected final Eth eth; protected final Net net; + protected final PantheonNodeFactory pantheon; protected AcceptanceTestBase() { final EthTransactions ethTransactions = new EthTransactions(); accounts = new Accounts(ethTransactions); blockchain = new Blockchain(ethTransactions); - cluster = new Cluster(); eth = new Eth(ethTransactions); - jsonRpc = new JsonRpc(cluster); net = new Net(new NetTransactions()); + cluster = new Cluster(net); transactions = new Transactions(accounts); web3 = new Web3(new Web3Transactions()); + pantheon = new PantheonNodeFactory(); } @After diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/net/AwaitNetPeerCount.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/net/AwaitNetPeerCount.java new file mode 100644 index 0000000000..d6ffadb807 --- /dev/null +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/net/AwaitNetPeerCount.java @@ -0,0 +1,39 @@ +/* + * Copyright 2018 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. + */ +package tech.pegasys.pantheon.tests.acceptance.dsl.condition.net; + +import static org.assertj.core.api.Assertions.assertThat; + +import tech.pegasys.pantheon.tests.acceptance.dsl.WaitUtils; +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.NetPeerCountTransaction; + +import java.math.BigInteger; + +public class AwaitNetPeerCount implements Condition { + + private final NetPeerCountTransaction transaction; + private final BigInteger expectedPeerCount; + + public AwaitNetPeerCount( + final NetPeerCountTransaction transaction, final BigInteger expectedPeerCount) { + this.transaction = transaction; + this.expectedPeerCount = expectedPeerCount; + } + + @Override + public void verify(final Node node) { + WaitUtils.waitFor(() -> assertThat(node.execute(transaction)).isEqualTo(expectedPeerCount)); + } +} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/JsonRpc.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/JsonRpc.java deleted file mode 100644 index 2fae04c636..0000000000 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/JsonRpc.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2018 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. - */ -package tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc; - -import static org.assertj.core.api.Assertions.assertThat; - -import tech.pegasys.pantheon.tests.acceptance.dsl.WaitUtils; -import tech.pegasys.pantheon.tests.acceptance.dsl.node.Cluster; -import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; - -public class JsonRpc { - - private final Cluster nodes; - - public JsonRpc(final Cluster nodes) { - this.nodes = nodes; - } - - public void waitForPeersConnected(final PantheonNode node, final int expectedNumberOfPeers) { - WaitUtils.waitFor(() -> assertThat(node.getPeerCount()).isEqualTo(expectedNumberOfPeers)); - } -} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Net.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Net.java index 8787599114..fed10e35fa 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Net.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Net.java @@ -13,11 +13,14 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.net.AwaitNetPeerCount; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.net.ExpectNetVersionConnectionException; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.net.ExpectNetVersionConnectionExceptionWithCause; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.net.ExpectNetVersionIsNotBlank; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.NetTransactions; +import java.math.BigInteger; + public class Net { private final NetTransactions transactions; @@ -30,6 +33,10 @@ public class Net { return new ExpectNetVersionIsNotBlank(transactions.netVersion()); } + public Condition awaitPeerCount(final int awaitPeerCount) { + return new AwaitNetPeerCount(transactions.peerCount(), BigInteger.valueOf(awaitPeerCount)); + } + public Condition netVersionExceptional(final String expectedMessage) { return new ExpectNetVersionConnectionException(transactions.netVersion(), expectedMessage); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/Cluster.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/Cluster.java index 942ca1b081..11ab3d5866 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/Cluster.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/Cluster.java @@ -14,42 +14,58 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.node; import static org.assertj.core.api.Assertions.assertThat; -import tech.pegasys.pantheon.tests.acceptance.dsl.WaitUtils; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; +import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Net; -import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; public class Cluster implements AutoCloseable { - private final Map nodes = new HashMap<>(); + private final Map nodes = new HashMap<>(); private final PantheonNodeRunner pantheonNodeRunner = PantheonNodeRunner.instance(); + private final Net net; - public void start(final PantheonNode... nodes) { + public Cluster(final Net net) { + this.net = net; + } + + public void start(final Node... nodes) { + start( + Arrays.stream(nodes) + .map( + n -> { + assertThat(n instanceof RunnableNode).isTrue(); + return (RunnableNode) n; + }) + .collect(Collectors.toList())); + } + + public void start(final List nodes) { this.nodes.clear(); final List bootNodes = new ArrayList<>(); - - for (final PantheonNode node : nodes) { + for (final RunnableNode node : nodes) { this.nodes.put(node.getName(), node); - bootNodes.add(node.enodeUrl()); + bootNodes.add(node.getConfiguration().enodeUrl()); } - for (final PantheonNode node : nodes) { - node.bootnodes(bootNodes); + for (final RunnableNode node : nodes) { + node.getConfiguration().bootnodes(bootNodes); node.start(pantheonNodeRunner); } - for (final PantheonNode node : nodes) { - awaitPeerDiscovery(node, nodes.length); + for (final RunnableNode node : nodes) { + node.awaitPeerDiscovery(net.awaitPeerCount(nodes.size() - 1)); } } public void stop() { - for (final PantheonNode node : nodes.values()) { + for (final RunnableNode node : nodes.values()) { node.stop(); } pantheonNodeRunner.shutdown(); @@ -57,31 +73,12 @@ public class Cluster implements AutoCloseable { @Override public void close() { - for (final PantheonNode node : nodes.values()) { + for (final RunnableNode node : nodes.values()) { node.close(); } pantheonNodeRunner.shutdown(); } - public PantheonNode create(final PantheonNodeConfig config) throws IOException { - config.initSocket(); - final PantheonNode node = - new PantheonNode( - config.getName(), - config.getSocketPort(), - config.getMiningParameters(), - config.getJsonRpcConfiguration(), - config.getWebSocketConfiguration()); - config.closeSocket(); - return node; - } - - private void awaitPeerDiscovery(final PantheonNode node, final int nodeCount) { - if (node.jsonRpcEnabled()) { - WaitUtils.waitFor(() -> assertThat(node.getPeerCount()).isEqualTo(nodeCount - 1)); - } - } - public void verify(final Condition expected) { for (final Node node : nodes.values()) { expected.verify(node); diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/Node.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/Node.java index a029506ff9..aa26313279 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/Node.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/Node.java @@ -12,9 +12,12 @@ */ package tech.pegasys.pantheon.tests.acceptance.dsl.node; +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; public interface Node { T execute(Transaction transaction); + + void verify(final Condition expected); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/NodeConfiguration.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/NodeConfiguration.java new file mode 100644 index 0000000000..08349095a4 --- /dev/null +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/NodeConfiguration.java @@ -0,0 +1,31 @@ +/* + * Copyright 2018 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. + */ +package tech.pegasys.pantheon.tests.acceptance.dsl.node; + +import java.util.List; +import java.util.Optional; + +public interface NodeConfiguration { + + String enodeUrl(); + + void bootnodes(List bootnodes); + + void useWebSocketsForJsonRpc(); + + Optional jsonRpcWebSocketPort(); + + String hostName(); + + boolean jsonRpcEnabled(); +} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java index 58089dfc48..96161183f9 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java @@ -43,54 +43,61 @@ import org.web3j.protocol.http.HttpService; import org.web3j.protocol.websocket.WebSocketService; import org.web3j.utils.Async; -public class PantheonNode implements Node, AutoCloseable { +public class PantheonNode implements Node, NodeConfiguration, RunnableNode, AutoCloseable { private static final String LOCALHOST = "127.0.0.1"; private static final Logger LOG = getLogger(); - private final String name; private final Path homeDirectory; private final KeyPair keyPair; private final int p2pPort; + private final Properties portsProperties = new Properties(); + + private final String name; private final MiningParameters miningParameters; private final JsonRpcConfiguration jsonRpcConfiguration; private final WebSocketConfiguration webSocketConfiguration; - private final boolean jsonRpcEnabled; - private final boolean wsRpcEnabled; - private final Properties portsProperties = new Properties(); private List bootnodes = new ArrayList<>(); private Web3j web3j; public PantheonNode( final String name, - final int p2pPort, final MiningParameters miningParameters, final JsonRpcConfiguration jsonRpcConfiguration, - final WebSocketConfiguration webSocketConfiguration) + final WebSocketConfiguration webSocketConfiguration, + final int p2pPort) throws IOException { - this.name = name; this.homeDirectory = Files.createTempDirectory("acctest"); this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory); this.p2pPort = p2pPort; + this.name = name; this.miningParameters = miningParameters; this.jsonRpcConfiguration = jsonRpcConfiguration; this.webSocketConfiguration = webSocketConfiguration; - this.jsonRpcEnabled = jsonRpcConfiguration.isEnabled(); - this.wsRpcEnabled = webSocketConfiguration.isEnabled(); LOG.info("Created PantheonNode {}", this.toString()); } - String getName() { + private boolean isJsonRpcEnabled() { + return jsonRpcConfiguration().isEnabled(); + } + + private boolean isWebSocketsRpcEnabled() { + return webSocketConfiguration().isEnabled(); + } + + @Override + public String getName() { return name; } - String enodeUrl() { + @Override + public String enodeUrl() { return "enode://" + keyPair.getPublicKey().toString() + "@" + LOCALHOST + ":" + p2pPort; } private Optional jsonRpcBaseUrl() { - if (jsonRpcEnabled) { + if (isJsonRpcEnabled()) { return Optional.of( "http://" + jsonRpcConfiguration.getHost() @@ -102,7 +109,7 @@ public class PantheonNode implements Node, AutoCloseable { } private Optional wsRpcBaseUrl() { - if (wsRpcEnabled) { + if (isWebSocketsRpcEnabled()) { return Optional.of( "ws://" + webSocketConfiguration.getHost() + ":" + portsProperties.getProperty("ws-rpc")); } else { @@ -110,15 +117,17 @@ public class PantheonNode implements Node, AutoCloseable { } } + @Override public Optional jsonRpcWebSocketPort() { - if (wsRpcEnabled) { + if (isWebSocketsRpcEnabled()) { return Optional.of(Integer.valueOf(portsProperties.getProperty("ws-rpc"))); } else { return Optional.empty(); } } - public String getHost() { + @Override + public String hostName() { return LOCALHOST; } @@ -153,6 +162,7 @@ public class PantheonNode implements Node, AutoCloseable { } /** All future JSON-RPC calls are made via a web sockets connection. */ + @Override public void useWebSocketsForJsonRpc() { final String url = wsRpcBaseUrl().isPresent() ? wsRpcBaseUrl().get() : "ws://127.0.0.1:8546"; @@ -165,19 +175,24 @@ public class PantheonNode implements Node, AutoCloseable { web3j = Web3j.build(webSocketService, 2000, Async.defaultExecutorService()); } - public int getPeerCount() { - try { - return web3j().netPeerCount().send().getQuantity().intValueExact(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } - + @Override public void start(final PantheonNodeRunner runner) { runner.startNode(this); loadPortsFile(); } + @Override + public NodeConfiguration getConfiguration() { + return this; + } + + @Override + public void awaitPeerDiscovery(final Condition condition) { + if (jsonRpcEnabled()) { + verify(condition); + } + } + private void loadPortsFile() { try (final FileInputStream fis = new FileInputStream(new File(homeDirectory.toFile(), "pantheon.ports"))) { @@ -191,8 +206,9 @@ public class PantheonNode implements Node, AutoCloseable { return homeDirectory; } - boolean jsonRpcEnabled() { - return jsonRpcEnabled; + @Override + public boolean jsonRpcEnabled() { + return isJsonRpcEnabled(); } JsonRpcConfiguration jsonRpcConfiguration() { @@ -200,15 +216,15 @@ public class PantheonNode implements Node, AutoCloseable { } Optional jsonRpcListenAddress() { - if (jsonRpcEnabled) { - return Optional.of(jsonRpcConfiguration.getHost() + ":" + jsonRpcConfiguration.getPort()); + if (isJsonRpcEnabled()) { + return Optional.of(jsonRpcConfiguration().getHost() + ":" + jsonRpcConfiguration().getPort()); } else { return Optional.empty(); } } boolean wsRpcEnabled() { - return wsRpcEnabled; + return isWebSocketsRpcEnabled(); } WebSocketConfiguration webSocketConfiguration() { @@ -216,7 +232,8 @@ public class PantheonNode implements Node, AutoCloseable { } Optional wsRpcListenAddress() { - return Optional.of(webSocketConfiguration.getHost() + ":" + webSocketConfiguration.getPort()); + return Optional.of( + webSocketConfiguration().getHost() + ":" + webSocketConfiguration().getPort()); } int p2pPort() { @@ -234,7 +251,8 @@ public class PantheonNode implements Node, AutoCloseable { .collect(Collectors.toList()); } - void bootnodes(final List bootnodes) { + @Override + public void bootnodes(final List bootnodes) { this.bootnodes = bootnodes; } @@ -252,7 +270,8 @@ public class PantheonNode implements Node, AutoCloseable { .toString(); } - void stop() { + @Override + public void stop() { if (web3j != null) { web3j.shutdown(); web3j = null; @@ -274,6 +293,7 @@ public class PantheonNode implements Node, AutoCloseable { return transaction.execute(web3j()); } + @Override public void verify(final Condition expected) { expected.verify(this); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNodeConfig.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNodeConfig.java deleted file mode 100644 index 07c2525f13..0000000000 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNodeConfig.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2018 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. - */ -package tech.pegasys.pantheon.tests.acceptance.dsl.node; - -import tech.pegasys.pantheon.ethereum.core.MiningParameters; -import tech.pegasys.pantheon.ethereum.core.MiningParametersTestBuilder; -import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration; -import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApi; -import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration; - -import java.io.IOException; -import java.net.ServerSocket; -import java.util.Arrays; - -public class PantheonNodeConfig { - - private final String name; - private final MiningParameters miningParameters; - private final JsonRpcConfiguration jsonRpcConfiguration; - private final WebSocketConfiguration webSocketConfiguration; - private ServerSocket serverSocket; - - private PantheonNodeConfig( - final String name, - final MiningParameters miningParameters, - final JsonRpcConfiguration jsonRpcConfiguration, - final WebSocketConfiguration webSocketConfiguration) { - this.name = name; - this.miningParameters = miningParameters; - this.jsonRpcConfiguration = jsonRpcConfiguration; - this.webSocketConfiguration = webSocketConfiguration; - } - - private PantheonNodeConfig(final String name, final MiningParameters miningParameters) { - this.name = name; - this.miningParameters = miningParameters; - this.jsonRpcConfiguration = createJsonRpcConfig(); - this.webSocketConfiguration = createWebSocketConfig(); - } - - private static MiningParameters createMiningParameters(final boolean miner) { - return new MiningParametersTestBuilder().enabled(miner).build(); - } - - public static PantheonNodeConfig pantheonMinerNode(final String name) { - return new PantheonNodeConfig(name, createMiningParameters(true)); - } - - public static PantheonNodeConfig pantheonNode(final String name) { - return new PantheonNodeConfig(name, createMiningParameters(false)); - } - - public static PantheonNodeConfig pantheonRpcDisabledNode(final String name) { - return new PantheonNodeConfig( - name, - createMiningParameters(false), - JsonRpcConfiguration.createDefault(), - WebSocketConfiguration.createDefault()); - } - - public static PantheonNodeConfig patheonNodeWithRpcApis( - final String name, final RpcApi... enabledRpcApis) { - final JsonRpcConfiguration jsonRpcConfig = createJsonRpcConfig(); - jsonRpcConfig.setRpcApis(Arrays.asList(enabledRpcApis)); - final WebSocketConfiguration webSocketConfig = createWebSocketConfig(); - webSocketConfig.setRpcApis(Arrays.asList(enabledRpcApis)); - - return new PantheonNodeConfig( - name, createMiningParameters(false), jsonRpcConfig, webSocketConfig); - } - - private static JsonRpcConfiguration createJsonRpcConfig() { - final JsonRpcConfiguration config = JsonRpcConfiguration.createDefault(); - config.setEnabled(true); - config.setPort(0); - return config; - } - - private static WebSocketConfiguration createWebSocketConfig() { - final WebSocketConfiguration config = WebSocketConfiguration.createDefault(); - config.setEnabled(true); - config.setPort(0); - return config; - } - - public void initSocket() throws IOException { - serverSocket = new ServerSocket(0); - } - - public void closeSocket() throws IOException { - serverSocket.close(); - } - - public int getSocketPort() { - return serverSocket.getLocalPort(); - } - - public String getName() { - return name; - } - - public MiningParameters getMiningParameters() { - return miningParameters; - } - - public JsonRpcConfiguration getJsonRpcConfiguration() { - return jsonRpcConfiguration; - } - - public WebSocketConfiguration getWebSocketConfiguration() { - return webSocketConfiguration; - } -} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNodeFactory.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNodeFactory.java new file mode 100644 index 0000000000..e2d09e633f --- /dev/null +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNodeFactory.java @@ -0,0 +1,126 @@ +/* + * Copyright 2018 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. + */ +package tech.pegasys.pantheon.tests.acceptance.dsl.node; + +import tech.pegasys.pantheon.ethereum.core.MiningParameters; +import tech.pegasys.pantheon.ethereum.core.MiningParametersTestBuilder; +import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration; +import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApi; +import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration; + +import java.io.IOException; +import java.net.ServerSocket; +import java.util.Arrays; + +public class PantheonNodeFactory { + + private PantheonNode create(final PantheonFactoryConfiguration config) throws IOException { + ServerSocket serverSocket = new ServerSocket(0); + final PantheonNode node = + new PantheonNode( + config.getName(), + config.getMiningParameters(), + config.getJsonRpcConfiguration(), + config.getWebSocketConfiguration(), + serverSocket.getLocalPort()); + serverSocket.close(); + + return node; + } + + public PantheonNode createMinerNode(final String name) throws IOException { + return create( + new PantheonFactoryConfiguration( + name, createMiningParameters(true), createJsonRpcConfig(), createWebSocketConfig())); + } + + public PantheonNode createArchiveNode(final String name) throws IOException { + return create( + new PantheonFactoryConfiguration( + name, createMiningParameters(false), createJsonRpcConfig(), createWebSocketConfig())); + } + + public PantheonNode createArchiveNodeWithRpcDisabled(final String name) throws IOException { + return create( + new PantheonFactoryConfiguration( + name, + createMiningParameters(false), + JsonRpcConfiguration.createDefault(), + WebSocketConfiguration.createDefault())); + } + + public PantheonNode createArchiveNodeWithRpcApis( + final String name, final RpcApi... enabledRpcApis) throws IOException { + final JsonRpcConfiguration jsonRpcConfig = createJsonRpcConfig(); + jsonRpcConfig.setRpcApis(Arrays.asList(enabledRpcApis)); + final WebSocketConfiguration webSocketConfig = createWebSocketConfig(); + webSocketConfig.setRpcApis(Arrays.asList(enabledRpcApis)); + + return create( + new PantheonFactoryConfiguration( + name, createMiningParameters(false), jsonRpcConfig, webSocketConfig)); + } + + private MiningParameters createMiningParameters(final boolean miner) { + return new MiningParametersTestBuilder().enabled(miner).build(); + } + + private JsonRpcConfiguration createJsonRpcConfig() { + final JsonRpcConfiguration config = JsonRpcConfiguration.createDefault(); + config.setEnabled(true); + config.setPort(0); + return config; + } + + private WebSocketConfiguration createWebSocketConfig() { + final WebSocketConfiguration config = WebSocketConfiguration.createDefault(); + config.setEnabled(true); + config.setPort(0); + return config; + } + + static class PantheonFactoryConfiguration { + + private final String name; + private final MiningParameters miningParameters; + private final JsonRpcConfiguration jsonRpcConfiguration; + private final WebSocketConfiguration webSocketConfiguration; + + public PantheonFactoryConfiguration( + final String name, + final MiningParameters miningParameters, + final JsonRpcConfiguration jsonRpcConfiguration, + final WebSocketConfiguration webSocketConfiguration) { + this.name = name; + this.miningParameters = miningParameters; + this.jsonRpcConfiguration = jsonRpcConfiguration; + this.webSocketConfiguration = webSocketConfiguration; + } + + public String getName() { + return name; + } + + public MiningParameters getMiningParameters() { + return miningParameters; + } + + public JsonRpcConfiguration getJsonRpcConfiguration() { + return jsonRpcConfiguration; + } + + public WebSocketConfiguration getWebSocketConfiguration() { + return webSocketConfiguration; + } + } +} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/RunnableNode.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/RunnableNode.java new file mode 100644 index 0000000000..5cbc239ca3 --- /dev/null +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/RunnableNode.java @@ -0,0 +1,30 @@ +/* + * Copyright 2018 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. + */ +package tech.pegasys.pantheon.tests.acceptance.dsl.node; + +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; + +public interface RunnableNode extends Node { + + void stop(); + + void close(); + + void start(PantheonNodeRunner runner); + + NodeConfiguration getConfiguration(); + + void awaitPeerDiscovery(final Condition condition); + + String getName(); +} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java index 844a517054..08bb5a8280 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java @@ -71,7 +71,7 @@ public class ThreadPantheonNodeRunner implements PantheonNodeRunner { pantheonController, true, node.bootnodes(), - node.getHost(), + node.hostName(), node.p2pPort(), 25, node.jsonRpcConfiguration(), diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/pubsub/WebSocket.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/pubsub/WebSocket.java index 249e5d9f27..9fd3fec45e 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/pubsub/WebSocket.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/pubsub/WebSocket.java @@ -14,7 +14,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.pubsub; import static org.assertj.core.api.Assertions.assertThat; -import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.NodeConfiguration; import java.util.List; @@ -26,7 +26,7 @@ public class WebSocket { private final WebSocketConnection connection; - public WebSocket(final Vertx vertx, final PantheonNode node) { + public WebSocket(final Vertx vertx, final NodeConfiguration node) { this.connection = new WebSocketConnection(vertx, node); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/pubsub/WebSocketConnection.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/pubsub/WebSocketConnection.java index d14b93dd99..3e85a6b850 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/pubsub/WebSocketConnection.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/pubsub/WebSocketConnection.java @@ -15,7 +15,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.pubsub; import static org.assertj.core.api.Assertions.assertThat; import tech.pegasys.pantheon.tests.acceptance.dsl.WaitUtils; -import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.NodeConfiguration; import java.util.ArrayList; import java.util.List; @@ -39,7 +39,7 @@ public class WebSocketConnection { private volatile JsonRpcSuccessEvent latestEvent; private volatile WebSocket connection; - public WebSocketConnection(final Vertx vertx, final PantheonNode node) { + public WebSocketConnection(final Vertx vertx, final NodeConfiguration node) { if (!node.jsonRpcWebSocketPort().isPresent()) { throw new IllegalStateException( "Can't start websocket connection for node with RPC disabled"); @@ -47,7 +47,7 @@ public class WebSocketConnection { subscriptionEvents = new ConcurrentLinkedDeque<>(); options = new RequestOptions(); options.setPort(node.jsonRpcWebSocketPort().get()); - options.setHost(node.getHost()); + options.setHost(node.hostName()); connect(vertx); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetPeerCountTransaction.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetPeerCountTransaction.java new file mode 100644 index 0000000000..01902ba581 --- /dev/null +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetPeerCountTransaction.java @@ -0,0 +1,40 @@ +/* + * Copyright 2018 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. + */ +package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net; + +import static org.assertj.core.api.Assertions.assertThat; + +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; + +import java.io.IOException; +import java.math.BigInteger; + +import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.methods.response.NetPeerCount; + +public class NetPeerCountTransaction implements Transaction { + + NetPeerCountTransaction() {} + + @Override + public BigInteger execute(final Web3j node) { + try { + final NetPeerCount result = node.netPeerCount().send(); + assertThat(result).isNotNull(); + assertThat(result.hasError()).isFalse(); + return result.getQuantity(); + } catch (final IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetTransactions.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetTransactions.java index 67a21d5816..1b059bf5c3 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetTransactions.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetTransactions.java @@ -17,4 +17,8 @@ public class NetTransactions { public NetVersionTransaction netVersion() { return new NetVersionTransaction(); } + + public NetPeerCountTransaction peerCount() { + return new NetPeerCountTransaction(); + } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetWorkAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetWorkAcceptanceTest.java index ad9c23c804..eec687f94b 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetWorkAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetWorkAcceptanceTest.java @@ -12,24 +12,21 @@ */ package tech.pegasys.pantheon.tests.acceptance.jsonrpc; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonMinerNode; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonNode; - import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; -import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import org.junit.Before; import org.junit.Test; public class EthGetWorkAcceptanceTest extends AcceptanceTestBase { - private PantheonNode minerNode; - private PantheonNode fullNode; + private Node minerNode; + private Node fullNode; @Before public void setUp() throws Exception { - minerNode = cluster.create(pantheonMinerNode("node1")); - fullNode = cluster.create(pantheonNode("node2")); + minerNode = pantheon.createMinerNode("node1"); + fullNode = pantheon.createArchiveNode("node2"); cluster.start(minerNode, fullNode); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/Web3Sha3AcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/Web3Sha3AcceptanceTest.java index 3839ab9b80..c0d7a2ccb0 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/Web3Sha3AcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/Web3Sha3AcceptanceTest.java @@ -12,21 +12,19 @@ */ package tech.pegasys.pantheon.tests.acceptance.jsonrpc; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonNode; - import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; -import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import org.junit.Before; import org.junit.Test; public class Web3Sha3AcceptanceTest extends AcceptanceTestBase { - private PantheonNode node; + private Node node; @Before public void setUp() throws Exception { - node = cluster.create(pantheonNode("node1")); + node = pantheon.createArchiveNode("node1"); cluster.start(node); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/mining/MiningAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/mining/MiningAcceptanceTest.java index 53a229ca67..e295611a0a 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/mining/MiningAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/mining/MiningAcceptanceTest.java @@ -12,11 +12,9 @@ */ package tech.pegasys.pantheon.tests.acceptance.mining; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonMinerNode; - import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account; -import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import org.junit.Before; import org.junit.Ignore; @@ -25,11 +23,11 @@ import org.junit.Test; @Ignore public class MiningAcceptanceTest extends AcceptanceTestBase { - private PantheonNode minerNode; + private Node minerNode; @Before public void setUp() throws Exception { - minerNode = cluster.create(pantheonMinerNode("miner1")); + minerNode = pantheon.createMinerNode("miner1"); cluster.start(minerNode); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/pubsub/NewPendingTransactionAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/pubsub/NewPendingTransactionAcceptanceTest.java index 42572a969b..bce461f446 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/pubsub/NewPendingTransactionAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/pubsub/NewPendingTransactionAcceptanceTest.java @@ -12,9 +12,6 @@ */ package tech.pegasys.pantheon.tests.acceptance.pubsub; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonMinerNode; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonNode; - import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account; @@ -42,12 +39,12 @@ public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase { @Before public void setUp() throws Exception { vertx = Vertx.vertx(); - minerNode = cluster.create(pantheonMinerNode("miner-node1")); - archiveNode = cluster.create(pantheonNode("full-node1")); + minerNode = pantheon.createMinerNode("miner-node1"); + archiveNode = pantheon.createArchiveNode("full-node1"); cluster.start(minerNode, archiveNode); accountOne = accounts.createAccount("account-one"); - minerWebSocket = new WebSocket(vertx, minerNode); - archiveWebSocket = new WebSocket(vertx, archiveNode); + minerWebSocket = new WebSocket(vertx, minerNode.getConfiguration()); + archiveWebSocket = new WebSocket(vertx, archiveNode.getConfiguration()); } @After @@ -72,7 +69,7 @@ public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase { cluster.stop(); // Create the heavy fork - final PantheonNode minerNodeTwo = cluster.create(pantheonMinerNode("miner-node2")); + final PantheonNode minerNodeTwo = pantheon.createMinerNode("miner-node2"); cluster.start(minerNodeTwo); final WebSocket heavyForkWebSocket = new WebSocket(vertx, minerNodeTwo); @@ -106,9 +103,10 @@ public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase { // Restart the two nodes on the light fork with the additional node from the heavy fork cluster.start(minerNode, archiveNode, minerNodeTwo); - final WebSocket minerMergedForksWebSocket = new WebSocket(vertx, minerNode); + final WebSocket minerMergedForksWebSocket = new WebSocket(vertx, minerNode.getConfiguration()); final WebSocket minerTwoMergedForksWebSocket = new WebSocket(vertx, minerNodeTwo); - final WebSocket archiveMergedForksWebSocket = new WebSocket(vertx, archiveNode); + final WebSocket archiveMergedForksWebSocket = + new WebSocket(vertx, archiveNode.getConfiguration()); final Subscription minerMergedForksSubscription = minerMergedForksWebSocket.subscribe(); final Subscription minerTwoMergedForksSubscription = minerTwoMergedForksWebSocket.subscribe(); final Subscription archiveMergedForksSubscription = archiveMergedForksWebSocket.subscribe(); diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/EventEmitterAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/EventEmitterAcceptanceTest.java index cebdb80d09..09b4f68ade 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/EventEmitterAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/EventEmitterAcceptanceTest.java @@ -14,7 +14,6 @@ package tech.pegasys.pantheon.tests.web3j; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonMinerNode; import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; @@ -48,7 +47,7 @@ public class EventEmitterAcceptanceTest extends AcceptanceTestBase { @Before public void setUp() throws Exception { - node = cluster.create(pantheonMinerNode("node1")); + node = pantheon.createMinerNode("node1"); cluster.start(node); }