diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/net/ExpectNetServicesValidPort.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/net/ExpectNetServicesValidPort.java new file mode 100644 index 0000000000..9827929a8f --- /dev/null +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/net/ExpectNetServicesValidPort.java @@ -0,0 +1,25 @@ +package tech.pegasys.pantheon.tests.acceptance.dsl.condition.net; + +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.NetServicesTransaction; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.NetVersionTransaction; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ExpectNetServicesValidPort implements Condition { + + private final NetServicesTransaction transaction; + + public ExpectNetServicesValidPort(final NetServicesTransaction transaction) { + this.transaction = transaction; + } + + @Override + public void verify(Node node) { + + final Boolean result = node.execute(); + + assertThat(result).isTrue(); + } +} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Net.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Net.java index 0b8ba3226c..9aaab52746 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Net.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Net.java @@ -32,6 +32,11 @@ public Net(final NetTransactions transactions) { this.transactions = transactions; } + public Condition netServices() { + + return transactions.netServices(); + } + public Condition netVersion() { return new ExpectNetVersionIsNotBlank(transactions.netVersion()); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetServicesTransaction.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetServicesTransaction.java new file mode 100644 index 0000000000..16919c96e1 --- /dev/null +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetServicesTransaction.java @@ -0,0 +1,28 @@ +package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net; + +import org.web3j.protocol.core.Request; +import org.web3j.protocol.core.methods.response.NetVersion; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.NetServicesJsonRpcRequestFactory; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; + +import java.util.Map; + +public class NetServicesTransaction implements Transaction>> { + + NetServicesTransaction() {} + + @Override + public Map> execute( + final JsonRequestFactories requestFactories) { + NetServicesJsonRpcRequestFactory.NetServicesResponse netServicesResponse = null; + try { + NetServicesJsonRpcRequestFactory netServicesJsonRpcRequestFactory = requestFactories.netServices(); + Request request = + netServicesJsonRpcRequestFactory.netServices(); + netServicesResponse = request.send(); + } catch (final Exception ignored) { + } + return netServicesResponse.getResult(); + } +} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetTransactions.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetTransactions.java index 1b059bf5c3..7bf87b4170 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetTransactions.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/net/NetTransactions.java @@ -18,7 +18,11 @@ public NetVersionTransaction netVersion() { return new NetVersionTransaction(); } + public NetServicesTransaction netServices() { + return new NetServicesTransaction(); + } public NetPeerCountTransaction peerCount() { return new NetPeerCountTransaction(); } + }