Acceptance test refactor to use the Node interface and a Factory to create instances (#226)

CJ Hare 6 years ago committed by GitHub
parent 9f8512b4c0
commit ea0e323336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterAcceptanceTest.java
  2. 10
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/CreateAccountAcceptanceTest.java
  3. 10
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/RpcApisTogglesAcceptanceTest.java
  4. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/AcceptanceTestBase.java
  5. 39
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/net/AwaitNetPeerCount.java
  6. 32
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/JsonRpc.java
  7. 7
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Net.java
  8. 61
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/Cluster.java
  9. 3
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/Node.java
  10. 31
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/NodeConfiguration.java
  11. 84
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java
  12. 123
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNodeConfig.java
  13. 126
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNodeFactory.java
  14. 30
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/RunnableNode.java
  15. 2
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java
  16. 4
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/pubsub/WebSocket.java
  17. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/pubsub/WebSocketConnection.java
  18. 40
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetPeerCountTransaction.java
  19. 4
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetTransactions.java
  20. 13
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetWorkAcceptanceTest.java
  21. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/Web3Sha3AcceptanceTest.java
  22. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/mining/MiningAcceptanceTest.java
  23. 18
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/pubsub/NewPendingTransactionAcceptanceTest.java
  24. 3
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/EventEmitterAcceptanceTest.java

@ -12,30 +12,27 @@
*/ */
package tech.pegasys.pantheon.tests.acceptance; 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.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.Before;
import org.junit.Test; import org.junit.Test;
public class PantheonClusterAcceptanceTest extends AcceptanceTestBase { public class ClusterAcceptanceTest extends AcceptanceTestBase {
private PantheonNode minerNode; private Node minerNode;
private PantheonNode fullNode; private Node fullNode;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
minerNode = cluster.create(pantheonMinerNode("node1")); minerNode = pantheon.createMinerNode("node1");
fullNode = cluster.create(pantheonNode("node2")); fullNode = pantheon.createArchiveNode("node2");
cluster.start(minerNode, fullNode); cluster.start(minerNode, fullNode);
} }
@Test @Test
public void shouldConnectToOtherPeer() { public void shouldConnectToOtherPeer() {
jsonRpc.waitForPeersConnected(minerNode, 1); minerNode.verify(net.awaitPeerCount(1));
jsonRpc.waitForPeersConnected(fullNode, 1); fullNode.verify(net.awaitPeerCount(1));
} }
} }

@ -13,12 +13,10 @@
package tech.pegasys.pantheon.tests.acceptance; package tech.pegasys.pantheon.tests.acceptance;
import static org.web3j.utils.Convert.Unit.ETHER; 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.AcceptanceTestBase;
import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account; 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.Before;
import org.junit.Ignore; import org.junit.Ignore;
@ -27,12 +25,12 @@ import org.junit.Test;
@Ignore @Ignore
public class CreateAccountAcceptanceTest extends AcceptanceTestBase { public class CreateAccountAcceptanceTest extends AcceptanceTestBase {
private PantheonNode minerNode; private Node minerNode;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
minerNode = cluster.create(pantheonMinerNode("node1")); minerNode = pantheon.createMinerNode("node1");
cluster.start(minerNode, cluster.create(pantheonNode("node2"))); cluster.start(minerNode, pantheon.createArchiveNode("node2"));
} }
@Test @Test

