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

Commit

Permalink
Merge branch 'master' into use-txpool-prefix-and-group
Browse files Browse the repository at this point in the history
  • Loading branch information
rojotek authored Mar 15, 2019
2 parents 8b27d60 + b5d025c commit a8d54e7
Show file tree
Hide file tree
Showing 152 changed files with 4,837 additions and 1,896 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.eea;

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

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.ResponseTypes;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eea.EeaGetTransactionReceiptTransaction;

public class ExpectSuccessfulEeaGetTransactionReceipt implements Condition {

private final EeaGetTransactionReceiptTransaction transaction;

public ExpectSuccessfulEeaGetTransactionReceipt(
final EeaGetTransactionReceiptTransaction transaction) {
this.transaction = transaction;
}

@Override
public void verify(final Node node) {
final ResponseTypes.PrivateTransactionReceipt response = node.execute(transaction);
assertThat(response.getContractAddress()).isNotEqualTo("0x");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.jsonrpc;

import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition;
import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eea.ExpectSuccessfulEeaGetTransactionReceipt;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eea.EeaTransactions;

public class Eea {

EeaTransactions transactions;

public Eea(final EeaTransactions transactions) {
this.transactions = transactions;
}

public Condition expectSuccessfulTransactionReceipt(
final String transactionHash, final String publicKey) {
return new ExpectSuccessfulEeaGetTransactionReceipt(
transactions.getTransactionReceipt(transactionHash, publicKey));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import tech.pegasys.pantheon.ethereum.core.Util;
import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration;
import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.permissioning.LocalPermissioningConfiguration;
import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration;
import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition;
import tech.pegasys.pantheon.tests.acceptance.dsl.httptransaction.HttpRequestFactory;
Expand Down Expand Up @@ -83,7 +83,7 @@ public class PantheonNode implements NodeConfiguration, RunnableNode, AutoClosea
private final JsonRpcConfiguration jsonRpcConfiguration;
private final WebSocketConfiguration webSocketConfiguration;
private final MetricsConfiguration metricsConfiguration;
private final Optional<PermissioningConfiguration> permissioningConfiguration;
private final Optional<LocalPermissioningConfiguration> permissioningConfiguration;
private final GenesisConfigProvider genesisConfigProvider;
private final boolean devMode;
private final boolean discoveryEnabled;
Expand All @@ -103,7 +103,7 @@ public PantheonNode(
final JsonRpcConfiguration jsonRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration,
final MetricsConfiguration metricsConfiguration,
final Optional<PermissioningConfiguration> permissioningConfiguration,
final Optional<LocalPermissioningConfiguration> permissioningConfiguration,
final boolean devMode,
final GenesisConfigProvider genesisConfigProvider,
final boolean p2pEnabled,
Expand Down Expand Up @@ -472,7 +472,7 @@ public boolean isDiscoveryEnabled() {
return discoveryEnabled;
}

Optional<PermissioningConfiguration> getPermissioningConfiguration() {
Optional<LocalPermissioningConfiguration> getPermissioningConfiguration() {
return permissioningConfiguration;
}

Expand All @@ -484,6 +484,7 @@ public String toString() {
.add("keyPair", keyPair)
.add("p2pEnabled", p2pEnabled)
.add("discoveryEnabled", discoveryEnabled)
.add("privacyEnabled", privacyParameters.isEnabled())
.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration;
import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.permissioning.LocalPermissioningConfiguration;
import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.GenesisConfigProvider;

Expand All @@ -30,7 +30,7 @@ class PantheonFactoryConfiguration {
private final JsonRpcConfiguration jsonRpcConfiguration;
private final WebSocketConfiguration webSocketConfiguration;
private final MetricsConfiguration metricsConfiguration;
private final Optional<PermissioningConfiguration> permissioningConfiguration;
private final Optional<LocalPermissioningConfiguration> permissioningConfiguration;
private final boolean devMode;
private final GenesisConfigProvider genesisConfigProvider;
private final boolean p2pEnabled;
Expand All @@ -44,7 +44,7 @@ class PantheonFactoryConfiguration {
final JsonRpcConfiguration jsonRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration,
final MetricsConfiguration metricsConfiguration,
final Optional<PermissioningConfiguration> permissioningConfiguration,
final Optional<LocalPermissioningConfiguration> permissioningConfiguration,
final boolean devMode,
final GenesisConfigProvider genesisConfigProvider,
final boolean p2pEnabled,
Expand Down Expand Up @@ -88,7 +88,7 @@ public MetricsConfiguration getMetricsConfiguration() {
return metricsConfiguration;
}

public Optional<PermissioningConfiguration> getPermissioningConfiguration() {
public Optional<LocalPermissioningConfiguration> getPermissioningConfiguration() {
return permissioningConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration;
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApis;
import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.permissioning.LocalPermissioningConfiguration;
import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.GenesisConfigProvider;

Expand All @@ -38,7 +38,7 @@ public class PantheonFactoryConfigurationBuilder {
private JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault();
private WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault();
private MetricsConfiguration metricsConfiguration = MetricsConfiguration.createDefault();
private Optional<PermissioningConfiguration> permissioningConfiguration = Optional.empty();
private Optional<LocalPermissioningConfiguration> permissioningConfiguration = Optional.empty();
private boolean devMode = true;
private GenesisConfigProvider genesisConfigProvider = ignore -> Optional.empty();
private Boolean p2pEnabled = true;
Expand Down Expand Up @@ -137,7 +137,7 @@ public PantheonFactoryConfigurationBuilder webSocketAuthenticationEnabled()
}

public PantheonFactoryConfigurationBuilder setPermissioningConfiguration(
final PermissioningConfiguration permissioningConfiguration) {
final LocalPermissioningConfiguration permissioningConfiguration) {
this.permissioningConfiguration = Optional.of(permissioningConfiguration);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApi;
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApis;
import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration;
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.permissioning.LocalPermissioningConfiguration;
import tech.pegasys.pantheon.ethereum.permissioning.WhitelistPersistor;
import tech.pegasys.pantheon.ethereum.permissioning.WhitelistPersistor.WHITELIST_TYPE;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.GenesisConfigProvider;
Expand Down Expand Up @@ -183,8 +183,8 @@ public PantheonNode createNodeWithWhitelistsEnabled(
final List<String> accountsWhitelist,
final String tempFilePath)
throws IOException {
final PermissioningConfiguration permissioningConfiguration =
PermissioningConfiguration.createDefault();
final LocalPermissioningConfiguration permissioningConfiguration =
LocalPermissioningConfiguration.createDefault();
permissioningConfiguration.setNodeWhitelist(nodesWhitelist);
permissioningConfiguration.setAccountWhitelist(accountsWhitelist);
permissioningConfiguration.setConfigurationFilePath(tempFilePath);
Expand All @@ -204,8 +204,8 @@ public PantheonNode createNodeWithNodesWhitelist(

public PantheonNode createNodeWithNodesWhitelist(
final String name, final List<URI> nodesWhitelist) throws IOException {
final PermissioningConfiguration permissioningConfiguration =
PermissioningConfiguration.createDefault();
final LocalPermissioningConfiguration permissioningConfiguration =
LocalPermissioningConfiguration.createDefault();
permissioningConfiguration.setNodeWhitelist(nodesWhitelist);

final List<String> whitelistAsStrings =
Expand Down Expand Up @@ -241,8 +241,8 @@ private void initPermissioningConfigurationFile(

public PantheonNode createNodeWithAccountsWhitelist(
final String name, final List<String> accountsWhitelist) throws IOException {
final PermissioningConfiguration permissioningConfiguration =
PermissioningConfiguration.createDefault();
final LocalPermissioningConfiguration permissioningConfiguration =
LocalPermissioningConfiguration.createDefault();
permissioningConfiguration.setAccountWhitelist(accountsWhitelist);
permissioningConfiguration.setConfigurationFilePath(
createTempPermissioningConfigurationFile().getPath());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.privacy;

import static org.junit.Assert.assertEquals;

import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Eea;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transactions;

public class ExpectValidPrivateContractDeployedReceipt
extends ExpectValidPrivateTransactionReceipt {

private final String contractAddress;

public ExpectValidPrivateContractDeployedReceipt(
final String contractAddress, final Eea eea, final Transactions transactions) {
super(eea, transactions);
this.contractAddress = contractAddress;
}

public void verify(
final PantheonNode node, final String transactionHash, final String publicKey) {
ResponseTypes.PrivateTransactionReceipt privateTxReceipt =
getPrivateTransactionReceipt(node, transactionHash, publicKey);

assertEquals(contractAddress, privateTxReceipt.getContractAddress());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.privacy;

import static org.junit.Assert.assertEquals;

import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Eea;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transactions;

import java.math.BigInteger;

import org.web3j.utils.Numeric;

public class ExpectValidPrivateContractEventsEmitted extends ExpectValidPrivateTransactionReceipt {
private final String eventValue;

public ExpectValidPrivateContractEventsEmitted(
final String eventValue, final Eea eea, final Transactions transactions) {
super(eea, transactions);
this.eventValue = eventValue;
}

public void verify(
final PantheonNode node, final String transactionHash, final String PUBLIC_KEY) {
ResponseTypes.PrivateTransactionReceipt privateTxReceipt =
getPrivateTransactionReceipt(node, transactionHash, PUBLIC_KEY);

String event = privateTxReceipt.getLogs().get(0).getData().substring(66, 130);
assertEquals(
Numeric.decodeQuantity(Numeric.prependHexPrefix(event)), new BigInteger(eventValue));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.privacy;

import static org.junit.Assert.assertEquals;

import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Eea;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transactions;
import tech.pegasys.pantheon.util.bytes.BytesValue;

import java.math.BigInteger;

import org.web3j.utils.Numeric;

public class ExpectValidPrivateContractValuesReturned extends ExpectValidPrivateTransactionReceipt {
private final String returnValue;

public ExpectValidPrivateContractValuesReturned(
final String returnValue, final Eea eea, final Transactions transactions) {
super(eea, transactions);
this.returnValue = returnValue;
}

public void verify(
final PantheonNode node, final String transactionHash, final String PUBLIC_KEY) {
ResponseTypes.PrivateTransactionReceipt privateTxReceipt =
getPrivateTransactionReceipt(node, transactionHash, PUBLIC_KEY);

BytesValue output = BytesValue.fromHexString(privateTxReceipt.getOutput());
assertEquals(Numeric.decodeQuantity(output.toString()), new BigInteger(returnValue));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.privacy;

import static tech.pegasys.pantheon.tests.acceptance.dsl.WaitUtils.waitFor;

import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Eea;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ResponseTypes;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transactions;

public abstract class ExpectValidPrivateTransactionReceipt {

private Eea eea;
private Transactions transactions;

ExpectValidPrivateTransactionReceipt(final Eea eea, final Transactions transactions) {
this.eea = eea;
this.transactions = transactions;
}

ResponseTypes.PrivateTransactionReceipt getPrivateTransactionReceipt(
final PantheonNode node, final String transactionHash, final String publicKey) {

waitFor(() -> node.verify(eea.expectSuccessfulTransactionReceipt(transactionHash, publicKey)));
ResponseTypes.PrivateTransactionReceipt privateTxReceipt =
node.execute(transactions.getPrivateTransactionReceipt(transactionHash, publicKey));
return privateTxReceipt;
}
}
Loading

0 comments on commit a8d54e7

Please sign in to comment.