Basic Ibft Json Acceptance tests (#634)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
tmohay 6 years ago committed by GitHub
parent 5e8ecff6bc
commit fd950378f9
  1. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/AcceptanceTestBase.java
  2. 38
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/ibft/ExpectProposals.java
  3. 39
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/ibft/ExpectValidators.java
  4. 2
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Admin.java
  5. 62
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Ibft.java
  6. 50
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java
  7. 38
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/AdminJsonRpcRequestFactory.java
  8. 66
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/CliqueJsonRpcRequestFactory.java
  9. 4
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/DeploySmartContractTransaction.java
  10. 70
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/IbftJsonRpcRequestFactory.java
  11. 65
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/JsonRequestFactories.java
  12. 149
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/PantheonWeb3j.java
  13. 79
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/PermissioningJsonRpcRequestFactory.java
  14. 42
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/ResponseTypes.java
  15. 2
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/Transaction.java
  16. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/account/TransferTransaction.java
  17. 4
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/account/TransferTransactionSet.java
  18. 9
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/clique/CliqueDiscard.java
  19. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/clique/CliqueGetSigners.java
  20. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/clique/CliqueGetSignersAtHash.java
  21. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/clique/CliqueProposals.java
  22. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/clique/CliquePropose.java
  23. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthAccountsTransaction.java
  24. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthBlockNumberTransaction.java
  25. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthGetBalanceTransaction.java
  26. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthGetBlockTransaction.java
  27. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthGetTransactionCountTransaction.java
  28. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthGetTransactionReceiptTransaction.java
  29. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthGetWorkTransaction.java
  30. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthSendRawTransactionTransaction.java
  31. 41
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/ibft/IbftDiscard.java
  32. 43
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/ibft/IbftGetValidators.java
  33. 44
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/ibft/IbftGetValidatorsAtHash.java
  34. 38
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/ibft/IbftProposals.java
  35. 43
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/ibft/IbftPropose.java
  36. 48
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/ibft/IbftTransactions.java
  37. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetPeerCountTransaction.java
  38. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetVersionTransaction.java
  39. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/PermAddAccountsToWhitelistTransaction.java
  40. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/PermAddNodeTransaction.java
  41. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/PermGetAccountsWhitelistTransaction.java
  42. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/PermGetNodesWhitelistTransaction.java
  43. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/PermRemoveAccountsFromWhitelistTransaction.java
  44. 8
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/perm/PermRemoveNodeTransaction.java
  45. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/web3/Web3Sha3Transaction.java
  46. 10
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/waitcondition/WaitConditions.java
  47. 44
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/waitcondition/WaitUntilValidatorsChanged.java
  48. 48
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java
  49. 42
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftProposalRpcAcceptanceTest.java
  50. 52
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftProposeRpcAcceptanceTest.java

@ -27,6 +27,7 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.node.factory.PantheonNodeFacto
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.clique.CliqueTransactions; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.clique.CliqueTransactions;
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.ibft.IbftTransactions;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.NetTransactions; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.NetTransactions;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.web3.Web3Transactions; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.web3.Web3Transactions;
import tech.pegasys.pantheon.tests.acceptance.dsl.waitcondition.WaitConditions; import tech.pegasys.pantheon.tests.acceptance.dsl.waitcondition.WaitConditions;
@ -39,6 +40,7 @@ public class AcceptanceTestBase {
protected final Blockchain blockchain; protected final Blockchain blockchain;
protected final Cluster cluster; protected final Cluster cluster;
protected final CliqueTransactions cliqueTransactions; protected final CliqueTransactions cliqueTransactions;
protected final IbftTransactions ibftTransactions;
protected final Transactions transactions; protected final Transactions transactions;
protected final Clique clique; protected final Clique clique;
protected final Ibft ibft; protected final Ibft ibft;
@ -57,8 +59,10 @@ public class AcceptanceTestBase {
blockchain = new Blockchain(ethTransactions); blockchain = new Blockchain(ethTransactions);
eth = new Eth(ethTransactions); eth = new Eth(ethTransactions);
cliqueTransactions = new CliqueTransactions(); cliqueTransactions = new CliqueTransactions();
ibftTransactions = new IbftTransactions();
clique = new Clique(ethTransactions, cliqueTransactions); clique = new Clique(ethTransactions, cliqueTransactions);
ibft = new Ibft(); ibft = new Ibft(ibftTransactions);
net = new Net(new NetTransactions()); net = new Net(new NetTransactions());
cluster = new Cluster(net); cluster = new Cluster(net);
transactions = new Transactions(accounts); transactions = new Transactions(accounts);
@ -67,7 +71,7 @@ public class AcceptanceTestBase {
web3 = new Web3(new Web3Transactions()); web3 = new Web3(new Web3Transactions());
pantheon = new PantheonNodeFactory(); pantheon = new PantheonNodeFactory();
contractVerifier = new ContractVerifier(accounts.getPrimaryBenefactor()); contractVerifier = new ContractVerifier(accounts.getPrimaryBenefactor());
wait = new WaitConditions(ethTransactions, cliqueTransactions); wait = new WaitConditions(ethTransactions, cliqueTransactions, ibftTransactions);
} }
@After @After

@ -0,0 +1,38 @@
/*
* 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.ibft;
import static org.assertj.core.api.Assertions.assertThat;
import static tech.pegasys.pantheon.tests.acceptance.dsl.WaitUtils.waitFor;
import tech.pegasys.pantheon.ethereum.core.Address;
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.ibft.IbftTransactions;
import java.util.Map;
public class ExpectProposals implements Condition {
private final IbftTransactions ibft;
private final Map<Address, Boolean> proposers;
public ExpectProposals(final IbftTransactions ibft, final Map<Address, Boolean> proposers) {
this.ibft = ibft;
this.proposers = proposers;
}
@Override
public void verify(final Node node) {
waitFor(() -> assertThat(node.execute(ibft.createProposals())).isEqualTo(proposers));
}
}

@ -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.ibft;
import static org.assertj.core.api.Assertions.assertThat;
import static tech.pegasys.pantheon.tests.acceptance.dsl.WaitUtils.waitFor;
import static tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ibft.IbftTransactions.LATEST;
import tech.pegasys.pantheon.ethereum.core.Address;
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.ibft.IbftTransactions;
public class ExpectValidators implements Condition {
private final IbftTransactions ibft;
private final Address[] validators;
public ExpectValidators(final IbftTransactions ibft, final Address... validators) {
this.ibft = ibft;
this.validators = validators;
}
@Override
public void verify(final Node node) {
waitFor(
() ->
assertThat(node.execute(ibft.createGetValidators(LATEST))).containsExactly(validators));
}
}

@ -25,7 +25,7 @@ public class Admin {
private Transaction<Boolean> addPeerTransaction(final String enode) { private Transaction<Boolean> addPeerTransaction(final String enode) {
return (n) -> { return (n) -> {
try { try {
final Response<Boolean> resp = n.adminAddPeer(enode).send(); final Response<Boolean> resp = n.admin().adminAddPeer(enode).send();
assertThat(resp).isNotNull(); assertThat(resp).isNotNull();
assertThat(resp.hasError()).isFalse(); assertThat(resp.hasError()).isFalse();
return resp.getResult(); return resp.getResult();

@ -12,14 +12,31 @@
*/ */
package tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc; package tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc;
import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition;
import tech.pegasys.pantheon.tests.acceptance.dsl.condition.ibft.ExpectProposals;
import tech.pegasys.pantheon.tests.acceptance.dsl.condition.ibft.ExpectValidators;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ibft.IbftTransactions;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import com.google.common.collect.ImmutableMap;
public class Ibft { public class Ibft {
private final IbftTransactions ibft;
public Ibft(final IbftTransactions ibft) {
this.ibft = ibft;
}
public List<PantheonNode> validators(final PantheonNode[] nodes) { public List<PantheonNode> validators(final PantheonNode[] nodes) {
final Comparator<PantheonNode> compareByAddress = final Comparator<PantheonNode> compareByAddress =
Comparator.comparing(PantheonNode::getAddress); Comparator.comparing(PantheonNode::getAddress);
@ -27,4 +44,49 @@ public class Ibft {
pantheonNodes.sort(compareByAddress); pantheonNodes.sort(compareByAddress);
return pantheonNodes; return pantheonNodes;
} }
public ExpectValidators validatorsEqual(final PantheonNode... validators) {
return new ExpectValidators(ibft, validatorAddresses(validators));
}
private Address[] validatorAddresses(final PantheonNode[] validators) {
return Arrays.stream(validators).map(PantheonNode::getAddress).sorted().toArray(Address[]::new);
}
public Condition noProposals() {
return new ExpectProposals(ibft, ImmutableMap.of());
}
public PendingVotesConfig pendingVotesEqual() {
return new PendingVotesConfig(ibft);
}
public static class PendingVotesConfig {
private final Map<PantheonNode, Boolean> proposals = new HashMap<>();
private final IbftTransactions ibft;
public PendingVotesConfig(final IbftTransactions ibft) {
this.ibft = ibft;
}
public PendingVotesConfig addProposal(final PantheonNode node) {
proposals.put(node, true);
return this;
}
public PendingVotesConfig removeProposal(final PantheonNode node) {
proposals.put(node, false);
return this;
}
public Condition build() {
final Map<Address, Boolean> proposalsAsAddress =
this.proposals
.entrySet()
.stream()
.collect(Collectors.toMap(p -> p.getKey().getAddress(), Entry::getValue));
return new tech.pegasys.pantheon.tests.acceptance.dsl.condition.ibft.ExpectProposals(
ibft, proposalsAsAddress);
}
}
} }

@ -25,7 +25,11 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;
import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration;
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.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.AdminJsonRpcRequestFactory;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.CliqueJsonRpcRequestFactory;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.IbftJsonRpcRequestFactory;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PermissioningJsonRpcRequestFactory;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import tech.pegasys.pantheon.tests.acceptance.dsl.waitcondition.WaitCondition; import tech.pegasys.pantheon.tests.acceptance.dsl.waitcondition.WaitCondition;
@ -50,6 +54,8 @@ import org.apache.logging.log4j.Logger;
import org.awaitility.Awaitility; import org.awaitility.Awaitility;
import org.awaitility.core.ConditionTimeoutException; import org.awaitility.core.ConditionTimeoutException;
import org.java_websocket.exceptions.WebsocketNotConnectedException; import org.java_websocket.exceptions.WebsocketNotConnectedException;
import org.web3j.protocol.Web3jService;
import org.web3j.protocol.core.JsonRpc2_0Web3j;
import org.web3j.protocol.http.HttpService; import org.web3j.protocol.http.HttpService;
import org.web3j.protocol.websocket.WebSocketClient; import org.web3j.protocol.websocket.WebSocketClient;
import org.web3j.protocol.websocket.WebSocketListener; import org.web3j.protocol.websocket.WebSocketListener;
@ -78,7 +84,7 @@ public class PantheonNode implements Node, NodeConfiguration, RunnableNode, Auto
private final boolean discoveryEnabled; private final boolean discoveryEnabled;
private List<String> bootnodes = new ArrayList<>(); private List<String> bootnodes = new ArrayList<>();
private PantheonWeb3j pantheonWeb3j; private JsonRequestFactories jsonRequestFactories;
private Optional<EthNetworkConfig> ethNetworkConfig = Optional.empty(); private Optional<EthNetworkConfig> ethNetworkConfig = Optional.empty();
public PantheonNode( public PantheonNode(
@ -163,19 +169,23 @@ public class PantheonNode implements Node, NodeConfiguration, RunnableNode, Auto
return LOCALHOST; return LOCALHOST;
} }
private PantheonWeb3j pantheonWeb3j() { private JsonRequestFactories jsonRequestFactories() {
if (jsonRequestFactories == null) {
if (pantheonWeb3j == null) { final Web3jService web3jService =
if (!jsonRpcBaseUrl().isPresent()) { jsonRpcBaseUrl()
return new PantheonWeb3j( .map(url -> new HttpService(url))
new HttpService("http://" + LOCALHOST + ":8545"), 2000, Async.defaultExecutorService()); .orElse(new HttpService("http://" + LOCALHOST + ":8545"));
}
jsonRequestFactories =
return new PantheonWeb3j( new JsonRequestFactories(
new HttpService(jsonRpcBaseUrl().get()), 2000, Async.defaultExecutorService()); new JsonRpc2_0Web3j(web3jService, 2000, Async.defaultExecutorService()),
new CliqueJsonRpcRequestFactory(web3jService),
new IbftJsonRpcRequestFactory(web3jService),
new PermissioningJsonRpcRequestFactory(web3jService),
new AdminJsonRpcRequestFactory(web3jService));
} }
return pantheonWeb3j; return jsonRequestFactories;
} }
/** All future JSON-RPC calls are made via a web sockets connection. */ /** All future JSON-RPC calls are made via a web sockets connection. */
@ -192,11 +202,9 @@ public class PantheonNode implements Node, NodeConfiguration, RunnableNode, Auto
throw new RuntimeException("Error connection to WebSocket endpoint", e); throw new RuntimeException("Error connection to WebSocket endpoint", e);
} }
if (pantheonWeb3j != null) { if (jsonRequestFactories != null) {
pantheonWeb3j.shutdown(); jsonRequestFactories.shutdown();
} }
pantheonWeb3j = new PantheonWeb3j(webSocketService, 2000, Async.defaultExecutorService());
} }
private void checkIfWebSocketEndpointIsAvailable(final String url) { private void checkIfWebSocketEndpointIsAvailable(final String url) {
@ -358,9 +366,9 @@ public class PantheonNode implements Node, NodeConfiguration, RunnableNode, Auto
@Override @Override
public void stop() { public void stop() {
if (pantheonWeb3j != null) { if (jsonRequestFactories != null) {
pantheonWeb3j.shutdown(); jsonRequestFactories.shutdown();
pantheonWeb3j = null; jsonRequestFactories = null;
} }
} }
@ -391,7 +399,7 @@ public class PantheonNode implements Node, NodeConfiguration, RunnableNode, Auto
@Override @Override
public <T> T execute(final Transaction<T> transaction) { public <T> T execute(final Transaction<T> transaction) {
return transaction.execute(pantheonWeb3j()); return transaction.execute(jsonRequestFactories());
} }
@Override @Override

@ -0,0 +1,38 @@
/*
* Copyright 2019 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;
import java.util.Collections;
import org.web3j.protocol.Web3jService;
import org.web3j.protocol.core.Request;
import org.web3j.protocol.core.Response;
public class AdminJsonRpcRequestFactory {
public static class AdminAddPeerResponse extends Response<Boolean> {}
private final Web3jService web3jService;
public AdminJsonRpcRequestFactory(final Web3jService web3jService) {
this.web3jService = web3jService;
}
public Request<?, AdminAddPeerResponse> adminAddPeer(final String enodeAddress) {
return new Request<>(
"admin_addPeer",
Collections.singletonList(enodeAddress),
web3jService,
AdminAddPeerResponse.class);
}
}

@ -0,0 +1,66 @@
/*
* Copyright 2019 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;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import tech.pegasys.pantheon.ethereum.core.Hash;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.DiscardResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.ProposalsResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.ProposeResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.SignersBlockResponse;
import java.util.Arrays;
import org.web3j.protocol.Web3jService;
import org.web3j.protocol.core.Request;
public class CliqueJsonRpcRequestFactory {
private final Web3jService web3jService;
public CliqueJsonRpcRequestFactory(final Web3jService web3jService) {
this.web3jService = web3jService;
}
public Request<?, ProposeResponse> cliquePropose(final String address, final Boolean auth) {
return new Request<>(
"clique_propose",
Arrays.asList(address, auth.toString()),
web3jService,
ProposeResponse.class);
}
public Request<?, DiscardResponse> cliqueDiscard(final String address) {
return new Request<>(
"clique_discard", singletonList(address), web3jService, DiscardResponse.class);
}
public Request<?, ProposalsResponse> cliqueProposals() {
return new Request<>("clique_proposals", emptyList(), web3jService, ProposalsResponse.class);
}
public Request<?, SignersBlockResponse> cliqueGetSigners(final String blockNumber) {
return new Request<>(
"clique_getSigners", singletonList(blockNumber), web3jService, SignersBlockResponse.class);
}
public Request<?, SignersBlockResponse> cliqueGetSignersAtHash(final Hash hash) {
return new Request<>(
"clique_getSignersAtHash",
singletonList(hash.toString()),
web3jService,
SignersBlockResponse.class);
}
}

@ -37,7 +37,7 @@ public class DeploySmartContractTransaction<T extends Contract> implements Trans
} }
@Override @Override
public T execute(final PantheonWeb3j node) { public T execute(final JsonRequestFactories node) {
try { try {
final Method method = final Method method =
clazz.getMethod( clazz.getMethod(
@ -45,7 +45,7 @@ public class DeploySmartContractTransaction<T extends Contract> implements Trans
final Object invoked = final Object invoked =
method.invoke( method.invoke(
METHOD_IS_STATIC, node, BENEFACTOR_ONE, DEFAULT_GAS_PRICE, DEFAULT_GAS_LIMIT); METHOD_IS_STATIC, node.eth(), BENEFACTOR_ONE, DEFAULT_GAS_PRICE, DEFAULT_GAS_LIMIT);
return cast(invoked).send(); return cast(invoked).send();
} catch (final Exception e) { } catch (final Exception e) {

@ -0,0 +1,70 @@
/*
* Copyright 2019 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;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import tech.pegasys.pantheon.ethereum.core.Hash;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.DiscardResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.ProposalsResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.ProposeResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.SignersBlockResponse;
import java.util.Arrays;
import org.web3j.protocol.Web3jService;
import org.web3j.protocol.core.Request;
public class IbftJsonRpcRequestFactory {
private final Web3jService web3jService;
public IbftJsonRpcRequestFactory(final Web3jService web3jService) {
this.web3jService = web3jService;
}
public Request<?, ProposeResponse> ibftPropose(final String address, final Boolean auth) {
return new Request<>(
"ibft_proposeValidatorVote",
Arrays.asList(address, auth.toString()),
web3jService,
ProposeResponse.class);
}
public Request<?, DiscardResponse> ibftDiscard(final String address) {
return new Request<>(
"ibft_discardValidatorVote", singletonList(address), web3jService, DiscardResponse.class);
}
public Request<?, ProposalsResponse> ibftProposals() {
return new Request<>(
"ibft_getPendingVotes", emptyList(), web3jService, ProposalsResponse.class);
}
public Request<?, SignersBlockResponse> ibftGetValidators(final String blockNumber) {
return new Request<>(
"ibft_getValidatorsByBlockNumber",
singletonList(blockNumber),
web3jService,
SignersBlockResponse.class);
}
public Request<?, SignersBlockResponse> ibftGetSignersAtHash(final Hash hash) {
return new Request<>(
"ibft_getValidatorsByBlockHash",
singletonList(hash.toString()),
web3jService,
SignersBlockResponse.class);
}
}

@ -0,0 +1,65 @@
/*
* Copyright 2019 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;
import org.web3j.protocol.core.JsonRpc2_0Web3j;
public class JsonRequestFactories {
private final JsonRpc2_0Web3j netEth;
private final CliqueJsonRpcRequestFactory clique;
private final IbftJsonRpcRequestFactory ibft;
private final PermissioningJsonRpcRequestFactory perm;
private final AdminJsonRpcRequestFactory admin;
public JsonRequestFactories(
final JsonRpc2_0Web3j netEth,
final CliqueJsonRpcRequestFactory clique,
final IbftJsonRpcRequestFactory ibft,
final PermissioningJsonRpcRequestFactory perm,
final AdminJsonRpcRequestFactory admin) {
this.netEth = netEth;
this.clique = clique;
this.ibft = ibft;
this.perm = perm;
this.admin = admin;
}
public JsonRpc2_0Web3j eth() {
return netEth;
}
public JsonRpc2_0Web3j net() {
return netEth;
}
public CliqueJsonRpcRequestFactory clique() {
return clique;
}
public IbftJsonRpcRequestFactory ibft() {
return ibft;
}
public PermissioningJsonRpcRequestFactory perm() {
return perm;
}
public AdminJsonRpcRequestFactory admin() {
return admin;
}
public void shutdown() {
netEth.shutdown();
}
}

@ -1,149 +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.transaction;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.ethereum.core.Hash;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import org.assertj.core.util.Lists;
import org.web3j.protocol.Web3jService;
import org.web3j.protocol.core.JsonRpc2_0Web3j;
import org.web3j.protocol.core.Request;
import org.web3j.protocol.core.Response;
public class PantheonWeb3j extends JsonRpc2_0Web3j {
public PantheonWeb3j(final Web3jService web3jService) {
super(web3jService);
}
public PantheonWeb3j(
final Web3jService web3jService,
final long pollingInterval,
final ScheduledExecutorService scheduledExecutorService) {
super(web3jService, pollingInterval, scheduledExecutorService);
}
public Request<?, ProposeResponse> cliquePropose(final String address, final Boolean auth) {
return new Request<>(
"clique_propose",
Arrays.asList(address, auth.toString()),
web3jService,
ProposeResponse.class);
}
public Request<?, DiscardResponse> cliqueDiscard(final String address) {
return new Request<>(
"clique_discard", singletonList(address), web3jService, DiscardResponse.class);
}
public Request<?, ProposalsResponse> cliqueProposals() {
return new Request<>("clique_proposals", emptyList(), web3jService, ProposalsResponse.class);
}
public Request<?, SignersBlockResponse> cliqueGetSigners(final String blockNumber) {
return new Request<>(
"clique_getSigners", singletonList(blockNumber), web3jService, SignersBlockResponse.class);
}
public Request<?, SignersBlockResponse> cliqueGetSignersAtHash(final Hash hash) {
return new Request<>(
"clique_getSignersAtHash",
singletonList(hash.toString()),
web3jService,
SignersBlockResponse.class);
}
public static class ProposeResponse extends Response<Boolean> {}
public static class DiscardResponse extends Response<Boolean> {}
public static class SignersBlockResponse extends Response<List<Address>> {}
public static class ProposalsResponse extends Response<Map<Address, Boolean>> {}
public Request<?, AddAccountsToWhitelistResponse> addAccountsToWhitelist(
final List<String> accounts) {
return new Request<>(
"perm_addAccountsToWhitelist",
Collections.singletonList(accounts),
web3jService,
AddAccountsToWhitelistResponse.class);
}
public Request<?, RemoveAccountsFromWhitelistResponse> removeAccountsFromWhitelist(
final List<String> accounts) {
return new Request<>(
"perm_removeAccountsFromWhitelist",
Collections.singletonList(accounts),
web3jService,
RemoveAccountsFromWhitelistResponse.class);
}
public Request<?, GetAccountsWhitelistResponse> getAccountsWhitelist() {
return new Request<>(
"perm_getAccountsWhitelist", null, web3jService, GetAccountsWhitelistResponse.class);
}
public static class AddAccountsToWhitelistResponse extends Response<Boolean> {}
public static class RemoveAccountsFromWhitelistResponse extends Response<Boolean> {}
public static class GetAccountsWhitelistResponse extends Response<List<String>> {}
public Request<?, AddNodeResponse> addNodesToWhitelist(final List<String> enodeList) {
return new Request<>(
"perm_addNodesToWhitelist",
Collections.singletonList(enodeList),
web3jService,
AddNodeResponse.class);
}
public Request<?, RemoveNodeResponse> removeNodesFromWhitelist(final List<String> enodeList) {
return new Request<>(
"perm_removeNodesFromWhitelist",
Collections.singletonList(enodeList),
web3jService,
RemoveNodeResponse.class);
}
public Request<?, GetNodesWhitelistResponse> getNodesWhitelist() {
return new Request<>(
"perm_getNodesWhitelist", Lists.emptyList(), web3jService, GetNodesWhitelistResponse.class);
}
public static class AddNodeResponse extends Response<Boolean> {}
public static class RemoveNodeResponse extends Response<Boolean> {}
public static class GetNodesWhitelistResponse extends Response<List<String>> {}
public static class AdminAddPeerResponse extends Response<Boolean> {}
public Request<?, AdminAddPeerResponse> adminAddPeer(final String enodeAddress) {
return new Request<>(
"admin_addPeer",
Collections.singletonList(enodeAddress),
web3jService,
AdminAddPeerResponse.class);
}
}

@ -0,0 +1,79 @@
/*
* Copyright 2019 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;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.AddAccountsToWhitelistResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.AddNodeResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.GetAccountsWhitelistResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.GetNodesWhitelistResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.RemoveAccountsFromWhitelistResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.RemoveNodeResponse;
import java.util.Collections;
import java.util.List;
import org.assertj.core.util.Lists;
import org.web3j.protocol.Web3jService;
import org.web3j.protocol.core.Request;
public class PermissioningJsonRpcRequestFactory {
private final Web3jService web3jService;
public PermissioningJsonRpcRequestFactory(final Web3jService web3jService) {
this.web3jService = web3jService;
}
public Request<?, AddNodeResponse> addNodesToWhitelist(final List<String> enodeList) {
return new Request<>(
"perm_addNodesToWhitelist",
Collections.singletonList(enodeList),
web3jService,
AddNodeResponse.class);
}
public Request<?, RemoveNodeResponse> removeNodesFromWhitelist(final List<String> enodeList) {
return new Request<>(
"perm_removeNodesFromWhitelist",
Collections.singletonList(enodeList),
web3jService,
RemoveNodeResponse.class);
}
public Request<?, GetNodesWhitelistResponse> getNodesWhitelist() {
return new Request<>(
"perm_getNodesWhitelist", Lists.emptyList(), web3jService, GetNodesWhitelistResponse.class);
}
public Request<?, GetAccountsWhitelistResponse> getAccountsWhitelist() {
return new Request<>(
"perm_getAccountsWhitelist", null, web3jService, GetAccountsWhitelistResponse.class);
}
public Request<?, AddAccountsToWhitelistResponse> addAccountsToWhitelist(
final List<String> accounts) {
return new Request<>(
"perm_addAccountsToWhitelist",
Collections.singletonList(accounts),
web3jService,
AddAccountsToWhitelistResponse.class);
}
public Request<?, RemoveAccountsFromWhitelistResponse> removeAccountsFromWhitelist(
final List<String> accounts) {
return new Request<>(
"perm_removeAccountsFromWhitelist",
Collections.singletonList(accounts),
web3jService,
RemoveAccountsFromWhitelistResponse.class);
}
}

@ -0,0 +1,42 @@
/*
* Copyright 2019 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;
import tech.pegasys.pantheon.ethereum.core.Address;
import java.util.List;
import java.util.Map;
import org.web3j.protocol.core.Response;
public class ResponseTypes {
public static class ProposeResponse extends Response<Boolean> {}
public static class DiscardResponse extends Response<Boolean> {}
public static class SignersBlockResponse extends Response<List<Address>> {}
public static class ProposalsResponse extends Response<Map<Address, Boolean>> {}
public static class AddAccountsToWhitelistResponse extends Response<Boolean> {}
public static class RemoveAccountsFromWhitelistResponse extends Response<Boolean> {}
public static class GetAccountsWhitelistResponse extends Response<List<String>> {}
public static class AddNodeResponse extends Response<Boolean> {}
public static class RemoveNodeResponse extends Response<Boolean> {}
public static class GetNodesWhitelistResponse extends Response<List<String>> {}
}

@ -15,5 +15,5 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction;
@FunctionalInterface @FunctionalInterface
public interface Transaction<T> { public interface Transaction<T> {
T execute(final PantheonWeb3j node); T execute(final JsonRequestFactories node);
} }

@ -16,7 +16,7 @@ import static org.web3j.utils.Numeric.toHexString;
import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.ethereum.core.Hash;
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.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -62,11 +62,11 @@ public class TransferTransaction implements Transaction<Hash> {
} }
@Override @Override
public Hash execute(final PantheonWeb3j node) { public Hash execute(final JsonRequestFactories node) {
final String signedTransactionData = signedTransactionData(); final String signedTransactionData = signedTransactionData();
try { try {
return Hash.fromHexString( return Hash.fromHexString(
node.ethSendRawTransaction(signedTransactionData).send().getTransactionHash()); node.eth().ethSendRawTransaction(signedTransactionData).send().getTransactionHash());
} catch (final IOException e) { } catch (final IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

@ -13,7 +13,7 @@
package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.account; package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.account;
import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.ethereum.core.Hash;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.util.ArrayList; import java.util.ArrayList;
@ -28,7 +28,7 @@ public class TransferTransactionSet implements Transaction<List<Hash>> {
} }
@Override @Override
public List<Hash> execute(final PantheonWeb3j node) { public List<Hash> execute(final JsonRequestFactories node) {
final List<Hash> hashes = new ArrayList<>(); final List<Hash> hashes = new ArrayList<>();
for (final TransferTransaction transaction : transactions) { for (final TransferTransaction transaction : transactions) {

@ -14,12 +14,13 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.clique;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j.DiscardResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
import org.web3j.protocol.core.Response;
public class CliqueDiscard implements Transaction<Boolean> { public class CliqueDiscard implements Transaction<Boolean> {
private final String address; private final String address;
@ -28,9 +29,9 @@ public class CliqueDiscard implements Transaction<Boolean> {
} }
@Override @Override
public Boolean execute(final PantheonWeb3j node) { public Boolean execute(final JsonRequestFactories node) {
try { try {
final DiscardResponse result = node.cliqueDiscard(address).send(); final Response<Boolean> result = node.clique().cliqueDiscard(address).send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse(); assertThat(result.hasError()).isFalse();
return result.getResult(); return result.getResult();

@ -15,8 +15,8 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.clique;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j.SignersBlockResponse; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.SignersBlockResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -30,9 +30,9 @@ public class CliqueGetSigners implements Transaction<List<Address>> {
} }
@Override @Override
public List<Address> execute(final PantheonWeb3j node) { public List<Address> execute(final JsonRequestFactories node) {
try { try {
final SignersBlockResponse result = node.cliqueGetSigners(blockNumber).send(); final SignersBlockResponse result = node.clique().cliqueGetSigners(blockNumber).send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse(); assertThat(result.hasError()).isFalse();
return result.getResult(); return result.getResult();

@ -16,8 +16,8 @@ import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.ethereum.core.Hash;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j.SignersBlockResponse; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.SignersBlockResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -31,9 +31,9 @@ public class CliqueGetSignersAtHash implements Transaction<List<Address>> {
} }
@Override @Override
public List<Address> execute(final PantheonWeb3j node) { public List<Address> execute(final JsonRequestFactories node) {
try { try {
final SignersBlockResponse result = node.cliqueGetSignersAtHash(hash).send(); final SignersBlockResponse result = node.clique().cliqueGetSignersAtHash(hash).send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse(); assertThat(result.hasError()).isFalse();
return result.getResult(); return result.getResult();

@ -15,8 +15,8 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.clique;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j.ProposalsResponse; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.ProposalsResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -25,9 +25,9 @@ import java.util.Map;
public class CliqueProposals implements Transaction<Map<Address, Boolean>> { public class CliqueProposals implements Transaction<Map<Address, Boolean>> {
@Override @Override
public Map<Address, Boolean> execute(final PantheonWeb3j node) { public Map<Address, Boolean> execute(final JsonRequestFactories node) {
try { try {
final ProposalsResponse result = node.cliqueProposals().send(); final ProposalsResponse result = node.clique().cliqueProposals().send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse(); assertThat(result.hasError()).isFalse();
return result.getResult(); return result.getResult();

@ -14,8 +14,8 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.clique;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j.ProposeResponse; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.ProposeResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -30,9 +30,9 @@ public class CliquePropose implements Transaction<Boolean> {
} }
@Override @Override
public Boolean execute(final PantheonWeb3j node) { public Boolean execute(final JsonRequestFactories node) {
try { try {
final ProposeResponse result = node.cliquePropose(address, auth).send(); final ProposeResponse result = node.clique().cliquePropose(address, auth).send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse(); assertThat(result.hasError()).isFalse();
return result.getResult(); return result.getResult();

@ -14,7 +14,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -27,9 +27,9 @@ public class EthAccountsTransaction implements Transaction<List<String>> {
EthAccountsTransaction() {} EthAccountsTransaction() {}
@Override @Override
public List<String> execute(final PantheonWeb3j node) { public List<String> execute(final JsonRequestFactories node) {
try { try {
final EthAccounts result = node.ethAccounts().send(); final EthAccounts result = node.eth().ethAccounts().send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
return result.getAccounts(); return result.getAccounts();
} catch (final IOException e) { } catch (final IOException e) {

@ -14,7 +14,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -25,10 +25,10 @@ public class EthBlockNumberTransaction implements Transaction<BigInteger> {
EthBlockNumberTransaction() {} EthBlockNumberTransaction() {}
@Override @Override
public BigInteger execute(final PantheonWeb3j node) { public BigInteger execute(final JsonRequestFactories node) {
try { try {
final org.web3j.protocol.core.methods.response.EthBlockNumber result = final org.web3j.protocol.core.methods.response.EthBlockNumber result =
node.ethBlockNumber().send(); node.eth().ethBlockNumber().send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse(); assertThat(result.hasError()).isFalse();
return result.getBlockNumber(); return result.getBlockNumber();

@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.web3j.protocol.core.DefaultBlockParameterName.LATEST; import static org.web3j.protocol.core.DefaultBlockParameterName.LATEST;
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.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -33,9 +33,9 @@ public class EthGetBalanceTransaction implements Transaction<BigInteger> {
} }
@Override @Override
public BigInteger execute(final PantheonWeb3j node) { public BigInteger execute(final JsonRequestFactories node) {
try { try {
final EthGetBalance result = node.ethGetBalance(account.getAddress(), LATEST).send(); final EthGetBalance result = node.eth().ethGetBalance(account.getAddress(), LATEST).send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse(); assertThat(result.hasError()).isFalse();

@ -14,7 +14,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -34,10 +34,10 @@ public class EthGetBlockTransaction implements Transaction<Block> {
} }
@Override @Override
public Block execute(final PantheonWeb3j node) { public Block execute(final JsonRequestFactories node) {
try { try {
final EthBlock result = final EthBlock result =
node.ethGetBlockByNumber(blockParameter, fullTransactionObjects).send(); node.eth().ethGetBlockByNumber(blockParameter, fullTransactionObjects).send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse(); assertThat(result.hasError()).isFalse();
return result.getBlock(); return result.getBlock();

@ -14,7 +14,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -32,10 +32,12 @@ public class EthGetTransactionCountTransaction implements Transaction<BigInteger
} }
@Override @Override
public BigInteger execute(final PantheonWeb3j node) { public BigInteger execute(final JsonRequestFactories node) {
try { try {
EthGetTransactionCount result = EthGetTransactionCount result =
node.ethGetTransactionCount(accountAddress, DefaultBlockParameterName.LATEST).send(); node.eth()
.ethGetTransactionCount(accountAddress, DefaultBlockParameterName.LATEST)
.send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
return result.getTransactionCount(); return result.getTransactionCount();
} catch (final IOException e) { } catch (final IOException e) {

@ -14,7 +14,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -33,9 +33,9 @@ public class EthGetTransactionReceiptTransaction
} }
@Override @Override
public Optional<TransactionReceipt> execute(final PantheonWeb3j node) { public Optional<TransactionReceipt> execute(final JsonRequestFactories node) {
try { try {
final EthGetTransactionReceipt result = node.ethGetTransactionReceipt(input).send(); final EthGetTransactionReceipt result = node.eth().ethGetTransactionReceipt(input).send();
assertThat(result.hasError()).isFalse(); assertThat(result.hasError()).isFalse();
return result.getTransactionReceipt(); return result.getTransactionReceipt();
} catch (final IOException e) { } catch (final IOException e) {

@ -14,7 +14,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -26,9 +26,9 @@ public class EthGetWorkTransaction implements Transaction<String[]> {
EthGetWorkTransaction() {} EthGetWorkTransaction() {}
@Override @Override
public String[] execute(final PantheonWeb3j node) { public String[] execute(final JsonRequestFactories node) {
try { try {
final EthGetWork result = node.ethGetWork().send(); final EthGetWork result = node.eth().ethGetWork().send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
return new String[] { return new String[] {
result.getCurrentBlockHeaderPowHash(), result.getCurrentBlockHeaderPowHash(),

@ -14,7 +14,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -30,9 +30,9 @@ public class EthSendRawTransactionTransaction implements Transaction<String> {
} }
@Override @Override
public String execute(final PantheonWeb3j node) { public String execute(final JsonRequestFactories node) {
try { try {
EthSendTransaction response = node.ethSendRawTransaction(transactionData).send(); EthSendTransaction response = node.eth().ethSendRawTransaction(transactionData).send();
assertThat(response.getTransactionHash()).isNotNull(); assertThat(response.getTransactionHash()).isNotNull();
return response.getTransactionHash(); return response.getTransactionHash();
} catch (final IOException e) { } catch (final IOException e) {

@ -0,0 +1,41 @@
/*
* 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.ibft;
import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.DiscardResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException;
public class IbftDiscard implements Transaction<Boolean> {
private final String address;
public IbftDiscard(final String address) {
this.address = address;
}
@Override
public Boolean execute(final JsonRequestFactories node) {
try {
final DiscardResponse result = node.ibft().ibftDiscard(address).send();
assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse();
return result.getResult();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}

@ -0,0 +1,43 @@
/*
* 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.ibft;
import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.SignersBlockResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException;
import java.util.List;
public class IbftGetValidators implements Transaction<List<Address>> {
private final String blockNumber;
public IbftGetValidators(final String blockNumber) {
this.blockNumber = blockNumber;
}
@Override
public List<Address> execute(final JsonRequestFactories node) {
try {
final SignersBlockResponse result = node.ibft().ibftGetValidators(blockNumber).send();
assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse();
return result.getResult();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}

@ -0,0 +1,44 @@
/*
* 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.ibft;
import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.ethereum.core.Hash;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.SignersBlockResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException;
import java.util.List;
public class IbftGetValidatorsAtHash implements Transaction<List<Address>> {
private final Hash hash;
public IbftGetValidatorsAtHash(final Hash hash) {
this.hash = hash;
}
@Override
public List<Address> execute(final JsonRequestFactories node) {
try {
final SignersBlockResponse result = node.ibft().ibftGetSignersAtHash(hash).send();
assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse();
return result.getResult();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}

@ -0,0 +1,38 @@
/*
* 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.ibft;
import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.ProposalsResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException;
import java.util.Map;
public class IbftProposals implements Transaction<Map<Address, Boolean>> {
@Override
public Map<Address, Boolean> execute(final JsonRequestFactories node) {
try {
final ProposalsResponse result = node.ibft().ibftProposals().send();
assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse();
return result.getResult();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}

@ -0,0 +1,43 @@
/*
* 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.ibft;
import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.ProposeResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException;
public class IbftPropose implements Transaction<Boolean> {
private final String address;
private final boolean auth;
public IbftPropose(final String address, final boolean auth) {
this.address = address;
this.auth = auth;
}
@Override
public Boolean execute(final JsonRequestFactories node) {
try {
final ProposeResponse result = node.ibft().ibftPropose(address, auth).send();
assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse();
return result.getResult();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}

@ -0,0 +1,48 @@
/*
* 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.ibft;
import tech.pegasys.pantheon.ethereum.core.Hash;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode;
public class IbftTransactions {
public static final String LATEST = "latest";
public IbftPropose createRemoveProposal(final PantheonNode node) {
return propose(node.getAddress().toString(), false);
}
public IbftPropose createAddProposal(final PantheonNode node) {
return propose(node.getAddress().toString(), true);
}
private IbftPropose propose(final String address, final boolean auth) {
return new IbftPropose(address, auth);
}
public IbftProposals createProposals() {
return new IbftProposals();
}
public IbftGetValidators createGetValidators(final String blockNumber) {
return new IbftGetValidators(blockNumber);
}
public IbftGetValidatorsAtHash createGetValidatorsAtHash(final Hash blockHash) {
return new IbftGetValidatorsAtHash(blockHash);
}
public IbftDiscard createDiscardProposal(final PantheonNode node) {
return new IbftDiscard(node.getAddress().toString());
}
}

@ -14,7 +14,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -27,9 +27,9 @@ public class NetPeerCountTransaction implements Transaction<BigInteger> {
NetPeerCountTransaction() {} NetPeerCountTransaction() {}
@Override @Override
public BigInteger execute(final PantheonWeb3j node) { public BigInteger execute(final JsonRequestFactories node) {
try { try {
final NetPeerCount result = node.netPeerCount().send(); final NetPeerCount result = node.net().netPeerCount().send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse(); assertThat(result.hasError()).isFalse();
return result.getQuantity(); return result.getQuantity();

@ -14,7 +14,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -26,9 +26,9 @@ public class NetVersionTransaction implements Transaction<String> {
NetVersionTransaction() {} NetVersionTransaction() {}
@Override @Override
public String execute(final PantheonWeb3j node) { public String execute(final JsonRequestFactories node) {
try { try {
final NetVersion result = node.netVersion().send(); final NetVersion result = node.net().netVersion().send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse(); assertThat(result.hasError()).isFalse();
return result.getNetVersion(); return result.getNetVersion();

@ -14,8 +14,8 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j.AddAccountsToWhitelistResponse; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.AddAccountsToWhitelistResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -30,9 +30,9 @@ public class PermAddAccountsToWhitelistTransaction implements Transaction<Boolea
} }
@Override @Override
public Boolean execute(final PantheonWeb3j node) { public Boolean execute(final JsonRequestFactories node) {
try { try {
AddAccountsToWhitelistResponse response = node.addAccountsToWhitelist(accounts).send(); AddAccountsToWhitelistResponse response = node.perm().addAccountsToWhitelist(accounts).send();
assertThat(response.getResult()).isTrue(); assertThat(response.getResult()).isTrue();
return response.getResult(); return response.getResult();
} catch (IOException e) { } catch (IOException e) {

@ -13,9 +13,9 @@
package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm; package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j.AddNodeResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.AddNodeResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -29,9 +29,9 @@ public class PermAddNodeTransaction implements Transaction<Boolean> {
} }
@Override @Override
public Boolean execute(final PantheonWeb3j node) { public Boolean execute(final JsonRequestFactories node) {
try { try {
final AddNodeResponse result = node.addNodesToWhitelist(enodeList).send(); final AddNodeResponse result = node.perm().addNodesToWhitelist(enodeList).send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
return result.getResult(); return result.getResult();
} catch (final IOException e) { } catch (final IOException e) {

@ -14,8 +14,8 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j.GetAccountsWhitelistResponse; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.GetAccountsWhitelistResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -24,9 +24,9 @@ import java.util.List;
public class PermGetAccountsWhitelistTransaction implements Transaction<List<String>> { public class PermGetAccountsWhitelistTransaction implements Transaction<List<String>> {
@Override @Override
public List<String> execute(final PantheonWeb3j node) { public List<String> execute(final JsonRequestFactories node) {
try { try {
GetAccountsWhitelistResponse response = node.getAccountsWhitelist().send(); GetAccountsWhitelistResponse response = node.perm().getAccountsWhitelist().send();
assertThat(response.getResult()).isNotNull(); assertThat(response.getResult()).isNotNull();
return response.getResult(); return response.getResult();
} catch (IOException e) { } catch (IOException e) {

@ -14,8 +14,8 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j.GetNodesWhitelistResponse; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.GetNodesWhitelistResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -23,9 +23,9 @@ import java.util.List;
public class PermGetNodesWhitelistTransaction implements Transaction<List<String>> { public class PermGetNodesWhitelistTransaction implements Transaction<List<String>> {
@Override @Override
public List<String> execute(final PantheonWeb3j node) { public List<String> execute(final JsonRequestFactories node) {
try { try {
GetNodesWhitelistResponse result = node.getNodesWhitelist().send(); GetNodesWhitelistResponse result = node.perm().getNodesWhitelist().send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
return result.getResult(); return result.getResult();
} catch (final IOException e) { } catch (final IOException e) {

@ -14,8 +14,8 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j.RemoveAccountsFromWhitelistResponse; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.RemoveAccountsFromWhitelistResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -30,10 +30,10 @@ public class PermRemoveAccountsFromWhitelistTransaction implements Transaction<B
} }
@Override @Override
public Boolean execute(final PantheonWeb3j node) { public Boolean execute(final JsonRequestFactories node) {
try { try {
RemoveAccountsFromWhitelistResponse response = RemoveAccountsFromWhitelistResponse response =
node.removeAccountsFromWhitelist(accounts).send(); node.perm().removeAccountsFromWhitelist(accounts).send();
assertThat(response.getResult()).isTrue(); assertThat(response.getResult()).isTrue();
return response.getResult(); return response.getResult();
} catch (IOException e) { } catch (IOException e) {

@ -14,8 +14,8 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j.RemoveNodeResponse; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes.RemoveNodeResponse;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -29,9 +29,9 @@ public class PermRemoveNodeTransaction implements Transaction<Boolean> {
} }
@Override @Override
public Boolean execute(final PantheonWeb3j node) { public Boolean execute(final JsonRequestFactories node) {
try { try {
final RemoveNodeResponse result = node.removeNodesFromWhitelist(enodeList).send(); final RemoveNodeResponse result = node.perm().removeNodesFromWhitelist(enodeList).send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
return result.getResult(); return result.getResult();
} catch (final IOException e) { } catch (final IOException e) {

@ -14,7 +14,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.web3;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.PantheonWeb3j; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.IOException; import java.io.IOException;
@ -30,9 +30,9 @@ public class Web3Sha3Transaction implements Transaction<String> {
} }
@Override @Override
public String execute(final PantheonWeb3j node) { public String execute(final JsonRequestFactories node) {
try { try {
final Web3Sha3 result = node.web3Sha3(input).send(); final Web3Sha3 result = node.net().web3Sha3(input).send();
assertThat(result).isNotNull(); assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse(); assertThat(result.hasError()).isFalse();
return result.getResult(); return result.getResult();

@ -19,16 +19,20 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.clique.CliqueTransactions; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.clique.CliqueTransactions;
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.ibft.IbftTransactions;
import java.math.BigInteger; import java.math.BigInteger;
public class WaitConditions { public class WaitConditions {
private final EthTransactions eth; private final EthTransactions eth;
private final CliqueTransactions clique; private final CliqueTransactions clique;
private final IbftTransactions ibft;
public WaitConditions(final EthTransactions eth, final CliqueTransactions clique) { public WaitConditions(
final EthTransactions eth, final CliqueTransactions clique, final IbftTransactions ibft) {
this.eth = eth; this.eth = eth;
this.clique = clique; this.clique = clique;
this.ibft = ibft;
} }
public WaitCondition chainHeadHasProgressed( public WaitCondition chainHeadHasProgressed(
@ -42,6 +46,10 @@ public class WaitConditions {
return new WaitUntilSignersChanged(node.execute(clique.createGetSigners(LATEST)), clique); return new WaitUntilSignersChanged(node.execute(clique.createGetSigners(LATEST)), clique);
} }
public WaitCondition ibftValidatorsChanged(final Node node) {
return new WaitUntilValidatorsChanged(node.execute(ibft.createGetValidators(LATEST)), ibft);
}
public WaitCondition chainHeadIsAt(final long blockNumber) { public WaitCondition chainHeadIsAt(final long blockNumber) {
return new ExpectBlockNumber(eth, BigInteger.valueOf(blockNumber))::verify; return new ExpectBlockNumber(eth, BigInteger.valueOf(blockNumber))::verify;
} }

@ -0,0 +1,44 @@
/*
* 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.waitcondition;
import static org.assertj.core.api.Assertions.assertThat;
import static tech.pegasys.pantheon.tests.acceptance.dsl.WaitUtils.waitFor;
import static tech.pegasys.pantheon.tests.acceptance.dsl.transaction.clique.CliqueTransactions.LATEST;
import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ibft.IbftTransactions;
import java.util.List;
public class WaitUntilValidatorsChanged implements WaitCondition {
private final IbftTransactions ibft;
private final List<Address> initialSigners;
public WaitUntilValidatorsChanged(
final List<Address> initialSigners, final IbftTransactions ibft) {
this.initialSigners = initialSigners;
this.ibft = ibft;
}
@Override
public void waitUntil(final Node node) {
waitFor(
60,
() ->
assertThat(node.execute(ibft.createGetValidators(LATEST)))
.isNotEqualTo(initialSigners));
}
}

@ -0,0 +1,48 @@
/*
* Copyright 2019 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.ibft;
import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode;
import java.io.IOException;
import org.junit.Test;
public class IbftDiscardRpcAcceptanceTest extends AcceptanceTestBase {
@Test
public void shouldDiscardVotes() throws IOException {
final String[] validators = {"validator1", "validator2"};
final PantheonNode validator1 = pantheon.createIbftNodeWithValidators("validator1", validators);
final PantheonNode validator2 = pantheon.createIbftNodeWithValidators("validator2", validators);
final PantheonNode validator3 = pantheon.createIbftNodeWithValidators("validator3", validators);
cluster.start(validator1, validator2, validator3);
validator1.execute(ibftTransactions.createRemoveProposal(validator2));
validator1.execute(ibftTransactions.createAddProposal(validator3));
validator2.execute(ibftTransactions.createRemoveProposal(validator2));
validator2.execute(ibftTransactions.createAddProposal(validator3));
validator1.execute(ibftTransactions.createDiscardProposal(validator2));
validator1.execute(ibftTransactions.createDiscardProposal(validator3));
validator1.waitUntil(wait.chainHeadHasProgressed(validator1, 2));
cluster.verify(ibft.validatorsEqual(validator1, validator2));
validator1.verify(ibft.noProposals());
validator2.verify(
ibft.pendingVotesEqual().removeProposal(validator2).addProposal(validator3).build());
}
}

@ -0,0 +1,42 @@
/*
* 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.ibft;
import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode;
import java.io.IOException;
import org.junit.Test;
public class IbftProposalRpcAcceptanceTest extends AcceptanceTestBase {
@Test
public void shouldReturnProposals() throws IOException {
final String[] validators = {"validator1", "validator2", "validator3"};
final PantheonNode validator1 = pantheon.createIbftNodeWithValidators("validator1", validators);
final PantheonNode validator2 = pantheon.createIbftNodeWithValidators("validator2", validators);
final PantheonNode validator3 = pantheon.createIbftNodeWithValidators("validator3", validators);
cluster.start(validator1, validator2, validator3);
cluster.verify(ibft.noProposals());
validator1.execute(ibftTransactions.createAddProposal(validator3));
validator1.execute(ibftTransactions.createRemoveProposal(validator2));
validator2.execute(ibftTransactions.createRemoveProposal(validator3));
validator1.verify(
ibft.pendingVotesEqual().addProposal(validator3).removeProposal(validator2).build());
validator2.verify(ibft.pendingVotesEqual().removeProposal(validator3).build());
validator3.verify(ibft.noProposals());
}
}

@ -0,0 +1,52 @@
/*
* Copyright 2019 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.ibft;
import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode;
import tech.pegasys.pantheon.tests.acceptance.dsl.waitcondition.WaitCondition;
import java.io.IOException;
import org.junit.Test;
// These tests prove the ibft_proposeValidatorVote and ibft_getValidatorsByBlockNumber (implicitly)
// JSON RPC calls.
public class IbftProposeRpcAcceptanceTest extends AcceptanceTestBase {
@Test
public void validatorsCanBeAddedAndThenRemoved() throws IOException {
final String[] validators = {"validator1", "validator2", "validator3"};
final PantheonNode validator1 = pantheon.createIbftNodeWithValidators("validator1", validators);
final PantheonNode validator2 = pantheon.createIbftNodeWithValidators("validator2", validators);
final PantheonNode validator3 = pantheon.createIbftNodeWithValidators("validator3", validators);
final PantheonNode nonValidatorNode =
pantheon.createIbftNodeWithValidators("non-validator", validators);
cluster.start(validator1, validator2, validator3, nonValidatorNode);
cluster.verify(ibft.validatorsEqual(validator1, validator2, validator3));
final WaitCondition addedCondition = wait.ibftValidatorsChanged(validator1);
validator1.execute(ibftTransactions.createAddProposal(nonValidatorNode));
validator2.execute(ibftTransactions.createAddProposal(nonValidatorNode));
cluster.waitUntil(addedCondition);
cluster.verify(ibft.validatorsEqual(validator1, validator2, validator3, nonValidatorNode));
final WaitCondition removedCondition = wait.ibftValidatorsChanged(validator1);
validator2.execute(ibftTransactions.createRemoveProposal(nonValidatorNode));
validator3.execute(ibftTransactions.createRemoveProposal(nonValidatorNode));
nonValidatorNode.execute(ibftTransactions.createRemoveProposal(nonValidatorNode));
cluster.waitUntil(removedCondition);
cluster.verify(ibft.validatorsEqual(validator1, validator2, validator3));
}
}
Loading…
Cancel
Save