Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
!!
Browse files Browse the repository at this point in the history
  • Loading branch information
smatthewenglish committed May 13, 2019
1 parent a064a67 commit 64efbdc
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public class AcceptanceTestBase {
protected final ContractVerifier contractVerifier;
protected final WaitConditions wait;
protected final PermissionedNodeBuilder permissionedNodeBuilder;

protected final NetServices netServices;

protected AcceptanceTestBase() {
Expand All @@ -81,7 +80,6 @@ protected AcceptanceTestBase() {
contractVerifier = new ContractVerifier(accounts.getPrimaryBenefactor());
wait = new WaitConditions(ethTransactions, cliqueTransactions, ibftTransactions);
permissionedNodeBuilder = new PermissionedNodeBuilder();

netServices = new NetServices();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,40 @@
package tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;

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.node.RunnableNode;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;

import java.io.IOException;
import java.net.URI;

import org.web3j.protocol.core.Response;

public class Admin {
private Transaction<Boolean> addPeerTransaction(final URI enode) {
return (n) -> {
try {
final Response<Boolean> resp = n.admin().adminAddPeer(enode).send();
assertThat(resp).isNotNull();
assertThat(resp.hasError()).isFalse();
return resp.getResult();
} catch (final IOException e) {
throw new RuntimeException(e);
}
};
}

public Condition addPeer(final Node node) {
if (!(node instanceof RunnableNode)) {
fail("Admin.addPeer() needs a RunnableNode instance");
}

System.out.println("999");

return new Condition() {
@Override
public void verify(Node x) {

System.out.println("888");

final Boolean result =
node.execute(
new Transaction<Boolean>() {
@Override
public Boolean execute(JsonRequestFactories requestFactories) {

System.out.println("777");

Response<Boolean> resp = null;
try {
URI enodeUrl = ((RunnableNode) x).enodeUrl();
resp = requestFactories.admin().adminAddPeer(enodeUrl).send();
assertThat(resp).isNotNull();
assertThat(resp.hasError()).isFalse();
} catch (final Exception ignored) {
}
return resp.getResult();
}
});
assertThat(result).isTrue();
}
return (n) -> {
final Boolean result = n.execute(addPeerTransaction(((RunnableNode) node).enodeUrl()));
assertThat(result).isTrue();
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Map<String, Map<String, String>> addPeer(final Node node) {
new Transaction<Map<String, Map<String, String>>>() {
@Override
public Map<String, Map<String, String>> execute(
JsonRequestFactories requestFactories) {
final JsonRequestFactories requestFactories) {
NetServicesJsonRpcRequestFactory.NetServicesResponse c = null;
try {
NetServicesJsonRpcRequestFactory s = requestFactories.netServices();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import org.web3j.protocol.core.Request;
import org.web3j.protocol.core.Response;

@SuppressWarnings({"unchecked", "rawtypes"})
public class NetServicesJsonRpcRequestFactory {

// public static class ProposalsResponse extends Response<Map<Address, Boolean>> {}
public static class NetServicesResponse extends Response<Map<String, Map<String, String>>> {}

private final Web3jService web3jService;
Expand All @@ -32,7 +32,7 @@ public NetServicesJsonRpcRequestFactory(final Web3jService web3jService) {

public Request<?, NetServicesResponse> netServices() {

Request request =
final Request request =
new Request<>(
"net_services", Collections.EMPTY_LIST, web3jService, NetServicesResponse.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.junit.Before;
import org.junit.Test;

@SuppressWarnings({"unchecked", "rawtypes"})
public class NetServicesAcceptanceTest extends AcceptanceTestBase {

private Cluster noDiscoveryCluster;
Expand All @@ -45,9 +46,9 @@ public void setUp() throws Exception {

@Test
public void adminAddPeerForcesConnection() {
Map<String, Map<String, String>> result = netServices.addPeer(nodeA);
Map<String, Map<String, String>> expectation = new HashMap<>();
Map<String, String> constituentMap =
final Map<String, Map<String, String>> result = netServices.addPeer(nodeA);
final Map<String, Map<String, String>> expectation = new HashMap<>();
final Map<String, String> constituentMap =
new HashMap() {
{
put("host", "127.0.0.1");
Expand Down
49 changes: 27 additions & 22 deletions pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
import tech.pegasys.pantheon.ethereum.core.Synchronizer;
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPool;
import tech.pegasys.pantheon.ethereum.graphqlrpc.GraphQLDataFetcherContext;
import tech.pegasys.pantheon.ethereum.graphqlrpc.GraphQLDataFetchers;
import tech.pegasys.pantheon.ethereum.graphqlrpc.GraphQLProvider;
import tech.pegasys.pantheon.ethereum.graphqlrpc.GraphQLRpcConfiguration;
import tech.pegasys.pantheon.ethereum.graphqlrpc.GraphQLRpcHttpService;
import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration;
Expand Down Expand Up @@ -72,6 +75,7 @@
import tech.pegasys.pantheon.util.bytes.BytesValue;
import tech.pegasys.pantheon.util.enode.EnodeURL;

import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.util.ArrayList;
Expand All @@ -85,6 +89,7 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import graphql.GraphQL;
import io.vertx.core.Vertx;

public class RunnerBuilder {
Expand Down Expand Up @@ -341,28 +346,28 @@ public Runner build() {
}

Optional<GraphQLRpcHttpService> graphQLRpcHttpService = Optional.empty();
// if (graphQLRpcConfiguration.isEnabled()) {
// final GraphQLDataFetchers fetchers = new GraphQLDataFetchers(supportedCapabilities);
// final GraphQLDataFetcherContext dataFetcherContext =
// new GraphQLDataFetcherContext(
// context.getBlockchain(),
// context.getWorldStateArchive(),
// protocolSchedule,
// transactionPool,
// miningCoordinator,
// synchronizer);
// GraphQL graphQL = null;
// try {
// graphQL = GraphQLProvider.buildGraphQL(fetchers);
// } catch (final IOException ioe) {
// throw new RuntimeException(ioe);
// }
//
// graphQLRpcHttpService =
// Optional.of(
// new GraphQLRpcHttpService(
// vertx, dataDir, graphQLRpcConfiguration, graphQL, dataFetcherContext));
// }
if (graphQLRpcConfiguration.isEnabled()) {
final GraphQLDataFetchers fetchers = new GraphQLDataFetchers(supportedCapabilities);
final GraphQLDataFetcherContext dataFetcherContext =
new GraphQLDataFetcherContext(
context.getBlockchain(),
context.getWorldStateArchive(),
protocolSchedule,
transactionPool,
miningCoordinator,
synchronizer);
GraphQL graphQL = null;
try {
graphQL = GraphQLProvider.buildGraphQL(fetchers);
} catch (final IOException ioe) {
throw new RuntimeException(ioe);
}

graphQLRpcHttpService =
Optional.of(
new GraphQLRpcHttpService(
vertx, dataDir, graphQLRpcConfiguration, graphQL, dataFetcherContext));
}

Optional<WebSocketService> webSocketService = Optional.empty();
if (webSocketConfiguration.isEnabled()) {
Expand Down

0 comments on commit 64efbdc

Please sign in to comment.