@ -12,10 +12,6 @@
*/ */
package tech.pegasys.pantheon.tests.acceptance; 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.ethereum.jsonrpc.RpcApis;
import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; 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.PantheonNode;
@ -34,9 +30,9 @@ public class RpcApisTogglesAcceptanceTest extends AcceptanceTestBase {
@Before @Before
public void before() throws Exception { public void before() throws Exception {
rpcEnabledNode = cluster.create(pantheonNode("rpc-enabled")); rpcEnabledNode = pantheon.createArchiveNode("rpc-enabled");
rpcDisabledNode = cluster.create(pantheonRpcDisabledNode("rpc-disabled")); rpcDisabledNode = pantheon.createArchiveNodeWithRpcDisabled("rpc-disabled");
ethApiDisabledNode = cluster.create(patheonNodeWithRpcApis("eth-api-disabled", RpcApis.NET)); ethApiDisabledNode = pantheon.createArchiveNodeWithRpcApis("eth-api-disabled", RpcApis.NET);
cluster.start(rpcEnabledNode, rpcDisabledNode, ethApiDisabledNode); cluster.start(rpcEnabledNode, rpcDisabledNode, ethApiDisabledNode);
} }

@ -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.account.Accounts;
import tech.pegasys.pantheon.tests.acceptance.dsl.blockchain.Blockchain; 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.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.Net;
import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Web3; 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.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.Transactions;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth.EthTransactions; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth.EthTransactions;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.NetTransactions; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.NetTransactions;
@ -31,22 +31,22 @@ public class AcceptanceTestBase {
protected final Accounts accounts; protected final Accounts accounts;
protected final Blockchain blockchain; protected final Blockchain blockchain;
protected final Cluster cluster; protected final Cluster cluster;
protected final JsonRpc jsonRpc;
protected final Transactions transactions; protected final Transactions transactions;
protected final Web3 web3; protected final Web3 web3;
protected final Eth eth; protected final Eth eth;
protected final Net net; protected final Net net;
protected final PantheonNodeFactory pantheon;
protected AcceptanceTestBase() { protected AcceptanceTestBase() {
final EthTransactions ethTransactions = new EthTransactions(); final EthTransactions ethTransactions = new EthTransactions();
accounts = new Accounts(ethTransactions); accounts = new Accounts(ethTransactions);
blockchain = new Blockchain(ethTransactions); blockchain = new Blockchain(ethTransactions);
cluster = new Cluster();
eth = new Eth(ethTransactions); eth = new Eth(ethTransactions);
jsonRpc = new JsonRpc(cluster);
net = new Net(new NetTransactions()); net = new Net(new NetTransactions());
cluster = new Cluster(net);
transactions = new Transactions(accounts); transactions = new Transactions(accounts);
web3 = new Web3(new Web3Transactions()); web3 = new Web3(new Web3Transactions());
pantheon = new PantheonNodeFactory();
} }
@After @After

@ -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));
}
}

@ -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));
}
}

