Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.hyperledger.besu.tests.acceptance.dsl.condition.login.LoginConditions;
import org.hyperledger.besu.tests.acceptance.dsl.condition.net.NetConditions;
import org.hyperledger.besu.tests.acceptance.dsl.condition.perm.PermissioningConditions;
import org.hyperledger.besu.tests.acceptance.dsl.condition.priv.PrivConditions;
import org.hyperledger.besu.tests.acceptance.dsl.condition.web3.Web3Conditions;
import org.hyperledger.besu.tests.acceptance.dsl.contract.ContractVerifier;
import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.Cluster;
Expand All @@ -37,6 +38,7 @@
import org.hyperledger.besu.tests.acceptance.dsl.transaction.miner.MinerTransactions;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.net.NetTransactions;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.perm.PermissioningTransactions;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyTransactions;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.web3.Web3Transactions;

import org.junit.After;
Expand Down Expand Up @@ -65,6 +67,8 @@ public class AcceptanceTestBase {
protected final PermissioningTransactions permissioningTransactions;
protected final MinerTransactions minerTransactions;
protected final Web3Conditions web3;
protected final PrivConditions priv;
protected final PrivacyTransactions privacyTransactions;

protected AcceptanceTestBase() {
ethTransactions = new EthTransactions();
Expand All @@ -74,6 +78,7 @@ protected AcceptanceTestBase() {
ibftTwoTransactions = new Ibft2Transactions();
accountTransactions = new AccountTransactions(accounts);
permissioningTransactions = new PermissioningTransactions();
privacyTransactions = new PrivacyTransactions();
contractTransactions = new ContractTransactions();
minerTransactions = new MinerTransactions();

Expand All @@ -85,6 +90,7 @@ protected AcceptanceTestBase() {
net = new NetConditions(new NetTransactions());
cluster = new Cluster(net);
perm = new PermissioningConditions(permissioningTransactions);
priv = new PrivConditions(privacyTransactions);
admin = new AdminConditions(adminTransactions);
web3 = new Web3Conditions(new Web3Transactions());
besu = new BesuNodeFactory();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.condition.priv;

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

import org.hyperledger.besu.ethereum.core.Hash;
import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.EeaSendRawTransactionTransaction;

public class EeaSendRawTransactionSuccess implements Condition {

private final EeaSendRawTransactionTransaction sendRawTransactionTransaction;

public EeaSendRawTransactionSuccess(
final EeaSendRawTransactionTransaction sendRawTransactionTransaction) {
this.sendRawTransactionTransaction = sendRawTransactionTransaction;
}

@Override
public void verify(final Node node) {
final Hash transactionHash = node.execute(sendRawTransactionTransaction);
assertThat(transactionHash).isNotNull();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.condition.priv;

import org.hyperledger.besu.ethereum.core.Address;
import org.hyperledger.besu.ethereum.core.Hash;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyTransactions;

import java.util.List;

public class PrivConditions {

private final PrivacyTransactions transactions;

public PrivConditions(final PrivacyTransactions transactions) {
this.transactions = transactions;
}

public Condition getPrivacyPrecompileAddress(final Address precompileAddress) {
return new PrivGetPrivacyPrecompileAddressSuccess(
transactions.getPrivacyPrecompileAddress(), precompileAddress);
}

public Condition getPrivateTransaction(
final Hash transactionHash, final PrivateTransaction privateTransaction) {
return new PrivGetPrivateTransactionSuccess(
transactions.getPrivateTransaction(transactionHash), privateTransaction);
}

public Condition createPrivacyGroup(
final List<String> addresses,
final String groupName,
final String groupDescription,
final String groupId) {
return new PrivCreatePrivacyGroupSuccess(
transactions.createPrivacyGroup(addresses, groupName, groupDescription), groupId);
}

public Condition deletePrivacyGroup(final String groupId) {
return new PrivDeletePrivacyGroupSuccess(transactions.deletePrivacyGroup(groupId), groupId);
}

public Condition findPrivacyGroup(final int numGroups, final String... groupMembers) {
return new PrivFindPrivacyGroupSuccess(transactions.findPrivacyGroup(groupMembers), numGroups);
}

public Condition eeaSendRawTransaction(final String transaction) {
return new EeaSendRawTransactionSuccess(transactions.sendRawTransaction(transaction));
}

public Condition distributeRawTransaction(
final String transactionRLP, final String enclaveResponseKey) {
return new PrivDistributeRawTransactionSuccess(
transactions.distributeRawTransaction(transactionRLP), enclaveResponseKey);
}

public Condition getTransactionCount(
final String accountAddress,
final String privacyGroupId,
final int expectedTransactionCount) {
return new PrivGetTransactionCountSuccess(
transactions.getTransactionCount(accountAddress, privacyGroupId), expectedTransactionCount);
}

public Condition getEeaTransactionCount(
final String accountAddress,
final String privateFrom,
final String[] privateFor,
final int expectedTransactionCount) {
return new PrivGetEeaTransactionCountSuccess(
transactions.getEeaTransactionCount(accountAddress, privateFrom, privateFor),
expectedTransactionCount);
}

public Condition getTransactionReceipt(final Hash transactionHash) {
return new PrivGetTransactionReceiptSuccess(
transactions.getTransactionReceipt(transactionHash));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.condition.priv;

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

import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivCreatePrivacyGroupTransaction;

public class PrivCreatePrivacyGroupSuccess implements Condition {

private final PrivCreatePrivacyGroupTransaction transaction;
private final String groupId;

public PrivCreatePrivacyGroupSuccess(
final PrivCreatePrivacyGroupTransaction transaction, final String groupId) {
this.transaction = transaction;
this.groupId = groupId;
}

@Override
public void verify(final Node node) {
final String result = node.execute(transaction);
assertThat(result).isEqualTo(groupId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.condition.priv;

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

import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivDeletePrivacyGroupTransaction;

public class PrivDeletePrivacyGroupSuccess implements Condition {

private final PrivDeletePrivacyGroupTransaction transaction;
private final String groupId;

public PrivDeletePrivacyGroupSuccess(
final PrivDeletePrivacyGroupTransaction transaction, final String groupId) {
this.transaction = transaction;
this.groupId = groupId;
}

@Override
public void verify(final Node node) {
final String result = node.execute(transaction);
assertThat(result).isEqualTo(groupId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.condition.priv;

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

import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivDistributeRawTransactionTransaction;

public class PrivDistributeRawTransactionSuccess implements Condition {

private final PrivDistributeRawTransactionTransaction sendRawTransactionTransaction;
private final String enclaveResponseKey;

public PrivDistributeRawTransactionSuccess(
final PrivDistributeRawTransactionTransaction sendRawTransactionTransaction,
final String enclaveResponseKey) {
this.sendRawTransactionTransaction = sendRawTransactionTransaction;
this.enclaveResponseKey = enclaveResponseKey;
}

@Override
public void verify(final Node node) {
final String result = node.execute(sendRawTransactionTransaction);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(String.class);
assertThat(result).isEqualTo(enclaveResponseKey);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.condition.priv;

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

import org.hyperledger.besu.enclave.types.PrivacyGroup;
import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivFindPrivacyGroupTransaction;

public class PrivFindPrivacyGroupSuccess implements Condition {

private final PrivFindPrivacyGroupTransaction transaction;
private final int numGroups;

public PrivFindPrivacyGroupSuccess(
final PrivFindPrivacyGroupTransaction transaction, final int numGroups) {
this.transaction = transaction;
this.numGroups = numGroups;
}

@Override
public void verify(final Node node) {
final PrivacyGroup[] privacyGroups = node.execute(transaction);
assertThat(privacyGroups).hasSize(numGroups);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.condition.priv;

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

import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivGetEeaTransactionCountTransaction;

public class PrivGetEeaTransactionCountSuccess implements Condition {

private final PrivGetEeaTransactionCountTransaction privGetEeaTransactionCountTransaction;
private final int expectedTransactionCount;

public PrivGetEeaTransactionCountSuccess(
final PrivGetEeaTransactionCountTransaction privGetEeaTransactionCountTransaction,
final int expectedTransactionCount) {
this.privGetEeaTransactionCountTransaction = privGetEeaTransactionCountTransaction;
this.expectedTransactionCount = expectedTransactionCount;
}

@Override
public void verify(final Node node) {
final int result = node.execute(privGetEeaTransactionCountTransaction);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(Integer.class);
assertThat(result).isEqualTo(expectedTransactionCount);
}
}
Loading