Enabling previously ignored acceptance tests (#282)

Lucas Saldanha 6 years ago committed by GitHub
parent 2f2050bad0
commit 126e30b0e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Jenkinsfile
  2. 2
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/CreateAccountAcceptanceTest.java
  3. 14
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/RpcApisTogglesAcceptanceTest.java
  4. 49
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java
  5. 2
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/mining/MiningAcceptanceTest.java
  6. 5
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/pubsub/NewPendingTransactionAcceptanceTest.java
  7. 2
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/EventEmitterAcceptanceTest.java

2
Jenkinsfile vendored

@ -44,7 +44,7 @@ stage('Pantheon tests') {
sh './gradlew --no-daemon --parallel integrationTest'
}
stage('Acceptance Tests') {
sh './gradlew --no-daemon --parallel acceptanceTest --tests Web3Sha3AcceptanceTest --tests PantheonClusterAcceptanceTest --tests MiningAcceptanceTest'
sh './gradlew --no-daemon --parallel acceptanceTest'
}
stage('Check Licenses') {
sh './gradlew --no-daemon --parallel checkLicenses'

@ -19,10 +19,8 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@Ignore
public class CreateAccountAcceptanceTest extends AcceptanceTestBase {
private Node minerNode;

@ -12,16 +12,17 @@
*/
package tech.pegasys.pantheon.tests.acceptance;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApis;
import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode;
import org.java_websocket.exceptions.WebsocketNotConnectedException;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@Ignore
public class RpcApisTogglesAcceptanceTest extends AcceptanceTestBase {
private PantheonNode rpcEnabledNode;
@ -52,15 +53,16 @@ public class RpcApisTogglesAcceptanceTest extends AcceptanceTestBase {
public void shouldSucceedConnectingToNodeWithWsRpcEnabled() {
rpcEnabledNode.useWebSocketsForJsonRpc();
// TODO previously this test was calling netVersion using the HTTP not WebSockets, now failing
rpcEnabledNode.verify(net.netVersion());
}
@Test
public void shouldFailConnectingToNodeWithWsRpcDisabled() {
rpcDisabledNode.useWebSocketsForJsonRpc();
rpcDisabledNode.verify(net.netVersionExceptional(WebsocketNotConnectedException.class));
rpcDisabledNode.verify(
node -> {
final Throwable thrown = catchThrowable(() -> rpcDisabledNode.useWebSocketsForJsonRpc());
assertThat(thrown).isInstanceOf(WebsocketNotConnectedException.class);
});
}
@Test

@ -25,20 +25,28 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.ConnectException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.google.common.base.MoreObjects;
import com.google.common.io.MoreFiles;
import com.google.common.io.RecursiveDeleteOption;
import org.apache.logging.log4j.Logger;
import org.awaitility.Awaitility;
import org.awaitility.core.ConditionTimeoutException;
import org.java_websocket.exceptions.WebsocketNotConnectedException;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;
import org.web3j.protocol.websocket.WebSocketClient;
import org.web3j.protocol.websocket.WebSocketListener;
import org.web3j.protocol.websocket.WebSocketService;
import org.web3j.utils.Async;
@ -150,7 +158,14 @@ public class PantheonNode implements Node, NodeConfiguration, RunnableNode, Auto
public void useWebSocketsForJsonRpc() {
final String url = wsRpcBaseUrl().isPresent() ? wsRpcBaseUrl().get() : "ws://127.0.0.1:8546";
checkIfWebSocketEndpointIsAvailable(url);
final WebSocketService webSocketService = new WebSocketService(url, true);
try {
webSocketService.connect();
} catch (ConnectException e) {
throw new RuntimeException("Error connection to WebSocket endpoint", e);
}
if (web3j != null) {
web3j.shutdown();
@ -159,6 +174,40 @@ public class PantheonNode implements Node, NodeConfiguration, RunnableNode, Auto
web3j = Web3j.build(webSocketService, 2000, Async.defaultExecutorService());
}
private void checkIfWebSocketEndpointIsAvailable(final String url) {
WebSocketClient webSocketClient = new WebSocketClient(URI.create(url));
// Web3j implementation always invoke the listener (even when one hasn't been set). We are using
// this stub implementation to avoid a NullPointerException.
webSocketClient.setListener(
new WebSocketListener() {
@Override
public void onMessage(final String message) {
// DO NOTHING
}
@Override
public void onError(final Exception e) {
// DO NOTHING
}
@Override
public void onClose() {
// DO NOTHING
}
});
// Because we can't trust the connection timeout of the WebSocket client implementation, we are
// using this approach to verify if the endpoint is enabled.
webSocketClient.connect();
try {
Awaitility.await().atMost(5, TimeUnit.SECONDS).until(webSocketClient::isOpen);
} catch (ConditionTimeoutException e) {
throw new WebsocketNotConnectedException();
} finally {
webSocketClient.close();
}
}
@Override
public void start(final PantheonNodeRunner runner) {
runner.startNode(this);

@ -17,10 +17,8 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@Ignore
public class MiningAcceptanceTest extends AcceptanceTestBase {
private Node minerNode;

@ -26,7 +26,6 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@Ignore
public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase {
private Vertx vertx;
@ -52,7 +51,11 @@ public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase {
vertx.close();
}
/*
This test will be fixed on NC-1952
*/
@Test
@Ignore
public void transactionRemovedByChainReorganisationMustPublishEvent() throws Exception {
// Create the light fork

@ -25,7 +25,6 @@ import java.math.BigInteger;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
@ -34,7 +33,6 @@ import rx.Observable;
/*
* This class is based around the EventEmitter solidity contract
*/
@Ignore
public class EventEmitterAcceptanceTest extends AcceptanceTestBase {
private PantheonNode node;

Loading…
Cancel
Save