@ -13,11 +13,14 @@
package tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc; 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.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.ExpectNetVersionConnectionException;
import tech.pegasys.pantheon.tests.acceptance.dsl.condition.net.ExpectNetVersionConnectionExceptionWithCause; 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.condition.net.ExpectNetVersionIsNotBlank;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.NetTransactions; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.NetTransactions;
import java.math.BigInteger;
public class Net { public class Net {
private final NetTransactions transactions; private final NetTransactions transactions;
@ -30,6 +33,10 @@ public class Net {
return new ExpectNetVersionIsNotBlank(transactions.netVersion()); 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) { public Condition netVersionExceptional(final String expectedMessage) {
return new ExpectNetVersionConnectionException(transactions.netVersion(), expectedMessage); return new ExpectNetVersionConnectionException(transactions.netVersion(), expectedMessage);
} }

@ -14,42 +14,58 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.node;
import static org.assertj.core.api.Assertions.assertThat; 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.condition.Condition;
import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Net;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
public class Cluster implements AutoCloseable { public class Cluster implements AutoCloseable {
private final Map<String, PantheonNode> nodes = new HashMap<>(); private final Map<String, RunnableNode> nodes = new HashMap<>();
private final PantheonNodeRunner pantheonNodeRunner = PantheonNodeRunner.instance(); 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<RunnableNode> nodes) {
this.nodes.clear(); this.nodes.clear();
final List<String> bootNodes = new ArrayList<>(); final List<String> bootNodes = new ArrayList<>();
for (final RunnableNode node : nodes) {
for (final PantheonNode node : nodes) {
this.nodes.put(node.getName(), node); this.nodes.put(node.getName(), node);
bootNodes.add(node.enodeUrl()); bootNodes.add(node.getConfiguration().enodeUrl());
} }
for (final PantheonNode node : nodes) { for (final RunnableNode node : nodes) {
node.bootnodes(bootNodes); node.getConfiguration().bootnodes(bootNodes);
node.start(pantheonNodeRunner); node.start(pantheonNodeRunner);
} }
for (final PantheonNode node : nodes) { for (final RunnableNode node : nodes) {
awaitPeerDiscovery(node, nodes.length); node.awaitPeerDiscovery(net.awaitPeerCount(nodes.size() - 1));
} }
} }
public void stop() { public void stop() {
for (final PantheonNode node : nodes.values()) { for (final RunnableNode node : nodes.values()) {
node.stop(); node.stop();
} }
pantheonNodeRunner.shutdown(); pantheonNodeRunner.shutdown();
@ -57,31 +73,12 @@ public class Cluster implements AutoCloseable {
@Override @Override
public void close() { public void close() {
for (final PantheonNode node : nodes.values()) { for (final RunnableNode node : nodes.values()) {
node.close(); node.close();
} }
pantheonNodeRunner.shutdown(); 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) { public void verify(final Condition expected) {
for (final Node node : nodes.values()) { for (final Node node : nodes.values()) {
expected.verify(node); expected.verify(node);

@ -12,9 +12,12 @@
*/ */
package tech.pegasys.pantheon.tests.acceptance.dsl.node; 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; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
public interface Node { public interface Node {
<T> T execute(Transaction<T> transaction); <T> T execute(Transaction<T> transaction);
void verify(final Condition expected);
} }

@ -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<String> bootnodes);
void useWebSocketsForJsonRpc();
Optional<Integer> jsonRpcWebSocketPort();
String hostName();
boolean jsonRpcEnabled();
}

@ -43,54 +43,61 @@ import org.web3j.protocol.http.HttpService;
import org.web3j.protocol.websocket.WebSocketService; import org.web3j.protocol.websocket.WebSocketService;
import org.web3j.utils.Async; 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 String LOCALHOST = "127.0.0.1";
private static final Logger LOG = getLogger(); private static final Logger LOG = getLogger();
private final String name;
private final Path homeDirectory; private final Path homeDirectory;
private final KeyPair keyPair; private final KeyPair keyPair;
private final int p2pPort; private final int p2pPort;
private final Properties portsProperties = new Properties();
private final String name;
private final MiningParameters miningParameters; private final MiningParameters miningParameters;
private final JsonRpcConfiguration jsonRpcConfiguration; private final JsonRpcConfiguration jsonRpcConfiguration;
private final WebSocketConfiguration webSocketConfiguration; private final WebSocketConfiguration webSocketConfiguration;
private final boolean jsonRpcEnabled;
private final boolean wsRpcEnabled;
private final Properties portsProperties = new Properties();
private List<String> bootnodes = new ArrayList<>(); private List<String> bootnodes = new ArrayList<>();
private Web3j web3j; private Web3j web3j;
public PantheonNode( public PantheonNode(
final String name, final String name,
final int p2pPort,
final MiningParameters miningParameters, final MiningParameters miningParameters,
final JsonRpcConfiguration jsonRpcConfiguration, final JsonRpcConfiguration jsonRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration) final WebSocketConfiguration webSocketConfiguration,
final int p2pPort)
throws IOException { throws IOException {
this.name = name;
this.homeDirectory = Files.createTempDirectory("acctest"); this.homeDirectory = Files.createTempDirectory("acctest");
this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory); this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory);
this.p2pPort = p2pPort; this.p2pPort = p2pPort;
this.name = name;
this.miningParameters = miningParameters; this.miningParameters = miningParameters;
this.jsonRpcConfiguration = jsonRpcConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration;
this.webSocketConfiguration = webSocketConfiguration; this.webSocketConfiguration = webSocketConfiguration;
this.jsonRpcEnabled = jsonRpcConfiguration.isEnabled();
this.wsRpcEnabled = webSocketConfiguration.isEnabled();
LOG.info("Created PantheonNode {}", this.toString()); 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; return name;
} }
String enodeUrl() { @Override
public String enodeUrl() {
return "enode://" + keyPair.getPublicKey().toString() + "@" + LOCALHOST + ":" + p2pPort; return "enode://" + keyPair.getPublicKey().toString() + "@" + LOCALHOST + ":" + p2pPort;
} }
private Optional<String> jsonRpcBaseUrl() { private Optional<String> jsonRpcBaseUrl() {
if (jsonRpcEnabled) { if (isJsonRpcEnabled()) {
return Optional.of( return Optional.of(
"http://" "http://"
+ jsonRpcConfiguration.getHost() + jsonRpcConfiguration.getHost()
@ -102,7 +109,7 @@ public class PantheonNode implements Node, AutoCloseable {
} }
private Optional<String> wsRpcBaseUrl() { private Optional<String> wsRpcBaseUrl() {
if (wsRpcEnabled) { if (isWebSocketsRpcEnabled()) {
return Optional.of( return Optional.of(
"ws://" + webSocketConfiguration.getHost() + ":" + portsProperties.getProperty("ws-rpc")); "ws://" + webSocketConfiguration.getHost() + ":" + portsProperties.getProperty("ws-rpc"));
} else { } else {
@ -110,15 +117,17 @@ public class PantheonNode implements Node, AutoCloseable {
} }
} }
@Override
public Optional<Integer> jsonRpcWebSocketPort() { public Optional<Integer> jsonRpcWebSocketPort() {
if (wsRpcEnabled) { if (isWebSocketsRpcEnabled()) {
return Optional.of(Integer.valueOf(portsProperties.getProperty("ws-rpc"))); return Optional.of(Integer.valueOf(portsProperties.getProperty("ws-rpc")));
} else { } else {
return Optional.empty(); return Optional.empty();
} }
} }
public String getHost() { @Override
public String hostName() {
return LOCALHOST; return LOCALHOST;
} }
@ -153,6 +162,7 @@ public class PantheonNode implements Node, AutoCloseable {
} }
/** All future JSON-RPC calls are made via a web sockets connection. */ /** All future JSON-RPC calls are made via a web sockets connection. */
@Override
public void useWebSocketsForJsonRpc() { public void useWebSocketsForJsonRpc() {
final String url = wsRpcBaseUrl().isPresent() ? wsRpcBaseUrl().get() : "ws://127.0.0.1:8546"; 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()); web3j = Web3j.build(webSocketService, 2000, Async.defaultExecutorService());
} }
public int getPeerCount() { @Override
try {
return web3j().netPeerCount().send().getQuantity().intValueExact();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
public void start(final PantheonNodeRunner runner) { public void start(final PantheonNodeRunner runner) {
runner.startNode(this); runner.startNode(this);
loadPortsFile(); loadPortsFile();
} }
@Override
public NodeConfiguration getConfiguration() {
return this;
}
@Override
public void awaitPeerDiscovery(final Condition condition) {
if (jsonRpcEnabled()) {
verify(condition);
}
}
private void loadPortsFile() { private void loadPortsFile() {
try (final FileInputStream fis = try (final FileInputStream fis =
new FileInputStream(new File(homeDirectory.toFile(), "pantheon.ports"))) { new FileInputStream(new File(homeDirectory.toFile(), "pantheon.ports"))) {
@ -191,8 +206,9 @@ public class PantheonNode implements Node, AutoCloseable {
return homeDirectory; return homeDirectory;
} }
boolean jsonRpcEnabled() { @Override
return jsonRpcEnabled; public boolean jsonRpcEnabled() {
return isJsonRpcEnabled();
} }
JsonRpcConfiguration jsonRpcConfiguration() { JsonRpcConfiguration jsonRpcConfiguration() {
@ -200,15 +216,15 @@ public class PantheonNode implements Node, AutoCloseable {
} }
Optional<String> jsonRpcListenAddress() { Optional<String> jsonRpcListenAddress() {
if (jsonRpcEnabled) { if (isJsonRpcEnabled()) {
return Optional.of(jsonRpcConfiguration.getHost() + ":" + jsonRpcConfiguration.getPort()); return Optional.of(jsonRpcConfiguration().getHost() + ":" + jsonRpcConfiguration().getPort());
} else { } else {
return Optional.empty(); return Optional.empty();
} }
} }
boolean wsRpcEnabled() { boolean wsRpcEnabled() {
return wsRpcEnabled; return isWebSocketsRpcEnabled();
} }
WebSocketConfiguration webSocketConfiguration() { WebSocketConfiguration webSocketConfiguration() {
@ -216,7 +232,8 @@ public class PantheonNode implements Node, AutoCloseable {
} }
Optional<String> wsRpcListenAddress() { Optional<String> wsRpcListenAddress() {
return Optional.of(webSocketConfiguration.getHost() + ":" + webSocketConfiguration.getPort()); return Optional.of(
webSocketConfiguration().getHost() + ":" + webSocketConfiguration().getPort());
} }
int p2pPort() { int p2pPort() {
@ -234,7 +251,8 @@ public class PantheonNode implements Node, AutoCloseable {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
void bootnodes(final List<String> bootnodes) { @Override
public void bootnodes(final List<String> bootnodes) {
this.bootnodes = bootnodes; this.bootnodes = bootnodes;
} }
@ -252,7 +270,8 @@ public class PantheonNode implements Node, AutoCloseable {
.toString(); .toString();
} }
void stop() { @Override
public void stop() {
if (web3j != null) { if (web3j != null) {
web3j.shutdown(); web3j.shutdown();
web3j = null; web3j = null;
@ -274,6 +293,7 @@ public class PantheonNode implements Node, AutoCloseable {
return transaction.execute(web3j()); return transaction.execute(web3j());
} }
@Override
public void verify(final Condition expected) { public void verify(final Condition expected) {
expected.verify(this); expected.verify(this);
} }

@ -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;
}
}

@ -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;
}
}
}

@ -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();
}

@ -71,7 +71,7 @@ public class ThreadPantheonNodeRunner implements PantheonNodeRunner {
pantheonController, pantheonController,
true, true,
node.bootnodes(), node.bootnodes(),
node.getHost(), node.hostName(),
node.p2pPort(), node.p2pPort(),
25, 25,
node.jsonRpcConfiguration(), node.jsonRpcConfiguration(),

@ -14,7 +14,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.pubsub;
import static org.assertj.core.api.Assertions.assertThat; 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; import java.util.List;
@ -26,7 +26,7 @@ public class WebSocket {
private final WebSocketConnection connection; 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); this.connection = new WebSocketConnection(vertx, node);
} }

@ -15,7 +15,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.pubsub;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.WaitUtils; 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.ArrayList;
import java.util.List; import java.util.List;
@ -39,7 +39,7 @@ public class WebSocketConnection {
private volatile JsonRpcSuccessEvent latestEvent; private volatile JsonRpcSuccessEvent latestEvent;
private volatile WebSocket connection; private volatile WebSocket connection;
public WebSocketConnection(final Vertx vertx, final PantheonNode node) { public WebSocketConnection(final Vertx vertx, final NodeConfiguration node) {
if (!node.jsonRpcWebSocketPort().isPresent()) { if (!node.jsonRpcWebSocketPort().isPresent()) {
throw new IllegalStateException( throw new IllegalStateException(
"Can't start websocket connection for node with RPC disabled"); "Can't start websocket connection for node with RPC disabled");
@ -47,7 +47,7 @@ public class WebSocketConnection {
subscriptionEvents = new ConcurrentLinkedDeque<>(); subscriptionEvents = new ConcurrentLinkedDeque<>();
options = new RequestOptions(); options = new RequestOptions();
options.setPort(node.jsonRpcWebSocketPort().get()); options.setPort(node.jsonRpcWebSocketPort().get());
options.setHost(node.getHost()); options.setHost(node.hostName());
connect(vertx); connect(vertx);
} }

@ -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<BigInteger> {
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);
}
}
}

@ -17,4 +17,8 @@ public class NetTransactions {
public NetVersionTransaction netVersion() { public NetVersionTransaction netVersion() {
return new NetVersionTransaction(); return new NetVersionTransaction();
} }
public NetPeerCountTransaction peerCount() {
return new NetPeerCountTransaction();
}
} }

@ -12,24 +12,21 @@
*/ */
package tech.pegasys.pantheon.tests.acceptance.jsonrpc; 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.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.Before;
import org.junit.Test; import org.junit.Test;
public class EthGetWorkAcceptanceTest extends AcceptanceTestBase { public class EthGetWorkAcceptanceTest extends AcceptanceTestBase {
private PantheonNode minerNode; private Node minerNode;
private PantheonNode fullNode; private Node fullNode;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
minerNode = cluster.create(pantheonMinerNode("node1")); minerNode = pantheon.createMinerNode("node1");
fullNode = cluster.create(pantheonNode("node2")); fullNode = pantheon.createArchiveNode("node2");
cluster.start(minerNode, fullNode); cluster.start(minerNode, fullNode);
} }

@ -12,21 +12,19 @@
*/ */
package tech.pegasys.pantheon.tests.acceptance.jsonrpc; 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.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.Before;
import org.junit.Test; import org.junit.Test;
public class Web3Sha3AcceptanceTest extends AcceptanceTestBase { public class Web3Sha3AcceptanceTest extends AcceptanceTestBase {
private PantheonNode node; private Node node;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
node = cluster.create(pantheonNode("node1")); node = pantheon.createArchiveNode("node1");
cluster.start(node); cluster.start(node);
} }

@ -12,11 +12,9 @@
*/ */
package tech.pegasys.pantheon.tests.acceptance.mining; 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.AcceptanceTestBase;
import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account; 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.Before;
import org.junit.Ignore; import org.junit.Ignore;
@ -25,11 +23,11 @@ import org.junit.Test;
@Ignore @Ignore
public class MiningAcceptanceTest extends AcceptanceTestBase { public class MiningAcceptanceTest extends AcceptanceTestBase {
private PantheonNode minerNode; private Node minerNode;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
minerNode = cluster.create(pantheonMinerNode("miner1")); minerNode = pantheon.createMinerNode("miner1");
cluster.start(minerNode); cluster.start(minerNode);
} }

@ -12,9 +12,6 @@
*/ */
package tech.pegasys.pantheon.tests.acceptance.pubsub; 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.ethereum.core.Hash;
import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase;
import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account; import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account;
@ -42,12 +39,12 @@ public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
vertx = Vertx.vertx(); vertx = Vertx.vertx();
minerNode = cluster.create(pantheonMinerNode("miner-node1")); minerNode = pantheon.createMinerNode("miner-node1");
archiveNode = cluster.create(pantheonNode("full-node1")); archiveNode = pantheon.createArchiveNode("full-node1");
cluster.start(minerNode, archiveNode); cluster.start(minerNode, archiveNode);
accountOne = accounts.createAccount("account-one"); accountOne = accounts.createAccount("account-one");
minerWebSocket = new WebSocket(vertx, minerNode); minerWebSocket = new WebSocket(vertx, minerNode.getConfiguration());
archiveWebSocket = new WebSocket(vertx, archiveNode); archiveWebSocket = new WebSocket(vertx, archiveNode.getConfiguration());
} }
@After @After
@ -72,7 +69,7 @@ public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase {
cluster.stop(); cluster.stop();
// Create the heavy fork // Create the heavy fork
final PantheonNode minerNodeTwo = cluster.create(pantheonMinerNode("miner-node2")); final PantheonNode minerNodeTwo = pantheon.createMinerNode("miner-node2");
cluster.start(minerNodeTwo); cluster.start(minerNodeTwo);
final WebSocket heavyForkWebSocket = new WebSocket(vertx, 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 // Restart the two nodes on the light fork with the additional node from the heavy fork
cluster.start(minerNode, archiveNode, minerNodeTwo); 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 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 minerMergedForksSubscription = minerMergedForksWebSocket.subscribe();
final Subscription minerTwoMergedForksSubscription = minerTwoMergedForksWebSocket.subscribe(); final Subscription minerTwoMergedForksSubscription = minerTwoMergedForksWebSocket.subscribe();
final Subscription archiveMergedForksSubscription = archiveMergedForksWebSocket.subscribe(); final Subscription archiveMergedForksSubscription = archiveMergedForksWebSocket.subscribe();

@ -14,7 +14,6 @@ package tech.pegasys.pantheon.tests.web3j;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; 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.AcceptanceTestBase;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode;
@ -48,7 +47,7 @@ public class EventEmitterAcceptanceTest extends AcceptanceTestBase {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
node = cluster.create(pantheonMinerNode("node1")); node = pantheon.createMinerNode("node1");
cluster.start(node); cluster.start(node);
} }

Loading…
Cancel
Save