diff --git a/CHANGELOG.md b/CHANGELOG.md index ec895443c33..9ea4ced222a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ### Breaking Changes ### Additions and Improvements +- Remove privacy test classes support [#7569](https://github.com/hyperledger/besu/pull/7569) + ### Bug fixes @@ -26,7 +28,7 @@ - Performance optimzation for ECMUL (2 of 2) [#7543](https://github.com/hyperledger/besu/pull/7543) - Include current chain head block when computing `eth_maxPriorityFeePerGas` [#7485](https://github.com/hyperledger/besu/pull/7485) - Remove (old) documentation updates from the changelog [#7562](https://github.com/hyperledger/besu/pull/7562) -- Update Java and Gradle dependecies [#7571](https://github.com/hyperledger/besu/pull/7571) +- Update Java and Gradle dependencies [#7571](https://github.com/hyperledger/besu/pull/7571) - Layered txpool: new options `--tx-pool-min-score` to remove a tx from pool when its score is lower than the specified value [#7576](https://github.com/hyperledger/besu/pull/7576) - Add `engine_getBlobsV1` method to the Engine API [#7553](https://github.com/hyperledger/besu/pull/7553) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java index 4072c6f1bc1..5256e71ee30 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java @@ -26,7 +26,6 @@ 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.process.ExitedWithCode; import org.hyperledger.besu.tests.acceptance.dsl.condition.txpool.TxPoolConditions; import org.hyperledger.besu.tests.acceptance.dsl.condition.web3.Web3Conditions; @@ -44,7 +43,6 @@ 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.txpool.TxPoolTransactions; import org.hyperledger.besu.tests.acceptance.dsl.transaction.web3.Web3Transactions; @@ -93,8 +91,6 @@ public class AcceptanceTestBase { protected final PermissioningTransactions permissioningTransactions; protected final MinerTransactions minerTransactions; protected final Web3Conditions web3; - protected final PrivConditions priv; - protected final PrivacyTransactions privacyTransactions; protected final TxPoolConditions txPoolConditions; protected final TxPoolTransactions txPoolTransactions; protected final ExitedWithCode exitedSuccessfully; @@ -109,10 +105,8 @@ protected AcceptanceTestBase() { bftTransactions = new BftTransactions(); accountTransactions = new AccountTransactions(accounts); permissioningTransactions = new PermissioningTransactions(); - privacyTransactions = new PrivacyTransactions(); contractTransactions = new ContractTransactions(); minerTransactions = new MinerTransactions(); - blockchain = new Blockchain(ethTransactions); clique = new CliqueConditions(ethTransactions, cliqueTransactions); eth = new EthConditions(ethTransactions); @@ -121,7 +115,6 @@ 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(); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseJunit5.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseJunit5.java index 0cf24b57364..4f3046c1abf 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseJunit5.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseJunit5.java @@ -26,7 +26,6 @@ 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.process.ExitedWithCode; import org.hyperledger.besu.tests.acceptance.dsl.condition.txpool.TxPoolConditions; import org.hyperledger.besu.tests.acceptance.dsl.condition.web3.Web3Conditions; @@ -44,7 +43,6 @@ 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.txpool.TxPoolTransactions; import org.hyperledger.besu.tests.acceptance.dsl.transaction.web3.Web3Transactions; @@ -96,8 +94,6 @@ public class AcceptanceTestBaseJunit5 { protected final PermissioningTransactions permissioningTransactions; protected final MinerTransactions minerTransactions; protected final Web3Conditions web3; - protected final PrivConditions priv; - protected final PrivacyTransactions privacyTransactions; protected final TxPoolConditions txPoolConditions; protected final TxPoolTransactions txPoolTransactions; protected final ExitedWithCode exitedSuccessfully; @@ -112,10 +108,8 @@ protected AcceptanceTestBaseJunit5() { bftTransactions = new BftTransactions(); accountTransactions = new AccountTransactions(accounts); permissioningTransactions = new PermissioningTransactions(); - privacyTransactions = new PrivacyTransactions(); contractTransactions = new ContractTransactions(); minerTransactions = new MinerTransactions(); - blockchain = new Blockchain(ethTransactions); clique = new CliqueConditions(ethTransactions, cliqueTransactions); eth = new EthConditions(ethTransactions); @@ -124,7 +118,6 @@ protected AcceptanceTestBaseJunit5() { 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(); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/EeaSendRawTransactionSuccess.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/EeaSendRawTransactionSuccess.java deleted file mode 100644 index 9aef5825ea4..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/EeaSendRawTransactionSuccess.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.datatypes.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(); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/ExpectJsonRpcError.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/ExpectJsonRpcError.java deleted file mode 100644 index a642a2731c9..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/ExpectJsonRpcError.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.failBecauseExceptionWasNotThrown; - -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -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.Transaction; - -import org.assertj.core.api.Assertions; -import org.web3j.protocol.exceptions.ClientConnectionException; - -public class ExpectJsonRpcError implements Condition { - - private final Transaction transaction; - private final JsonRpcError error; - - public ExpectJsonRpcError(final Transaction transaction, final JsonRpcError error) { - this.transaction = transaction; - this.error = error; - } - - public ExpectJsonRpcError(final Transaction transaction, final RpcErrorType error) { - this(transaction, new JsonRpcError(error)); - } - - @Override - public void verify(final Node node) { - try { - node.execute(transaction); - failBecauseExceptionWasNotThrown(ClientConnectionException.class); - } catch (final Exception e) { - Assertions.assertThat(e) - .isInstanceOf(RuntimeException.class) - .hasMessageContaining(error.getMessage()); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivConditions.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivConditions.java deleted file mode 100644 index 2bbf04534de..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivConditions.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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.datatypes.Address; -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; -import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.condition.PrivateCondition; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; -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 getPrivateTransactionReturnsNull(final Hash transactionHash) { - return new PrivGetPrivateTransactionReturnsNull( - transactions.getPrivateTransaction(transactionHash)); - } - - public Condition createPrivacyGroup( - final List 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 getSuccessfulTransactionReceipt(final Hash transactionHash) { - return new PrivGetExpectedSuccessfulTransactionReceipt( - transactions.getTransactionReceipt(transactionHash)); - } - - public Condition getFailedTransactionReceipt(final Hash transactionHash) { - return new PrivGetExpectedFailedTransactionReceipt( - transactions.getTransactionReceipt(transactionHash)); - } - - public Condition getInvalidTransactionReceipt(final Hash transactionHash) { - return new PrivGetExpectedInvalidTransactionReceipt( - transactions.getTransactionReceipt(transactionHash)); - } - - public Condition multiTenancyValidationFail( - final Transaction transaction, final RpcErrorType error) { - return new ExpectJsonRpcError(transaction, error); - } - - public PrivateCondition syncingStatus(final boolean isSyncing) { - return new PrivateSyncingStatusCondition(transactions.syncing(), isSyncing); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivCreatePrivacyGroupSuccess.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivCreatePrivacyGroupSuccess.java deleted file mode 100644 index c507ca4b50f..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivCreatePrivacyGroupSuccess.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivDeletePrivacyGroupSuccess.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivDeletePrivacyGroupSuccess.java deleted file mode 100644 index b2cd4a40ce5..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivDeletePrivacyGroupSuccess.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivDistributeRawTransactionSuccess.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivDistributeRawTransactionSuccess.java deleted file mode 100644 index 4184102cf5a..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivDistributeRawTransactionSuccess.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivFindPrivacyGroupSuccess.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivFindPrivacyGroupSuccess.java deleted file mode 100644 index f4a069a243f..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivFindPrivacyGroupSuccess.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetEeaTransactionCountSuccess.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetEeaTransactionCountSuccess.java deleted file mode 100644 index def5502d98c..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetEeaTransactionCountSuccess.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetExpectedFailedTransactionReceipt.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetExpectedFailedTransactionReceipt.java deleted file mode 100644 index fc3b0818796..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetExpectedFailedTransactionReceipt.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.WaitUtils; -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.PrivGetTransactionReceiptTransaction; - -public class PrivGetExpectedFailedTransactionReceipt implements Condition { - - private final PrivGetTransactionReceiptTransaction getTransactionReceiptTransaction; - - public PrivGetExpectedFailedTransactionReceipt( - final PrivGetTransactionReceiptTransaction getTransactionReceiptTransaction) { - this.getTransactionReceiptTransaction = getTransactionReceiptTransaction; - } - - @Override - public void verify(final Node node) { - WaitUtils.waitFor(() -> assertThat(node.execute(getTransactionReceiptTransaction)).isNotNull()); - assertThat(node.execute(getTransactionReceiptTransaction).getStatus()).isEqualTo("0x0"); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetExpectedInvalidTransactionReceipt.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetExpectedInvalidTransactionReceipt.java deleted file mode 100644 index 75a344ded77..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetExpectedInvalidTransactionReceipt.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.WaitUtils; -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.PrivGetTransactionReceiptTransaction; - -public class PrivGetExpectedInvalidTransactionReceipt implements Condition { - - private final PrivGetTransactionReceiptTransaction getTransactionReceiptTransaction; - - public PrivGetExpectedInvalidTransactionReceipt( - final PrivGetTransactionReceiptTransaction getTransactionReceiptTransaction) { - this.getTransactionReceiptTransaction = getTransactionReceiptTransaction; - } - - @Override - public void verify(final Node node) { - WaitUtils.waitFor(() -> assertThat(node.execute(getTransactionReceiptTransaction)).isNotNull()); - assertThat(node.execute(getTransactionReceiptTransaction).getStatus()).isEqualTo("0x2"); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetExpectedSuccessfulTransactionReceipt.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetExpectedSuccessfulTransactionReceipt.java deleted file mode 100644 index cefc110e1b2..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetExpectedSuccessfulTransactionReceipt.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.WaitUtils; -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.PrivGetTransactionReceiptTransaction; - -public class PrivGetExpectedSuccessfulTransactionReceipt implements Condition { - - private final PrivGetTransactionReceiptTransaction getTransactionReceiptTransaction; - - public PrivGetExpectedSuccessfulTransactionReceipt( - final PrivGetTransactionReceiptTransaction getTransactionReceiptTransaction) { - this.getTransactionReceiptTransaction = getTransactionReceiptTransaction; - } - - @Override - public void verify(final Node node) { - WaitUtils.waitFor(() -> assertThat(node.execute(getTransactionReceiptTransaction)).isNotNull()); - assertThat(node.execute(getTransactionReceiptTransaction).getStatus()).isEqualTo("0x1"); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetPrivacyPrecompileAddressSuccess.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetPrivacyPrecompileAddressSuccess.java deleted file mode 100644 index a3992da4327..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetPrivacyPrecompileAddressSuccess.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.datatypes.Address; -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.PrivGetPrivacyPrecompileAddressTransaction; - -public class PrivGetPrivacyPrecompileAddressSuccess implements Condition { - - private final PrivGetPrivacyPrecompileAddressTransaction transaction; - private final Address precompileAddress; - - public PrivGetPrivacyPrecompileAddressSuccess( - final PrivGetPrivacyPrecompileAddressTransaction transaction, - final Address precompileAddress) { - this.transaction = transaction; - this.precompileAddress = precompileAddress; - } - - @Override - public void verify(final Node node) { - final Address result = node.execute(transaction); - assertThat(result).isInstanceOf(Address.class); - assertThat(result).isEqualTo(precompileAddress); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetPrivateTransactionReturnsNull.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetPrivateTransactionReturnsNull.java deleted file mode 100644 index da6f7f519bf..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetPrivateTransactionReturnsNull.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.privacy.PrivateTransactionGroupResponse; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivGetPrivateTransactionTransaction; - -public class PrivGetPrivateTransactionReturnsNull implements Condition { - - private final PrivGetPrivateTransactionTransaction transaction; - - public PrivGetPrivateTransactionReturnsNull( - final PrivGetPrivateTransactionTransaction transaction) { - this.transaction = transaction; - } - - @Override - public void verify(final Node node) { - final PrivateTransactionGroupResponse result = node.execute(transaction); - assertThat(result).isNull(); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetPrivateTransactionSuccess.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetPrivateTransactionSuccess.java deleted file mode 100644 index b09b1b29bca..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetPrivateTransactionSuccess.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.api.jsonrpc.internal.results.privacy.PrivateTransactionGroupResult; -import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; -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.privacy.PrivateTransactionGroupResponse; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivGetPrivateTransactionTransaction; - -public class PrivGetPrivateTransactionSuccess implements Condition { - - private final PrivGetPrivateTransactionTransaction transaction; - private final PrivateTransactionGroupResult privateTransaction; - - public PrivGetPrivateTransactionSuccess( - final PrivGetPrivateTransactionTransaction transaction, - final PrivateTransaction privateTransaction) { - this.transaction = transaction; - this.privateTransaction = new PrivateTransactionGroupResult(privateTransaction); - } - - @Override - public void verify(final Node node) { - final PrivateTransactionGroupResponse result = node.execute(transaction); - assertThat(result).usingRecursiveComparison().isEqualTo(privateTransaction); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetTransactionCountSuccess.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetTransactionCountSuccess.java deleted file mode 100644 index 823548effaf..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivGetTransactionCountSuccess.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.PrivGetTransactionCountTransaction; - -public class PrivGetTransactionCountSuccess implements Condition { - - private final PrivGetTransactionCountTransaction privGetTransactionCountTransaction; - private final int expectedTransactionCount; - - public PrivGetTransactionCountSuccess( - final PrivGetTransactionCountTransaction privGetTransactionCountTransaction, - final int expectedTransactionCount) { - this.privGetTransactionCountTransaction = privGetTransactionCountTransaction; - this.expectedTransactionCount = expectedTransactionCount; - } - - @Override - public void verify(final Node node) { - final Integer result = node.execute(privGetTransactionCountTransaction); - assertThat(result).isNotNull(); - assertThat(result).isInstanceOf(Integer.class); - assertThat(result).isEqualTo(expectedTransactionCount); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivateSyncingStatusCondition.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivateSyncingStatusCondition.java deleted file mode 100644 index 067cba268d2..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/priv/PrivateSyncingStatusCondition.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.WaitUtils; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.condition.PrivateCondition; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivSyncingTransactions; - -public class PrivateSyncingStatusCondition implements PrivateCondition { - - private final PrivSyncingTransactions transaction; - private final boolean syncingMiningStatus; - - public PrivateSyncingStatusCondition( - final PrivSyncingTransactions transaction, final boolean syncingStatus) { - this.transaction = transaction; - this.syncingMiningStatus = syncingStatus; - } - - @Override - public void verify(final PrivacyNode node) { - WaitUtils.waitFor( - 10, () -> assertThat(node.execute(transaction)).isEqualTo(syncingMiningStatus)); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java index 1ae27d62614..157421531bb 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java @@ -49,7 +49,6 @@ import org.hyperledger.besu.tests.acceptance.dsl.transaction.miner.MinerRequestFactory; import org.hyperledger.besu.tests.acceptance.dsl.transaction.net.CustomRequestFactory; import org.hyperledger.besu.tests.acceptance.dsl.transaction.perm.PermissioningJsonRpcRequestFactory; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory; import org.hyperledger.besu.tests.acceptance.dsl.transaction.txpool.TxPoolRequestFactory; import java.io.File; @@ -445,7 +444,6 @@ public NodeRequests nodeRequests() { new BftRequestFactory(web3jService, bftType), new PermissioningJsonRpcRequestFactory(web3jService), new AdminRequestFactory(web3jService), - new PrivacyRequestFactory(web3jService), new CustomRequestFactory(web3jService), new MinerRequestFactory(web3jService), new TxPoolRequestFactory(web3jService), diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java index 9660f6ee9dc..0451d2a7212 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java @@ -20,16 +20,8 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.IBFT; import org.hyperledger.besu.crypto.KeyPair; -import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.enclave.EnclaveFactory; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; -import org.hyperledger.besu.ethereum.core.AddressHelpers; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.InMemoryPrivacyStorageProvider; -import org.hyperledger.besu.ethereum.core.MiningParameters; -import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration; @@ -45,7 +37,6 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -53,8 +44,6 @@ import java.util.Set; import java.util.function.UnaryOperator; -import io.vertx.core.Vertx; - public class BesuNodeFactory { private final NodeConfigurationFactory node = new NodeConfigurationFactory(); @@ -288,49 +277,6 @@ public BesuNode createNodeWithP2pDisabled(final String name) throws IOException .build()); } - public BesuNode createNodeWithMultiTenantedPrivacy( - final String name, - final String enclaveUrl, - final String authFile, - final String privTransactionSigningKey, - final boolean enableFlexiblePrivacy, - final boolean enablePrivateNonceAlwaysIncrements) - throws IOException, URISyntaxException { - final PrivacyParameters.Builder privacyParametersBuilder = new PrivacyParameters.Builder(); - final PrivacyParameters privacyParameters = - privacyParametersBuilder - .setMultiTenancyEnabled(true) - .setEnabled(true) - .setFlexiblePrivacyGroupsEnabled(enableFlexiblePrivacy) - .setStorageProvider(new InMemoryPrivacyStorageProvider()) - .setEnclaveFactory(new EnclaveFactory(Vertx.vertx())) - .setEnclaveUrl(URI.create(enclaveUrl)) - .setPrivateNonceAlwaysIncrementsEnabled(enablePrivateNonceAlwaysIncrements) - .setPrivateKeyPath( - Paths.get(ClassLoader.getSystemResource(privTransactionSigningKey).toURI())) - .build(); - - final MiningParameters miningParameters = - ImmutableMiningParameters.builder() - .mutableInitValues( - MutableInitValues.builder() - .isMiningEnabled(true) - .minTransactionGasPrice(Wei.ZERO) - .coinbase(AddressHelpers.ofValue(1)) - .build()) - .build(); - - return create( - new BesuNodeConfigurationBuilder() - .name(name) - .jsonRpcEnabled() - .jsonRpcAuthenticationConfiguration(authFile) - .enablePrivateTransactions() - .privacyParameters(privacyParameters) - .miningConfiguration(miningParameters) - .build()); - } - public BesuNode createArchiveNodeWithRpcDisabled(final String name) throws IOException { return create(new BesuNodeConfigurationBuilder().name(name).build()); } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeConfiguration.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeConfiguration.java deleted file mode 100644 index 05c989e54aa..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeConfiguration.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.node.configuration.privacy; - -import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeConfiguration; -import org.hyperledger.enclave.testutil.EnclaveKeyConfiguration; - -public class PrivacyNodeConfiguration { - - private final boolean isFlexiblePrivacyGroupEnabled; - private final boolean isMultitenancyEnabled; - private final boolean isPrivacyPluginEnabled; - private final BesuNodeConfiguration besuConfig; - private final EnclaveKeyConfiguration keyConfig; - - PrivacyNodeConfiguration( - final BesuNodeConfiguration besuConfig, final EnclaveKeyConfiguration keyConfig) { - this(false, false, false, besuConfig, keyConfig); - } - - public PrivacyNodeConfiguration( - final boolean isFlexiblePrivacyGroupEnabled, - final boolean isMultitenancyEnabled, - final boolean isPrivacyPluginEnabled, - final BesuNodeConfiguration besuConfig, - final EnclaveKeyConfiguration keyConfig) { - this.isFlexiblePrivacyGroupEnabled = isFlexiblePrivacyGroupEnabled; - this.besuConfig = besuConfig; - this.keyConfig = keyConfig; - this.isMultitenancyEnabled = isMultitenancyEnabled; - this.isPrivacyPluginEnabled = isPrivacyPluginEnabled; - } - - public boolean isFlexiblePrivacyGroupEnabled() { - return isFlexiblePrivacyGroupEnabled; - } - - public boolean isMultitenancyEnabled() { - return isMultitenancyEnabled; - } - - public boolean isPrivacyPluginEnabled() { - return isPrivacyPluginEnabled; - } - - public BesuNodeConfiguration getBesuConfig() { - return besuConfig; - } - - public EnclaveKeyConfiguration getKeyConfig() { - return keyConfig; - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeFactory.java deleted file mode 100644 index 03188db8a27..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/privacy/PrivacyNodeFactory.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * 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.node.configuration.privacy; - -import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeConfigurationBuilder; -import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.NodeConfigurationFactory; -import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.genesis.GenesisConfigurationFactory; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.account.PrivacyAccount; -import org.hyperledger.enclave.testutil.EnclaveEncryptorType; -import org.hyperledger.enclave.testutil.EnclaveKeyConfiguration; -import org.hyperledger.enclave.testutil.EnclaveType; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import io.vertx.core.Vertx; -import org.testcontainers.containers.Network; - -public class PrivacyNodeFactory { - - private final NodeConfigurationFactory node = new NodeConfigurationFactory(); - private final Vertx vertx; - - public PrivacyNodeFactory(final Vertx vertx) { - this.vertx = vertx; - } - - public PrivacyNode create( - final PrivacyNodeConfiguration privacyNodeConfig, - final EnclaveType enclaveType, - final Optional containerNetwork) - throws IOException { - return new PrivacyNode(privacyNodeConfig, vertx, enclaveType, containerNetwork); - } - - public PrivacyNode createPrivateTransactionEnabledMinerNode( - final String name, - final PrivacyAccount privacyAccount, - final EnclaveType enclaveType, - final Optional containerNetwork, - final boolean isFlexiblePrivacyGroupEnabled, - final boolean isMultitenancyEnabled, - final boolean isPrivacyPluginEnabled) - throws IOException { - return create( - new PrivacyNodeConfiguration( - isFlexiblePrivacyGroupEnabled, - isMultitenancyEnabled, - isPrivacyPluginEnabled, - new BesuNodeConfigurationBuilder() - .name(name) - .miningEnabled() - .jsonRpcEnabled() - .webSocketEnabled() - .enablePrivateTransactions() - .keyFilePath(privacyAccount.getPrivateKeyPath()) - .plugins(Collections.singletonList("testPlugins")) - .extraCLIOptions(List.of("--plugin-privacy-service-encryption-prefix=0xAA")) - .build(), - new EnclaveKeyConfiguration( - privacyAccount.getEnclaveKeyPaths(), - privacyAccount.getEnclavePrivateKeyPaths(), - privacyAccount.getEnclaveEncryptorType())), - enclaveType, - containerNetwork); - } - - public PrivacyNode createPrivateTransactionEnabledNode( - final String name, - final PrivacyAccount privacyAccount, - final EnclaveType enclaveType, - final Optional containerNetwork, - final boolean isFlexiblePrivacyGroupEnabled, - final boolean isMultitenancyEnabled, - final boolean isPrivacyPluginEnabled) - throws IOException { - return create( - new PrivacyNodeConfiguration( - isFlexiblePrivacyGroupEnabled, - isMultitenancyEnabled, - isPrivacyPluginEnabled, - new BesuNodeConfigurationBuilder() - .name(name) - .jsonRpcEnabled() - .keyFilePath(privacyAccount.getPrivateKeyPath()) - .enablePrivateTransactions() - .webSocketEnabled() - .plugins(Collections.singletonList("testPlugins")) - .extraCLIOptions(List.of("--plugin-privacy-service-encryption-prefix=0xBB")) - .build(), - new EnclaveKeyConfiguration( - privacyAccount.getEnclaveKeyPaths(), - privacyAccount.getEnclavePrivateKeyPaths(), - privacyAccount.getEnclaveEncryptorType())), - enclaveType, - containerNetwork); - } - - public PrivacyNode createIbft2NodePrivacyEnabled( - final String name, - final PrivacyAccount privacyAccount, - final boolean minerEnabled, - final EnclaveType enclaveType, - final Optional containerNetwork, - final boolean isFlexiblePrivacyGroupEnabled, - final boolean isMultitenancyEnabled, - final boolean isPrivacyPluginEnabled, - final String unrestrictedPrefix) - throws IOException { - return create( - new PrivacyNodeConfiguration( - isFlexiblePrivacyGroupEnabled, - isMultitenancyEnabled, - isPrivacyPluginEnabled, - new BesuNodeConfigurationBuilder() - .name(name) - .miningEnabled() - .jsonRpcConfiguration(node.createJsonRpcWithIbft2EnabledConfig(minerEnabled)) - .webSocketConfiguration(node.createWebSocketEnabledConfig()) - .devMode(false) - .genesisConfigProvider(GenesisConfigurationFactory::createPrivacyIbft2GenesisConfig) - .keyFilePath(privacyAccount.getPrivateKeyPath()) - .enablePrivateTransactions() - .plugins(Collections.singletonList("testPlugins")) - .extraCLIOptions( - List.of("--plugin-privacy-service-encryption-prefix=" + unrestrictedPrefix)) - .build(), - new EnclaveKeyConfiguration( - privacyAccount.getEnclaveKeyPaths(), - privacyAccount.getEnclavePrivateKeyPaths(), - privacyAccount.getEnclaveEncryptorType())), - enclaveType, - containerNetwork); - } - - public PrivacyNode createIbft2NodePrivacyEnabledWithGenesis( - final String name, - final PrivacyAccount privacyAccount, - final boolean minerEnabled, - final EnclaveType enclaveType, - final Optional containerNetwork, - final boolean isFlexiblePrivacyGroupEnabled, - final boolean isMultitenancyEnabled, - final boolean isPrivacyPluginEnabled, - final String unrestrictedPrefix) - throws IOException { - return create( - new PrivacyNodeConfiguration( - isFlexiblePrivacyGroupEnabled, - isMultitenancyEnabled, - isPrivacyPluginEnabled, - new BesuNodeConfigurationBuilder() - .name(name) - .miningEnabled() - .jsonRpcConfiguration(node.createJsonRpcWithIbft2EnabledConfig(minerEnabled)) - .webSocketConfiguration(node.createWebSocketEnabledConfig()) - .devMode(false) - .genesisConfigProvider(GenesisConfigurationFactory::createPrivacyIbft2GenesisConfig) - .keyFilePath(privacyAccount.getPrivateKeyPath()) - .enablePrivateTransactions() - .plugins(Collections.singletonList("testPlugins")) - .extraCLIOptions( - List.of( - "--plugin-privacy-service-encryption-prefix=" + unrestrictedPrefix, - "--plugin-privacy-service-genesis-enabled=true")) - .build(), - new EnclaveKeyConfiguration( - privacyAccount.getEnclaveKeyPaths(), - privacyAccount.getEnclavePrivateKeyPaths(), - privacyAccount.getEnclaveEncryptorType())), - enclaveType, - containerNetwork); - } - - public PrivacyNode createQbftNodePrivacyEnabled( - final String name, - final PrivacyAccount privacyAccount, - final EnclaveType enclaveType, - final Optional containerNetwork, - final boolean isFlexiblePrivacyGroupEnabled, - final boolean isMultitenancyEnabled, - final boolean isPrivacyPluginEnabled, - final String unrestrictedPrefix) - throws IOException { - return create( - new PrivacyNodeConfiguration( - isFlexiblePrivacyGroupEnabled, - isMultitenancyEnabled, - isPrivacyPluginEnabled, - new BesuNodeConfigurationBuilder() - .name(name) - .miningEnabled() - .jsonRpcConfiguration(node.createJsonRpcWithQbftEnabledConfig(false)) - .webSocketConfiguration(node.createWebSocketEnabledConfig()) - .devMode(false) - .genesisConfigProvider(GenesisConfigurationFactory::createQbftGenesisConfig) - .keyFilePath(privacyAccount.getPrivateKeyPath()) - .enablePrivateTransactions() - .plugins(Collections.singletonList("testPlugins")) - .extraCLIOptions( - List.of("--plugin-privacy-service-encryption-prefix=" + unrestrictedPrefix)) - .build(), - new EnclaveKeyConfiguration( - privacyAccount.getEnclaveKeyPaths(), - privacyAccount.getEnclavePrivateKeyPaths(), - privacyAccount.getEnclaveEncryptorType())), - enclaveType, - containerNetwork); - } - - public PrivacyNode createFlexiblePrivacyGroupEnabledMinerNode( - final String name, - final PrivacyAccount privacyAccount, - final boolean multiTenancyEnabled, - final EnclaveType enclaveType, - final Optional containerNetwork) - throws IOException, URISyntaxException { - final BesuNodeConfigurationBuilder besuNodeConfigurationBuilder = - new BesuNodeConfigurationBuilder(); - if (multiTenancyEnabled) { - final String authPrivTomlPath = - EnclaveEncryptorType.EC.equals(privacyAccount.getEnclaveEncryptorType()) - ? "authentication/auth_priv_ec_pubkey.toml" - : "authentication/auth_priv.toml"; - besuNodeConfigurationBuilder.jsonRpcAuthenticationConfiguration(authPrivTomlPath); - } - return create( - new PrivacyNodeConfiguration( - true, - multiTenancyEnabled, - false, - besuNodeConfigurationBuilder - .name(name) - .miningEnabled() - .jsonRpcEnabled() - .webSocketEnabled() - .enablePrivateTransactions() - .plugins(Collections.singletonList("testPlugins")) - .extraCLIOptions(List.of("--plugin-privacy-service-genesis-enabled=true")) - .keyFilePath(privacyAccount.getPrivateKeyPath()) - .build(), - new EnclaveKeyConfiguration( - privacyAccount.getEnclaveKeyPaths(), - privacyAccount.getEnclavePrivateKeyPaths(), - privacyAccount.getEnclaveEncryptorType())), - enclaveType, - containerNetwork); - } - - public PrivacyNode createFlexiblePrivacyGroupEnabledNode( - final String name, - final PrivacyAccount privacyAccount, - final boolean multiTenancyEnabled, - final EnclaveType enclaveType, - final Optional containerNetwork) - throws IOException { - return create( - new PrivacyNodeConfiguration( - true, - multiTenancyEnabled, - false, - new BesuNodeConfigurationBuilder() - .name(name) - .jsonRpcEnabled() - .keyFilePath(privacyAccount.getPrivateKeyPath()) - .enablePrivateTransactions() - .plugins(Collections.singletonList("testPlugins")) - .extraCLIOptions(List.of("--plugin-privacy-service-genesis-enabled=true")) - .webSocketEnabled() - .build(), - new EnclaveKeyConfiguration( - privacyAccount.getEnclaveKeyPaths(), - privacyAccount.getEnclavePrivateKeyPaths(), - privacyAccount.getEnclaveEncryptorType())), - enclaveType, - containerNetwork); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyCluster.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyCluster.java deleted file mode 100644 index 3d1fc148059..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyCluster.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * 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.privacy; - -import static java.util.Collections.emptyList; -import static java.util.function.Predicate.not; - -import org.hyperledger.besu.tests.acceptance.dsl.condition.net.NetConditions; -import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNodeRunner; -import org.hyperledger.besu.tests.acceptance.dsl.node.RunnableNode; -import org.hyperledger.enclave.testutil.EnclaveType; -import org.hyperledger.enclave.testutil.TesseraTestHarness; - -import java.net.URI; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PrivacyCluster { - private static final Logger LOG = LoggerFactory.getLogger(PrivacyCluster.class); - private final NetConditions net; - private final BesuNodeRunner besuNodeRunner; - - private List nodes = emptyList(); - private List runnableNodes = emptyList(); - private PrivacyNode bootNode; - - public PrivacyCluster(final NetConditions net) { - this.net = net; - this.besuNodeRunner = BesuNodeRunner.instance(); - } - - public void start(final PrivacyNode... nodes) { - start(Arrays.asList(nodes)); - } - - public void start(final List nodes) { - startNodes(nodes); - awaitPeerCount(nodes); - } - - public void startNodes(final PrivacyNode... nodes) { - startNodes(Arrays.asList(nodes)); - } - - public void startNodes(final List nodes) { - if (nodes.isEmpty()) { - throw new IllegalArgumentException("Can't start a cluster with no nodes"); - } - this.nodes = nodes; - this.runnableNodes = nodes.stream().map(PrivacyNode::getBesu).collect(Collectors.toList()); - - final Optional bootNode = selectAndStartBootnode(nodes); - - nodes.parallelStream() - .filter(node -> bootNode.map(boot -> boot != node).orElse(true)) - .forEach(this::startNode); - } - - public void awaitPeerCount(final PrivacyNode... nodes) { - awaitPeerCount(Arrays.asList(nodes)); - } - - public void awaitPeerCount(final List nodes) { - for (final PrivacyNode node : nodes) { - LOG.info("Awaiting peer discovery for node {}", node.getName()); - node.awaitPeerDiscovery(net.awaitPeerCount(nodes.size() - 1)); - } - - verifyAllEnclaveNetworkConnections(); - } - - public List getNodes() { - return nodes; - } - - /** Verify that each Enclave has connected to every other Enclave */ - public void verifyAllEnclaveNetworkConnections() { - nodes.forEach( - privacyNode -> { - final List otherNodes = - nodes.stream() - .filter(not(privacyNode::equals)) - .collect(Collectors.toUnmodifiableList()); - privacyNode.testEnclaveConnection(otherNodes); - }); - } - - public void stop() { - for (final PrivacyNode node : nodes) { - besuNodeRunner.stopNode(node.getBesu()); - } - } - - public void stopNode(final PrivacyNode node) { - node.getEnclave().stop(); - besuNodeRunner.stopNode(node.getBesu()); - } - - public void close() { - stop(); - for (final PrivacyNode node : nodes) { - node.close(); - } - besuNodeRunner.shutdown(); - } - - private Optional selectAndStartBootnode(final List nodes) { - final Optional bootNode = - nodes.stream() - .filter(node -> node.getConfiguration().isBootnodeEligible()) - .filter(node -> node.getConfiguration().isP2pEnabled()) - .filter(node -> node.getConfiguration().isDiscoveryEnabled()) - .findFirst(); - - bootNode.ifPresent( - b -> { - LOG.info("Selected node {} as bootnode", b.getName()); - startNode(b, true); - this.bootNode = b; - }); - - return bootNode; - } - - private void startNode(final PrivacyNode node) { - startNode(node, false); - } - - private void startNode(final PrivacyNode node, final boolean isBootNode) { - node.getConfiguration() - .setBootnodes(isBootNode ? emptyList() : Collections.singletonList(bootNode.enodeUrl())); - - node.getConfiguration() - .getGenesisConfigProvider() - .create(runnableNodes) - .ifPresent(node.getConfiguration()::setGenesisConfig); - - if (!isBootNode) { - if (bootNode.getEnclave().getEnclaveType() == EnclaveType.TESSERA) { - final URI otherNode = bootNode.getEnclave().nodeUrl(); - try { - // Substitute IP with hostname for test container network - final URI otherNodeHostname = - new URI( - otherNode.getScheme() - + "://" - + bootNode.getName() - + ":" - + TesseraTestHarness.p2pPort); - node.addOtherEnclaveNode(otherNodeHostname); - } catch (Exception ex) { - throw new RuntimeException("Invalid node URI"); - } - } else { - node.addOtherEnclaveNode(bootNode.getEnclave().nodeUrl()); - } - } - - LOG.info( - "Starting node {} (id = {}...{})", - node.getName(), - node.getNodeId().substring(0, 4), - node.getNodeId().substring(124)); - node.start(besuNodeRunner); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java deleted file mode 100644 index d54bf908726..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * 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.privacy; - -import static org.hyperledger.besu.controller.BesuController.DATABASE_PATH; -import static org.hyperledger.besu.plugin.services.storage.rocksdb.configuration.RocksDBCLIOptions.DEFAULT_BACKGROUND_THREAD_COUNT; -import static org.hyperledger.besu.plugin.services.storage.rocksdb.configuration.RocksDBCLIOptions.DEFAULT_CACHE_CAPACITY; -import static org.hyperledger.besu.plugin.services.storage.rocksdb.configuration.RocksDBCLIOptions.DEFAULT_IS_HIGH_SPEC; -import static org.hyperledger.besu.plugin.services.storage.rocksdb.configuration.RocksDBCLIOptions.DEFAULT_MAX_OPEN_FILES; - -import org.hyperledger.besu.crypto.KeyPairUtil; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.enclave.Enclave; -import org.hyperledger.besu.enclave.EnclaveClientException; -import org.hyperledger.besu.enclave.EnclaveFactory; -import org.hyperledger.besu.enclave.EnclaveIOException; -import org.hyperledger.besu.enclave.EnclaveServerException; -import org.hyperledger.besu.ethereum.core.PrivacyParameters; -import org.hyperledger.besu.ethereum.privacy.storage.PrivacyStorageProvider; -import org.hyperledger.besu.ethereum.privacy.storage.keyvalue.PrivacyKeyValueStorageProviderBuilder; -import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier; -import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; -import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBKeyValuePrivacyStorageFactory; -import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBKeyValueStorageFactory; -import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBMetricsFactory; -import org.hyperledger.besu.plugin.services.storage.rocksdb.configuration.RocksDBFactoryConfiguration; -import org.hyperledger.besu.services.BesuConfigurationImpl; -import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition; -import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; -import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNodeRunner; -import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeConfiguration; -import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.NodeConfiguration; -import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.privacy.PrivacyNodeConfiguration; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.condition.PrivateCondition; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; -import org.hyperledger.enclave.testutil.EnclaveTestHarness; -import org.hyperledger.enclave.testutil.EnclaveType; -import org.hyperledger.enclave.testutil.NoopEnclaveTestHarness; -import org.hyperledger.enclave.testutil.TesseraTestHarnessFactory; - -import java.io.IOException; -import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import io.vertx.core.Vertx; -import org.awaitility.Awaitility; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testcontainers.containers.Network; - -public class PrivacyNode implements AutoCloseable { - - private static final Logger LOG = LoggerFactory.getLogger(PrivacyNode.class); - - private final EnclaveTestHarness enclave; - private final BesuNode besu; - private final Vertx vertx; - private final boolean isFlexiblePrivacyEnabled; - private final boolean isMultitenancyEnabled; - private final boolean isPrivacyPluginEnabled; - private final BesuNodeConfiguration besuConfig; - - public PrivacyNode( - final PrivacyNodeConfiguration privacyConfiguration, - final Vertx vertx, - final EnclaveType enclaveType, - final Optional containerNetwork) - throws IOException { - final Path enclaveDir = Files.createTempDirectory("acctest-orion"); - final BesuNodeConfiguration config = privacyConfiguration.getBesuConfig(); - this.enclave = - selectEnclave(enclaveType, enclaveDir, config, privacyConfiguration, containerNetwork); - this.vertx = vertx; - - this.besuConfig = config; - - isFlexiblePrivacyEnabled = privacyConfiguration.isFlexiblePrivacyGroupEnabled(); - isMultitenancyEnabled = privacyConfiguration.isMultitenancyEnabled(); - isPrivacyPluginEnabled = privacyConfiguration.isPrivacyPluginEnabled(); - - this.besu = - new BesuNode( - besuConfig.getName(), - besuConfig.getDataPath(), - besuConfig.getMiningParameters(), - besuConfig.getTransactionPoolConfiguration(), - besuConfig.getJsonRpcConfiguration(), - besuConfig.getEngineRpcConfiguration(), - besuConfig.getWebSocketConfiguration(), - besuConfig.getJsonRpcIpcConfiguration(), - besuConfig.getInProcessRpcConfiguration(), - besuConfig.getMetricsConfiguration(), - besuConfig.getPermissioningConfiguration(), - besuConfig.getApiConfiguration(), - besuConfig.getDataStorageConfiguration(), - besuConfig.getKeyFilePath(), - besuConfig.isDevMode(), - besuConfig.getNetwork(), - besuConfig.getGenesisConfigProvider(), - besuConfig.isP2pEnabled(), - besuConfig.getP2pPort(), - besuConfig.getTLSConfiguration(), - besuConfig.getNetworkingConfiguration(), - besuConfig.isDiscoveryEnabled(), - besuConfig.isBootnodeEligible(), - besuConfig.isRevertReasonEnabled(), - besuConfig.isSecp256k1Native(), - besuConfig.isAltbn128Native(), - besuConfig.getPlugins(), - besuConfig.getExtraCLIOptions(), - Collections.emptyList(), - besuConfig.isDnsEnabled(), - besuConfig.getPrivacyParameters(), - List.of(), - Optional.empty(), - besuConfig.isStrictTxReplayProtectionEnabled(), - besuConfig.getEnvironment()); - } - - public void testEnclaveConnection(final List otherNodes) { - if (this.isPrivacyPluginEnabled) { - LOG.info("Skipping test as node has no enclave (isPrivacyPluginEnabled=true)"); - return; - } - - if (!otherNodes.isEmpty()) { - LOG.debug( - String.format( - "Testing Enclave connectivity between %s (%s) and %s (%s)", - besu.getName(), - enclave.nodeUrl(), - Arrays.toString(otherNodes.stream().map(node -> node.besu.getName()).toArray()), - Arrays.toString(otherNodes.stream().map(node -> node.enclave.nodeUrl()).toArray()))); - final EnclaveFactory factory = new EnclaveFactory(vertx); - final Enclave enclaveClient = factory.createVertxEnclave(enclave.clientUrl()); - final String payload = "SGVsbG8sIFdvcmxkIQ=="; - final List to = - otherNodes.stream() - .map(node -> node.enclave.getDefaultPublicKey()) - .collect(Collectors.toList()); - - Awaitility.await() - .until( - () -> { - try { - enclaveClient.send(payload, enclave.getDefaultPublicKey(), to); - return true; - } catch (final EnclaveClientException - | EnclaveIOException - | EnclaveServerException e) { - LOG.warn( - "Waiting for enclave connectivity between {} and {}: " + e.getMessage(), - enclave.getDefaultPublicKey(), - to.get(0)); - return false; - } - }); - } - } - - public EnclaveTestHarness getEnclave() { - return enclave; - } - - public BesuNode getBesu() { - return besu; - } - - public void stop() { - besu.stop(); - enclave.stop(); - } - - @Override - public void close() { - besu.close(); - enclave.close(); - } - - public void start(final BesuNodeRunner runner) { - enclave.start(); - - final PrivacyParameters privacyParameters; - - try { - final Path dataDir = Files.createTempDirectory("acctest-privacy"); - final Path dbDir = dataDir.resolve(DATABASE_PATH); - - var builder = - new PrivacyParameters.Builder() - .setEnabled(true) - .setEnclaveUrl(enclave.clientUrl()) - .setStorageProvider(createKeyValueStorageProvider(dataDir, dbDir)) - .setPrivateKeyPath(KeyPairUtil.getDefaultKeyFile(besu.homeDirectory()).toPath()) - .setEnclaveFactory(new EnclaveFactory(vertx)) - .setFlexiblePrivacyGroupsEnabled(isFlexiblePrivacyEnabled) - .setMultiTenancyEnabled(isMultitenancyEnabled) - .setPrivacyPluginEnabled(isPrivacyPluginEnabled); - - if (enclave.getPublicKeyPaths().size() > 0) { - builder.setPrivacyUserIdUsingFile(enclave.getPublicKeyPaths().get(0).toFile()); - } - - privacyParameters = builder.build(); - - } catch (final IOException e) { - throw new RuntimeException(e); - } - besu.setPrivacyParameters(privacyParameters); - besu.start(runner); - } - - public void awaitPeerDiscovery(final Condition condition) { - besu.awaitPeerDiscovery(condition); - } - - public String getName() { - return besu.getName(); - } - - public Address getAddress() { - return besu.getAddress(); - } - - public URI enodeUrl() { - return besu.enodeUrl(); - } - - public String getNodeId() { - return besu.getNodeId(); - } - - public T execute(final Transaction transaction) { - return besu.execute(transaction); - } - - public void verify(final PrivateCondition expected) { - expected.verify(this); - } - - public String getEnclaveKey() { - return enclave.getDefaultPublicKey(); - } - - public String getTransactionSigningKey() { - return besu.getPrivacyParameters().getSigningKeyPair().orElseThrow().getPrivateKey().toString(); - } - - public void addOtherEnclaveNode(final URI otherNode) { - enclave.addOtherNode(otherNode); - } - - public NodeConfiguration getConfiguration() { - return besu.getConfiguration(); - } - - private PrivacyStorageProvider createKeyValueStorageProvider( - final Path dataLocation, final Path dbLocation) { - final var besuConfiguration = new BesuConfigurationImpl(); - besuConfiguration - .init(dataLocation, dbLocation, besuConfig.getDataStorageConfiguration()) - .withMiningParameters(besuConfig.getMiningParameters()); - return new PrivacyKeyValueStorageProviderBuilder() - .withStorageFactory( - new RocksDBKeyValuePrivacyStorageFactory( - new RocksDBKeyValueStorageFactory( - () -> - new RocksDBFactoryConfiguration( - DEFAULT_MAX_OPEN_FILES, - DEFAULT_BACKGROUND_THREAD_COUNT, - DEFAULT_CACHE_CAPACITY, - DEFAULT_IS_HIGH_SPEC), - Arrays.asList(KeyValueSegmentIdentifier.values()), - RocksDBMetricsFactory.PRIVATE_ROCKS_DB_METRICS))) - .withCommonConfiguration(besuConfiguration) - .withMetricsSystem(new NoOpMetricsSystem()) - .build(); - } - - private EnclaveTestHarness selectEnclave( - final EnclaveType enclaveType, - final Path tempDir, - final BesuNodeConfiguration config, - final PrivacyNodeConfiguration privacyConfiguration, - final Optional containerNetwork) { - - switch (enclaveType) { - case ORION: - throw new UnsupportedOperationException("The Orion tests are getting deprecated"); - case TESSERA: - return TesseraTestHarnessFactory.create( - config.getName(), tempDir, privacyConfiguration.getKeyConfig(), containerNetwork); - default: - return new NoopEnclaveTestHarness(tempDir, privacyConfiguration.getKeyConfig()); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivateTransactionGroupResponse.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivateTransactionGroupResponse.java deleted file mode 100644 index 3cd7ca49a49..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivateTransactionGroupResponse.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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.privacy; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class PrivateTransactionGroupResponse { - private final String from; - private final String gas; - private final String gasPrice; - private final String input; - private final String nonce; - private final String to; - private final String value; - private final String v; - private final String r; - private final String s; - private final String privateFrom; - private final String restriction; - private final String privacyGroupId; - - @JsonCreator - public PrivateTransactionGroupResponse( - @JsonProperty("from") final String from, - @JsonProperty("gas") final String gas, - @JsonProperty("gasPrice") final String gasPrice, - @JsonProperty("hash") final String hash, - @JsonProperty("input") final String input, - @JsonProperty("nonce") final String nonce, - @JsonProperty("to") final String to, - @JsonProperty("value") final String value, - @JsonProperty("v") final String v, - @JsonProperty("r") final String r, - @JsonProperty("s") final String s, - @JsonProperty("privateFrom") final String privateFrom, - @JsonProperty("restriction") final String restriction, - @JsonProperty("privacyGroupId") final String privacyGroupId) { - this.from = from; - this.gas = gas; - this.gasPrice = gasPrice; - this.input = input; - this.nonce = nonce; - this.to = to; - this.value = value; - this.v = v; - this.r = r; - this.s = s; - this.privateFrom = privateFrom; - this.restriction = restriction; - this.privacyGroupId = privacyGroupId; - } - - public String getFrom() { - return from; - } - - public String getGas() { - return gas; - } - - public String getGasPrice() { - return gasPrice; - } - - public String getInput() { - return input; - } - - public String getNonce() { - return nonce; - } - - public String getTo() { - return to; - } - - public String getValue() { - return value; - } - - public String getV() { - return v; - } - - public String getR() { - return r; - } - - public String getS() { - return s; - } - - public String getPrivateFrom() { - return privateFrom; - } - - public String getRestriction() { - return restriction; - } - - public String getPrivacyGroupId() { - return privacyGroupId; - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/account/PrivacyAccount.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/account/PrivacyAccount.java deleted file mode 100644 index c246dd585a5..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/account/PrivacyAccount.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.privacy.account; - -import org.hyperledger.enclave.testutil.EnclaveEncryptorType; - -import java.io.File; -import java.net.URL; -import java.util.Arrays; - -public class PrivacyAccount { - - private final URL privateKeyPath; - private final URL[] enclaveKeyPaths; - private final URL[] enclavePrivateKeyPaths; - private final EnclaveEncryptorType enclaveEncryptorType; - - private PrivacyAccount( - final URL privateKeyPath, - final URL[] enclavePublicKeyPaths, - final URL[] enclavePrivateKeyPaths, - final EnclaveEncryptorType enclaveEncryptorType) { - this.privateKeyPath = privateKeyPath; - this.enclaveKeyPaths = enclavePublicKeyPaths; - this.enclavePrivateKeyPaths = enclavePrivateKeyPaths; - this.enclaveEncryptorType = enclaveEncryptorType; - } - - public static PrivacyAccount create( - final URL privateKeyPath, - final URL enclavePublicKeyPath, - final URL enclavePrivateKeyPath, - final EnclaveEncryptorType enclaveEncryptorType) { - return new PrivacyAccount( - privateKeyPath, - new URL[] {enclavePublicKeyPath}, - new URL[] {enclavePrivateKeyPath}, - enclaveEncryptorType); - } - - public static PrivacyAccount create( - final URL privateKeyPath, - final URL[] enclavePublicKeyPath, - final URL[] enclavePrivateKeyPath, - final EnclaveEncryptorType enclaveEncryptorType) { - return new PrivacyAccount( - privateKeyPath, enclavePublicKeyPath, enclavePrivateKeyPath, enclaveEncryptorType); - } - - public String getPrivateKeyPath() { - return toStringResource(privateKeyPath); - } - - public String[] getEnclaveKeyPaths() { - return Arrays.stream(enclaveKeyPaths) - .map(path -> toStringResource(path)) - .toArray(String[]::new); - } - - public String[] getEnclavePrivateKeyPaths() { - return Arrays.stream(enclavePrivateKeyPaths) - .map(path -> toStringResource(path)) - .toArray(String[]::new); - } - - public EnclaveEncryptorType getEnclaveEncryptorType() { - return enclaveEncryptorType; - } - - private String toStringResource(final URL path) { - return path.getPath().substring(path.getPath().lastIndexOf(File.separator) + 1); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/account/PrivacyAccountResolver.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/account/PrivacyAccountResolver.java deleted file mode 100644 index 7a6e26f7bce..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/account/PrivacyAccountResolver.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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.privacy.account; - -import org.hyperledger.enclave.testutil.EnclaveEncryptorType; - -import java.net.URL; - -/** Supplier of known funded accounts defined in dev.json */ -public enum PrivacyAccountResolver { - ALICE { - @Override - public PrivacyAccount resolve(final EnclaveEncryptorType enclaveEncryptorType) { - return PrivacyAccount.create( - resolveResource("key"), - enclaveEncryptorType.equals(EnclaveEncryptorType.EC) - ? resolveResource("enclave_ec_key_0.pub") - : resolveResource("enclave_key_0.pub"), - enclaveEncryptorType.equals(EnclaveEncryptorType.EC) - ? resolveResource("enclave_ec_key_0.key") - : resolveResource("enclave_key_0.key"), - enclaveEncryptorType); - } - }, - BOB { - @Override - public PrivacyAccount resolve(final EnclaveEncryptorType enclaveEncryptorType) { - return PrivacyAccount.create( - resolveResource("key1"), - enclaveEncryptorType.equals(EnclaveEncryptorType.EC) - ? resolveResource("enclave_ec_key_1.pub") - : resolveResource("enclave_key_1.pub"), - enclaveEncryptorType.equals(EnclaveEncryptorType.EC) - ? resolveResource("enclave_ec_key_1.key") - : resolveResource("enclave_key_1.key"), - enclaveEncryptorType); - } - }, - CHARLIE { - @Override - public PrivacyAccount resolve(final EnclaveEncryptorType enclaveEncryptorType) { - return PrivacyAccount.create( - resolveResource("key2"), - enclaveEncryptorType.equals(EnclaveEncryptorType.EC) - ? resolveResource("enclave_ec_key_2.pub") - : resolveResource("enclave_key_2.pub"), - enclaveEncryptorType.equals(EnclaveEncryptorType.EC) - ? resolveResource("enclave_ec_key_2.key") - : resolveResource("enclave_key_2.key"), - enclaveEncryptorType); - } - }, - MULTI_TENANCY { - @Override - public PrivacyAccount resolve(final EnclaveEncryptorType enclaveEncryptorType) { - return PrivacyAccount.create( - resolveResource("key"), - new URL[] { - enclaveEncryptorType.equals(EnclaveEncryptorType.EC) - ? resolveResource("enclave_ec_key_0.pub") - : resolveResource("enclave_key_0.pub"), - enclaveEncryptorType.equals(EnclaveEncryptorType.EC) - ? resolveResource("enclave_ec_key_1.pub") - : resolveResource("enclave_key_1.pub"), - enclaveEncryptorType.equals(EnclaveEncryptorType.EC) - ? resolveResource("enclave_ec_key_2.pub") - : resolveResource("enclave_key_2.pub") - }, - new URL[] { - enclaveEncryptorType.equals(EnclaveEncryptorType.EC) - ? resolveResource("enclave_ec_key_0.key") - : resolveResource("enclave_key_0.key"), - enclaveEncryptorType.equals(EnclaveEncryptorType.EC) - ? resolveResource("enclave_ec_key_1.key") - : resolveResource("enclave_key_1.key"), - enclaveEncryptorType.equals(EnclaveEncryptorType.EC) - ? resolveResource("enclave_ec_key_2.key") - : resolveResource("enclave_key_2.key") - }, - enclaveEncryptorType); - } - }; - - public abstract PrivacyAccount resolve(final EnclaveEncryptorType enclaveEncryptorType); - - URL resolveResource(final String resource) { - return PrivacyAccountResolver.class.getClassLoader().getResource(resource); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectExistingPrivateTransactionReceipt.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectExistingPrivateTransactionReceipt.java deleted file mode 100644 index 7d1c97c13d7..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectExistingPrivateTransactionReceipt.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.privacy.condition; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.PrivacyTransactions; - -import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; - -public class ExpectExistingPrivateTransactionReceipt implements PrivateCondition { - private final PrivacyTransactions transactions; - private final String transactionHash; - - public ExpectExistingPrivateTransactionReceipt( - final PrivacyTransactions transactions, final String transactionHash) { - - this.transactions = transactions; - this.transactionHash = transactionHash; - } - - @Override - public void verify(final PrivacyNode node) { - final PrivateTransactionReceipt privateTransactionReceipt = - node.execute(transactions.getPrivateTransactionReceipt(transactionHash)); - assertThat(privateTransactionReceipt).isNotNull(); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectInternalErrorPrivateTransactionReceipt.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectInternalErrorPrivateTransactionReceipt.java deleted file mode 100644 index 450be72d427..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectInternalErrorPrivateTransactionReceipt.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.privacy.condition; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.PrivacyTransactions; - -public class ExpectInternalErrorPrivateTransactionReceipt implements PrivateCondition { - private final PrivacyTransactions transactions; - private final String transactionHash; - - public ExpectInternalErrorPrivateTransactionReceipt( - final PrivacyTransactions transactions, final String transactionHash) { - this.transactions = transactions; - this.transactionHash = transactionHash; - } - - @Override - public void verify(final PrivacyNode node) { - try { - node.execute(transactions.getPrivateTransactionReceipt(transactionHash)); - } catch (final RuntimeException e) { - assertThat(e.getMessage()).contains("Internal error"); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectNoPrivateTransactionReceipt.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectNoPrivateTransactionReceipt.java deleted file mode 100644 index d14d0dde736..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectNoPrivateTransactionReceipt.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.privacy.condition; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.catchThrowable; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.PrivacyTransactions; - -public class ExpectNoPrivateTransactionReceipt implements PrivateCondition { - private final PrivacyTransactions transactions; - private final String transactionHash; - - public ExpectNoPrivateTransactionReceipt( - final PrivacyTransactions transactions, final String transactionHash) { - this.transactions = transactions; - this.transactionHash = transactionHash; - } - - @Override - public void verify(final PrivacyNode node) { - final Throwable t = - catchThrowable( - () -> node.execute(transactions.getPrivateTransactionReceipt(transactionHash))); - - assertThat(t).hasMessageContaining("TransactionException"); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidContractCode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidContractCode.java deleted file mode 100644 index 574ace120da..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidContractCode.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.privacy.condition; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; - -import org.web3j.tx.Contract; - -public class ExpectValidContractCode implements PrivateContractCondition { - @Override - public void verify(final Contract contract) throws IOException { - assertThat(contract).isNotNull(); - assertThat(contract.isValid()).isEqualTo(true); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidFlexiblePrivacyGroupCreated.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidFlexiblePrivacyGroupCreated.java deleted file mode 100644 index ce9c93d23d6..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidFlexiblePrivacyGroupCreated.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.privacy.condition; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.PrivacyTransactions; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory; - -import java.util.List; -import java.util.concurrent.TimeUnit; - -import org.awaitility.Awaitility; -import org.web3j.utils.Base64String; - -public class ExpectValidFlexiblePrivacyGroupCreated implements PrivateCondition { - - private final PrivacyTransactions transactions; - private final PrivacyRequestFactory.FlexiblePrivacyGroup expected; - - public ExpectValidFlexiblePrivacyGroupCreated( - final PrivacyTransactions transactions, - final PrivacyRequestFactory.FlexiblePrivacyGroup expected) { - this.transactions = transactions; - this.expected = expected; - } - - @Override - public void verify(final PrivacyNode node) { - Awaitility.waitAtMost(20, TimeUnit.SECONDS) - .untilAsserted( - () -> { - final List groups = - node.execute( - transactions.findFlexiblePrivacyGroup( - Base64String.unwrapList(expected.getMembers()))); - assertThat(groups).contains(expected); - }); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidPrivacyGroupCreated.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidPrivacyGroupCreated.java deleted file mode 100644 index 813050cc588..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidPrivacyGroupCreated.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.privacy.condition; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.PrivacyTransactions; - -import java.util.List; - -import org.awaitility.Awaitility; -import org.web3j.protocol.besu.response.privacy.PrivacyGroup; -import org.web3j.utils.Base64String; - -public class ExpectValidPrivacyGroupCreated implements PrivateCondition { - - private final PrivacyTransactions transactions; - private final PrivacyGroup expected; - - public ExpectValidPrivacyGroupCreated( - final PrivacyTransactions transactions, final PrivacyGroup expected) { - this.transactions = transactions; - this.expected = expected; - } - - @Override - public void verify(final PrivacyNode node) { - Awaitility.await() - .untilAsserted( - () -> { - final List groups = - node.execute( - transactions.findPrivacyGroup( - Base64String.unwrapList(expected.getMembers()))); - assertThat(groups).contains(expected); - }); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidPrivateContractDeployedReceipt.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidPrivateContractDeployedReceipt.java deleted file mode 100644 index 687d6360c2d..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidPrivateContractDeployedReceipt.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.privacy.condition; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Optional; - -import org.web3j.protocol.core.methods.response.TransactionReceipt; -import org.web3j.tx.Contract; - -public class ExpectValidPrivateContractDeployedReceipt implements PrivateContractCondition { - - private final String contractAddress; - private final String senderAddress; - - public ExpectValidPrivateContractDeployedReceipt( - final String contractAddress, final String senderAddress) { - this.contractAddress = contractAddress; - this.senderAddress = senderAddress; - } - - @Override - public void verify(final Contract contract) { - - assertThat(contract).isNotNull(); - final Optional receipt = contract.getTransactionReceipt(); - - // We're expecting a receipt - assertThat(receipt).isNotNull(); - assertThat(receipt.isPresent()).isTrue(); - final TransactionReceipt transactionReceipt = receipt.get(); - - assertThat(transactionReceipt.isStatusOK()).isTrue(); - - // Contract transaction has no 'to' address or contract address - assertThat(transactionReceipt.getTo()).isNull(); - - // Address generation is deterministic, based on the sender address and the transaction nonce - assertThat(transactionReceipt.getContractAddress()).isEqualTo(contractAddress); - - // Address for the account that signed (and paid) for the contract deployment transaction - assertThat(transactionReceipt.getFrom()).isEqualTo(senderAddress); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidPrivateTransactionReceipt.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidPrivateTransactionReceipt.java deleted file mode 100644 index ff8e0c2c5f4..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/ExpectValidPrivateTransactionReceipt.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.privacy.condition; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.PrivacyTransactions; - -import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; - -public class ExpectValidPrivateTransactionReceipt implements PrivateCondition { - private final PrivacyTransactions transactions; - private final String transactionHash; - private final PrivateTransactionReceipt expectedReceipt; - private final boolean ignoreOutput; - - public ExpectValidPrivateTransactionReceipt( - final PrivacyTransactions transactions, - final String transactionHash, - final PrivateTransactionReceipt expectedReceipt) { - this(transactions, transactionHash, expectedReceipt, false); - } - - public ExpectValidPrivateTransactionReceipt( - final PrivacyTransactions transactions, - final String transactionHash, - final PrivateTransactionReceipt expectedReceipt, - final boolean ignoreOutput) { - - this.transactions = transactions; - this.transactionHash = transactionHash; - this.expectedReceipt = expectedReceipt; - this.ignoreOutput = ignoreOutput; - } - - @Override - public void verify(final PrivacyNode node) { - final PrivateTransactionReceipt actualReceipt = - node.execute(transactions.getPrivateTransactionReceipt(transactionHash)); - if (ignoreOutput) { - // output can be ignored if it is checked separately - assertThat(actualReceipt) - .usingRecursiveComparison() - .ignoringFields( - "commitmentHash", - "logs", - "blockHash", - "blockNumber", - "logsBloom", - "transactionIndex", - "output") - // TODO: The fields blockHash, blockNumber, logsBloom, transactionIndex and output have to - // be ignored as - // the class org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt does not - // contain - // these fields. Once web3j has been updated these ignores can be removed. - .isEqualTo(expectedReceipt); - } else { - assertThat(actualReceipt) - .usingRecursiveComparison() - .ignoringFields( - "commitmentHash", "logs", "blockHash", "blockNumber", "logsBloom", "transactionIndex") - // TODO: The fields blockHash, blockNumber, logsBloom and transactionIndex have to be - // ignored as the class - // org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt does not contain - // these fields. Once web3j has been updated these ignores can be removed. - .isEqualTo(expectedReceipt); - } - assertThat(actualReceipt.getLogs().size()).isEqualTo(expectedReceipt.getLogs().size()); - - for (int i = 0; i < expectedReceipt.getLogs().size(); i++) { - assertThat(actualReceipt.getLogs().get(i)) - .usingRecursiveComparison() - .ignoringFields("blockHash", "blockNumber") - .isEqualTo(expectedReceipt.getLogs().get(i)); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivGetTransactionReceiptTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivGetTransactionReceiptTransaction.java deleted file mode 100644 index b5922b25b0f..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivGetTransactionReceiptTransaction.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.privacy.condition; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -import org.web3j.protocol.besu.Besu; -import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; -import org.web3j.protocol.exceptions.TransactionException; -import org.web3j.tx.response.PollingPrivateTransactionReceiptProcessor; - -public class PrivGetTransactionReceiptTransaction - implements Transaction { - - private final String transactionHash; - - public PrivGetTransactionReceiptTransaction(final String transactionHash) { - this.transactionHash = transactionHash; - } - - @Override - public PrivateTransactionReceipt execute(final NodeRequests node) { - final Besu besu = node.privacy().getBesuClient(); - final PollingPrivateTransactionReceiptProcessor receiptProcessor = - new PollingPrivateTransactionReceiptProcessor(besu, 1000, 15); - try { - final PrivateTransactionReceipt result = - receiptProcessor.waitForTransactionReceipt(transactionHash); - assertThat(result).isNotNull(); - return result; - } catch (final IOException | TransactionException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateCondition.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateCondition.java deleted file mode 100644 index 873f015a499..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateCondition.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.privacy.condition; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; - -public interface PrivateCondition { - void verify(PrivacyNode node); -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateContractCondition.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateContractCondition.java deleted file mode 100644 index 7969e2d3576..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateContractCondition.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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.privacy.condition; - -import java.io.IOException; - -import org.web3j.tx.Contract; - -public interface PrivateContractCondition { - void verify(final Contract contract) throws IOException; -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateContractVerifier.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateContractVerifier.java deleted file mode 100644 index de9f36d08d7..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateContractVerifier.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.privacy.condition; - -public class PrivateContractVerifier { - - public PrivateContractVerifier() {} - - public ExpectValidPrivateContractDeployedReceipt validPrivateContractDeployed( - final String contractAddress, final String senderAddress) { - return new ExpectValidPrivateContractDeployedReceipt(contractAddress, senderAddress); - } - - public ExpectValidContractCode validContractCodeProvided() { - return new ExpectValidContractCode(); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateTransactionVerifier.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateTransactionVerifier.java deleted file mode 100644 index cfd83b65821..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/condition/PrivateTransactionVerifier.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.privacy.condition; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.PrivacyTransactions; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory.FlexiblePrivacyGroup; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import org.web3j.protocol.besu.response.privacy.PrivacyGroup; -import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; -import org.web3j.utils.Base64String; - -public class PrivateTransactionVerifier { - - private final PrivacyTransactions transactions; - - public PrivateTransactionVerifier(final PrivacyTransactions transactions) { - this.transactions = transactions; - } - - public ExpectValidPrivateTransactionReceipt validPrivateTransactionReceipt( - final String transactionHash, final PrivateTransactionReceipt receipt) { - return new ExpectValidPrivateTransactionReceipt(transactions, transactionHash, receipt); - } - - public ExpectValidPrivateTransactionReceipt validPrivateTransactionReceipt( - final String transactionHash, - final PrivateTransactionReceipt receipt, - final boolean ignoreOutput) { - return new ExpectValidPrivateTransactionReceipt( - transactions, transactionHash, receipt, ignoreOutput); - } - - public ExpectExistingPrivateTransactionReceipt existingPrivateTransactionReceipt( - final String transactionHash) { - return new ExpectExistingPrivateTransactionReceipt(transactions, transactionHash); - } - - public ExpectNoPrivateTransactionReceipt noPrivateTransactionReceipt( - final String transactionHash) { - return new ExpectNoPrivateTransactionReceipt(transactions, transactionHash); - } - - public ExpectValidPrivacyGroupCreated validPrivacyGroupCreated(final PrivacyGroup expected) { - return new ExpectValidPrivacyGroupCreated(transactions, expected); - } - - public ExpectValidFlexiblePrivacyGroupCreated flexiblePrivacyGroupExists( - final String privacyGroupId, final PrivacyNode... members) { - - final List membersEnclaveKeys = - Arrays.stream(members) - .map(PrivacyNode::getEnclaveKey) - .map(Base64String::wrap) - .collect(Collectors.toList()); - return flexiblePrivacyGroupExists(privacyGroupId, membersEnclaveKeys); - } - - public ExpectValidFlexiblePrivacyGroupCreated flexiblePrivacyGroupExists( - final String privacyGroupId, final List membersEnclaveKeys) { - - final FlexiblePrivacyGroup expectedGroup = - new FlexiblePrivacyGroup(privacyGroupId, membersEnclaveKeys); - - return new ExpectValidFlexiblePrivacyGroupCreated(transactions, expectedGroup); - } - - public ExpectInternalErrorPrivateTransactionReceipt internalErrorPrivateTransactionReceipt( - final String transactionHash) { - return new ExpectInternalErrorPrivateTransactionReceipt(transactions, transactionHash); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/CallOnchainPermissioningPrivateSmartContractFunction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/CallOnchainPermissioningPrivateSmartContractFunction.java deleted file mode 100644 index 0820d65d1d5..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/CallOnchainPermissioningPrivateSmartContractFunction.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.privacy.contract; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; -import java.math.BigInteger; - -import org.web3j.crypto.Credentials; -import org.web3j.tx.PrivateTransactionManager; -import org.web3j.tx.gas.BesuPrivacyGasProvider; -import org.web3j.utils.Base64String; -import org.web3j.utils.Restriction; - -public class CallOnchainPermissioningPrivateSmartContractFunction implements Transaction { - - private static final BesuPrivacyGasProvider GAS_PROVIDER = - new BesuPrivacyGasProvider(BigInteger.valueOf(1000)); - private final String contractAddress; - private final String encodedFunction; - private final Credentials senderCredentials; - private final Base64String privateFrom; - private final Base64String privacyGroupId; - - public CallOnchainPermissioningPrivateSmartContractFunction( - final String contractAddress, - final String encodedFunction, - final String transactionSigningKey, - final String privateFrom, - final String privacyGroupId) { - - this.contractAddress = contractAddress; - this.encodedFunction = encodedFunction; - this.senderCredentials = Credentials.create(transactionSigningKey); - this.privateFrom = Base64String.wrap(privateFrom); - this.privacyGroupId = Base64String.wrap(privacyGroupId); - } - - @Override - public String execute(final NodeRequests node) { - final PrivateTransactionManager privateTransactionManager = - node.privacy() - .getTransactionManager( - senderCredentials, privateFrom, privacyGroupId, Restriction.RESTRICTED); - - try { - return privateTransactionManager - .sendTransaction( - GAS_PROVIDER.getGasPrice(), - GAS_PROVIDER.getGasLimit(), - contractAddress, - encodedFunction, - null) - .getTransactionHash(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/CallPrivateSmartContractFunction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/CallPrivateSmartContractFunction.java deleted file mode 100644 index d3ec7989e5e..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/CallPrivateSmartContractFunction.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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.privacy.contract; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; -import java.math.BigInteger; -import java.util.List; - -import org.web3j.crypto.Credentials; -import org.web3j.tx.PrivateTransactionManager; -import org.web3j.tx.gas.BesuPrivacyGasProvider; -import org.web3j.utils.Base64String; -import org.web3j.utils.Restriction; - -public class CallPrivateSmartContractFunction implements Transaction { - - private static final BesuPrivacyGasProvider GAS_PROVIDER = - new BesuPrivacyGasProvider(BigInteger.valueOf(1000)); - private final String contractAddress; - private final String encodedFunction; - private final Credentials senderCredentials; - private final Restriction restriction; - private final Base64String privateFrom; - private final List privateFor; - private final Base64String privacyGroupId; - - public CallPrivateSmartContractFunction( - final String contractAddress, - final String encodedFunction, - final String transactionSigningKey, - final Restriction restriction, - final String privateFrom, - final List privateFor) { - this( - contractAddress, - encodedFunction, - transactionSigningKey, - restriction, - privateFrom, - privateFor, - null); - } - - public CallPrivateSmartContractFunction( - final String contractAddress, - final String encodedFunction, - final String transactionSigningKey, - final Restriction restriction, - final String privateFrom, - final String privacyGroupId) { - this( - contractAddress, - encodedFunction, - transactionSigningKey, - restriction, - privateFrom, - null, - privacyGroupId); - } - - private CallPrivateSmartContractFunction( - final String contractAddress, - final String encodedFunction, - final String transactionSigningKey, - final Restriction restriction, - final String privateFrom, - final List privateFor, - final String privacyGroupId) { - - this.contractAddress = contractAddress; - this.encodedFunction = encodedFunction; - this.senderCredentials = Credentials.create(transactionSigningKey); - this.restriction = restriction; - this.privateFrom = Base64String.wrap(privateFrom); - this.privateFor = privateFor != null ? Base64String.wrapList(privateFor) : null; - this.privacyGroupId = privacyGroupId != null ? Base64String.wrap(privacyGroupId) : null; - } - - @Override - public String execute(final NodeRequests node) { - final PrivateTransactionManager privateTransactionManager; - - if (privateFor != null) { - privateTransactionManager = - node.privacy() - .getTransactionManager(senderCredentials, privateFrom, privateFor, restriction); - } else { - privateTransactionManager = - node.privacy() - .getTransactionManager(senderCredentials, privateFrom, privacyGroupId, restriction); - } - - try { - return privateTransactionManager - .sendTransaction( - GAS_PROVIDER.getGasPrice(), - GAS_PROVIDER.getGasLimit(), - contractAddress, - encodedFunction, - null) - .getTransactionHash(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/DeployPrivateSmartContractTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/DeployPrivateSmartContractTransaction.java deleted file mode 100644 index ed7ca9cd9af..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/DeployPrivateSmartContractTransaction.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.privacy.contract; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.lang.reflect.Method; -import java.math.BigInteger; -import java.util.List; - -import org.web3j.crypto.Credentials; -import org.web3j.protocol.Web3j; -import org.web3j.protocol.core.RemoteCall; -import org.web3j.tx.Contract; -import org.web3j.tx.PrivateTransactionManager; -import org.web3j.tx.TransactionManager; -import org.web3j.tx.gas.BesuPrivacyGasProvider; -import org.web3j.tx.gas.ContractGasProvider; -import org.web3j.utils.Base64String; -import org.web3j.utils.Restriction; - -public class DeployPrivateSmartContractTransaction implements Transaction { - - private static final BesuPrivacyGasProvider GAS_PROVIDER = - new BesuPrivacyGasProvider(BigInteger.valueOf(1000)); - private static final Object METHOD_IS_STATIC = null; - - private final Class clazz; - private final Credentials senderCredentials; - private final Base64String privateFrom; - private final List privateFor; - - public DeployPrivateSmartContractTransaction( - final Class clazz, - final String transactionSigningKey, - final String privateFrom, - final List privateFor) { - this.clazz = clazz; - this.senderCredentials = Credentials.create(transactionSigningKey); - this.privateFrom = Base64String.wrap(privateFrom); - this.privateFor = Base64String.wrapList(privateFor); - } - - @Override - public T execute(final NodeRequests node) { - - final PrivateTransactionManager privateTransactionManager = - node.privacy() - .getTransactionManager( - senderCredentials, privateFrom, privateFor, Restriction.RESTRICTED); - - try { - final Method method = - clazz.getMethod( - "deploy", Web3j.class, TransactionManager.class, ContractGasProvider.class); - - final Object invoked = - method.invoke( - METHOD_IS_STATIC, - node.privacy().getBesuClient(), - privateTransactionManager, - GAS_PROVIDER); - - return cast(invoked).send(); - } catch (final Exception e) { - throw new RuntimeException(e); - } - } - - @SuppressWarnings("unchecked") - private RemoteCall cast(final Object invokedMethod) { - return (RemoteCall) invokedMethod; - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/DeployPrivateSmartContractWithPrivacyGroupIdTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/DeployPrivateSmartContractWithPrivacyGroupIdTransaction.java deleted file mode 100644 index c5d0116431a..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/DeployPrivateSmartContractWithPrivacyGroupIdTransaction.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.privacy.contract; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.lang.reflect.Method; -import java.math.BigInteger; - -import org.web3j.crypto.Credentials; -import org.web3j.protocol.Web3j; -import org.web3j.protocol.core.RemoteCall; -import org.web3j.tx.Contract; -import org.web3j.tx.PrivateTransactionManager; -import org.web3j.tx.TransactionManager; -import org.web3j.tx.gas.BesuPrivacyGasProvider; -import org.web3j.tx.gas.ContractGasProvider; -import org.web3j.utils.Base64String; -import org.web3j.utils.Restriction; - -public class DeployPrivateSmartContractWithPrivacyGroupIdTransaction - implements Transaction { - - private static final BesuPrivacyGasProvider GAS_PROVIDER = - new BesuPrivacyGasProvider(BigInteger.valueOf(1000)); - private static final Object METHOD_IS_STATIC = null; - - private final Class clazz; - private final Credentials senderCredentials; - private final Restriction restriction; - private final Base64String privateFrom; - private final Base64String privacyGroupId; - - public DeployPrivateSmartContractWithPrivacyGroupIdTransaction( - final Class clazz, - final String transactionSigningKey, - final Restriction restriction, - final String privateFrom, - final String privacyGroupId) { - this.clazz = clazz; - this.senderCredentials = Credentials.create(transactionSigningKey); - this.restriction = restriction; - this.privateFrom = Base64String.wrap(privateFrom); - this.privacyGroupId = Base64String.wrap(privacyGroupId); - } - - @Override - public T execute(final NodeRequests node) { - - final PrivateTransactionManager privateTransactionManager = - node.privacy() - .getTransactionManager(senderCredentials, privateFrom, privacyGroupId, restriction); - - try { - final Method method = - clazz.getMethod( - "deploy", Web3j.class, TransactionManager.class, ContractGasProvider.class); - - final Object invoked = - method.invoke( - METHOD_IS_STATIC, - node.privacy().getBesuClient(), - privateTransactionManager, - GAS_PROVIDER); - - return cast(invoked).send(); - } catch (final Exception e) { - throw new RuntimeException(e); - } - } - - @SuppressWarnings("unchecked") - private RemoteCall cast(final Object invokedMethod) { - return (RemoteCall) invokedMethod; - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/LoadPrivateSmartContractTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/LoadPrivateSmartContractTransaction.java deleted file mode 100644 index aac5f293f9b..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/LoadPrivateSmartContractTransaction.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.privacy.contract; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.lang.reflect.Method; -import java.math.BigInteger; -import java.util.List; - -import org.web3j.crypto.Credentials; -import org.web3j.protocol.Web3j; -import org.web3j.tx.Contract; -import org.web3j.tx.PrivateTransactionManager; -import org.web3j.tx.TransactionManager; -import org.web3j.tx.gas.BesuPrivacyGasProvider; -import org.web3j.tx.gas.ContractGasProvider; -import org.web3j.utils.Base64String; -import org.web3j.utils.Restriction; - -public class LoadPrivateSmartContractTransaction implements Transaction { - private static final BesuPrivacyGasProvider GAS_PROVIDER = - new BesuPrivacyGasProvider(BigInteger.valueOf(1000)); - private static final Object METHOD_IS_STATIC = null; - - private final Class clazz; - private final Credentials senderCredentials; - private final Base64String privateFrom; - private final List privateFor; - private final String contractAddress; - - public LoadPrivateSmartContractTransaction( - final String contractAddress, - final Class clazz, - final String transactionSigningKey, - final String privateFrom, - final List privateFor) { - - this.contractAddress = contractAddress; - this.clazz = clazz; - this.senderCredentials = Credentials.create(transactionSigningKey); - this.privateFrom = Base64String.wrap(privateFrom); - this.privateFor = Base64String.wrapList(privateFor); - } - - @SuppressWarnings("unchecked") - @Override - public T execute(final NodeRequests node) { - final PrivateTransactionManager privateTransactionManager = - node.privacy() - .getTransactionManager( - senderCredentials, privateFrom, privateFor, Restriction.RESTRICTED); - - try { - final Method method = - clazz.getMethod( - "load", - String.class, - Web3j.class, - TransactionManager.class, - ContractGasProvider.class); - - return (T) - method.invoke( - METHOD_IS_STATIC, - contractAddress, - node.privacy().getBesuClient(), - privateTransactionManager, - GAS_PROVIDER); - } catch (final Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/LoadPrivateSmartContractTransactionWithPrivacyGroupId.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/LoadPrivateSmartContractTransactionWithPrivacyGroupId.java deleted file mode 100644 index 11a5045752c..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/LoadPrivateSmartContractTransactionWithPrivacyGroupId.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.privacy.contract; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.lang.reflect.Method; -import java.math.BigInteger; - -import org.web3j.crypto.Credentials; -import org.web3j.protocol.Web3j; -import org.web3j.tx.Contract; -import org.web3j.tx.PrivateTransactionManager; -import org.web3j.tx.TransactionManager; -import org.web3j.tx.gas.BesuPrivacyGasProvider; -import org.web3j.tx.gas.ContractGasProvider; -import org.web3j.utils.Base64String; -import org.web3j.utils.Restriction; - -public class LoadPrivateSmartContractTransactionWithPrivacyGroupId - implements Transaction { - - private static final BesuPrivacyGasProvider GAS_PROVIDER = - new BesuPrivacyGasProvider(BigInteger.valueOf(1000)); - private static final Object METHOD_IS_STATIC = null; - - private final Class clazz; - private final Credentials senderCredentials; - private final Base64String privateFrom; - private final Base64String privacyGroupId; - private final String contractAddress; - - public LoadPrivateSmartContractTransactionWithPrivacyGroupId( - final String contractAddress, - final Class clazz, - final String transactionSigningKey, - final String privateFrom, - final String privacyGroupId) { - - this.contractAddress = contractAddress; - this.clazz = clazz; - this.senderCredentials = Credentials.create(transactionSigningKey); - this.privateFrom = Base64String.wrap(privateFrom); - this.privacyGroupId = Base64String.wrap(privacyGroupId); - } - - @SuppressWarnings("unchecked") - @Override - public T execute(final NodeRequests node) { - final PrivateTransactionManager privateTransactionManager = - node.privacy() - .getTransactionManager( - senderCredentials, privateFrom, privacyGroupId, Restriction.RESTRICTED); - - try { - final Method method = - clazz.getMethod( - "load", - String.class, - Web3j.class, - TransactionManager.class, - ContractGasProvider.class); - - return (T) - method.invoke( - METHOD_IS_STATIC, - contractAddress, - node.privacy().getBesuClient(), - privateTransactionManager, - GAS_PROVIDER); - } catch (final Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/PrivateContractTransactions.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/PrivateContractTransactions.java deleted file mode 100644 index 97e7e654018..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/PrivateContractTransactions.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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.privacy.contract; - -import java.util.Arrays; -import java.util.List; - -import org.web3j.tx.Contract; -import org.web3j.utils.Restriction; - -public class PrivateContractTransactions { - - public - DeployPrivateSmartContractWithPrivacyGroupIdTransaction - createSmartContractWithPrivacyGroupId( - final Class clazz, - final String transactionSigningKey, - final Restriction restriction, - final String privateFrom, - final String privacyGroupId) { - return new DeployPrivateSmartContractWithPrivacyGroupIdTransaction<>( - clazz, transactionSigningKey, restriction, privateFrom, privacyGroupId); - } - - public - DeployPrivateSmartContractWithPrivacyGroupIdTransaction - createSmartContractWithPrivacyGroupId( - final Class clazz, - final String transactionSigningKey, - final String privateFrom, - final String privacyGroupId) { - return new DeployPrivateSmartContractWithPrivacyGroupIdTransaction<>( - clazz, transactionSigningKey, Restriction.RESTRICTED, privateFrom, privacyGroupId); - } - - public DeployPrivateSmartContractTransaction createSmartContract( - final Class clazz, - final String transactionSigningKey, - final String privateFrom, - final String... privateFor) { - return createSmartContract( - clazz, transactionSigningKey, privateFrom, Arrays.asList(privateFor)); - } - - public DeployPrivateSmartContractTransaction createSmartContract( - final Class clazz, - final String transactionSigningKey, - final String privateFrom, - final List privateFor) { - return new DeployPrivateSmartContractTransaction<>( - clazz, transactionSigningKey, privateFrom, privateFor); - } - - public CallPrivateSmartContractFunction callSmartContract( - final String contractAddress, - final String encodedFunction, - final String transactionSigningKey, - final Restriction restriction, - final String privateFrom, - final String... privateFor) { - return callSmartContract( - contractAddress, - encodedFunction, - transactionSigningKey, - restriction, - privateFrom, - Arrays.asList(privateFor)); - } - - public CallPrivateSmartContractFunction callSmartContract( - final String contractAddress, - final String encodedFunction, - final String transactionSigningKey, - final Restriction restriction, - final String privateFrom, - final List privateFor) { - return new CallPrivateSmartContractFunction( - contractAddress, - encodedFunction, - transactionSigningKey, - restriction, - privateFrom, - privateFor); - } - - public CallPrivateSmartContractFunction callSmartContractWithPrivacyGroupId( - final String contractAddress, - final String encodedFunction, - final String transactionSigningKey, - final Restriction restriction, - final String privateFrom, - final String privacyGroupId) { - return new CallPrivateSmartContractFunction( - contractAddress, - encodedFunction, - transactionSigningKey, - restriction, - privateFrom, - privacyGroupId); - } - - public LoadPrivateSmartContractTransaction loadSmartContract( - final String contractAddress, - final Class clazz, - final String transactionSigningKey, - final String privateFrom, - final String... privateFor) { - return loadSmartContract( - contractAddress, clazz, transactionSigningKey, privateFrom, Arrays.asList(privateFor)); - } - - public LoadPrivateSmartContractTransaction loadSmartContract( - final String contractAddress, - final Class clazz, - final String transactionSigningKey, - final String privateFrom, - final List privateFor) { - return new LoadPrivateSmartContractTransaction<>( - contractAddress, clazz, transactionSigningKey, privateFrom, privateFor); - } - - public - LoadPrivateSmartContractTransactionWithPrivacyGroupId loadSmartContractWithPrivacyGroupId( - final String contractAddress, - final Class clazz, - final String transactionSigningKey, - final String privateFrom, - final String privacyGroupId) { - return new LoadPrivateSmartContractTransactionWithPrivacyGroupId<>( - contractAddress, clazz, transactionSigningKey, privateFrom, privacyGroupId); - } - - public CallOnchainPermissioningPrivateSmartContractFunction callOnchainPermissioningSmartContract( - final String contractAddress, - final String encodedFunction, - final String transactionSigningKey, - final String privateFrom, - final String privacyGroupId) { - return new CallOnchainPermissioningPrivateSmartContractFunction( - contractAddress, encodedFunction, transactionSigningKey, privateFrom, privacyGroupId); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/AddToFlexiblePrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/AddToFlexiblePrivacyGroupTransaction.java deleted file mode 100644 index 9c879bc421c..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/AddToFlexiblePrivacyGroupTransaction.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.privacy.transaction; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import org.web3j.crypto.Credentials; -import org.web3j.utils.Base64String; - -public class AddToFlexiblePrivacyGroupTransaction implements Transaction { - private final Base64String privacyGroupId; - private final PrivacyNode adder; - private final List addresses; - private final Credentials signer; - - public AddToFlexiblePrivacyGroupTransaction( - final String privacyGroupId, - final PrivacyNode adder, - final Credentials signer, - final PrivacyNode... nodes) { - this.privacyGroupId = Base64String.wrap(privacyGroupId); - this.adder = adder; - this.signer = signer; - this.addresses = - Arrays.stream(nodes) - .map(n -> n.getEnclave().getDefaultPublicKey()) - .collect(Collectors.toList()); - } - - @Override - public String execute(final NodeRequests node) { - try { - return node.privacy().privxAddToPrivacyGroup(privacyGroupId, adder, signer, addresses); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/CreateFlexiblePrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/CreateFlexiblePrivacyGroupTransaction.java deleted file mode 100644 index bf2814a4b15..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/CreateFlexiblePrivacyGroupTransaction.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.privacy.transaction; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory.PrivxCreatePrivacyGroupResponse; - -import java.io.IOException; -import java.util.List; - -public class CreateFlexiblePrivacyGroupTransaction - implements Transaction { - private final PrivacyNode creator; - private final List addresses; - private final String privateFrom; - - CreateFlexiblePrivacyGroupTransaction( - final PrivacyNode creator, final String privateFrom, final List addresses) { - this.creator = creator; - this.addresses = addresses; - this.privateFrom = privateFrom; - } - - @Override - public PrivxCreatePrivacyGroupResponse execute(final NodeRequests node) { - try { - return node.privacy().privxCreatePrivacyGroup(creator, privateFrom, addresses); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindFlexiblePrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindFlexiblePrivacyGroupTransaction.java deleted file mode 100644 index 0e8ac95b4f6..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindFlexiblePrivacyGroupTransaction.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.privacy.transaction; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory.PrivxFindPrivacyGroupResponse; - -import java.io.IOException; -import java.util.List; -import java.util.stream.Collectors; - -import org.web3j.utils.Base64String; - -public class FindFlexiblePrivacyGroupTransaction - implements Transaction> { - private final List nodes; - - public FindFlexiblePrivacyGroupTransaction(final List nodeEnclaveKeys) { - this.nodes = nodeEnclaveKeys.stream().map(Base64String::wrap).collect(Collectors.toList()); - } - - @Override - public List execute(final NodeRequests node) { - try { - PrivxFindPrivacyGroupResponse result = - node.privacy().privxFindFlexiblePrivacyGroup(nodes).send(); - assertThat(result).isNotNull(); - if (result.hasError()) { - throw new RuntimeException(result.getError().getMessage()); - } - return result.getGroups(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindPrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindPrivacyGroupTransaction.java deleted file mode 100644 index 0b15b4c0c80..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindPrivacyGroupTransaction.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.privacy.transaction; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; -import java.util.List; -import java.util.stream.Collectors; - -import org.web3j.protocol.besu.Besu; -import org.web3j.protocol.besu.response.privacy.PrivacyGroup; -import org.web3j.utils.Base64String; - -public class FindPrivacyGroupTransaction implements Transaction> { - private final List nodes; - - public FindPrivacyGroupTransaction(final List nodeEnclaveKeys) { - - this.nodes = nodeEnclaveKeys.stream().map(Base64String::wrap).collect(Collectors.toList()); - } - - @Override - public List execute(final NodeRequests node) { - final Besu besu = node.privacy().getBesuClient(); - try { - return besu.privFindPrivacyGroup(nodes).send().getGroups(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/GetAllPrivateMarkerTransactionHashes.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/GetAllPrivateMarkerTransactionHashes.java deleted file mode 100644 index d0056f50b43..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/GetAllPrivateMarkerTransactionHashes.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.privacy.transaction; - -import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; - -import org.web3j.protocol.besu.Besu; -import org.web3j.protocol.core.DefaultBlockParameter; -import org.web3j.protocol.core.methods.response.EthBlock; - -public class GetAllPrivateMarkerTransactionHashes implements Transaction> { - @Override - public List execute(final NodeRequests node) { - final Besu besu = node.privacy().getBesuClient(); - final List toReturn = new ArrayList<>(); - try { - final long blockchainHeight = besu.ethBlockNumber().send().getBlockNumber().longValueExact(); - for (long i = 0; i <= blockchainHeight; i++) { - besu.ethGetBlockByNumber(DefaultBlockParameter.valueOf(BigInteger.valueOf(i)), true) - .send() - .getBlock() - .getTransactions() - .forEach( - t -> { - if (((EthBlock.TransactionObject) t).getTo().equals(DEFAULT_PRIVACY.toString())) { - toReturn.add(((EthBlock.TransactionObject) t).getHash()); - } - }); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - - return toReturn; - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/LockFlexiblePrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/LockFlexiblePrivacyGroupTransaction.java deleted file mode 100644 index 92ed003ad43..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/LockFlexiblePrivacyGroupTransaction.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.privacy.transaction; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -import org.web3j.crypto.Credentials; -import org.web3j.protocol.exceptions.TransactionException; -import org.web3j.utils.Base64String; - -public class LockFlexiblePrivacyGroupTransaction implements Transaction { - private final Base64String privacyGroupId; - private final PrivacyNode locker; - private final Credentials signer; - - public LockFlexiblePrivacyGroupTransaction( - final String privacyGroupId, final PrivacyNode locker, final Credentials signer) { - this.privacyGroupId = Base64String.wrap(privacyGroupId); - this.locker = locker; - this.signer = signer; - } - - @Override - public String execute(final NodeRequests node) { - try { - return node.privacy().privxLockPrivacyGroup(locker, privacyGroupId, signer); - } catch (final IOException | TransactionException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PluginCreateRandomPrivacyGroupIdTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PluginCreateRandomPrivacyGroupIdTransaction.java deleted file mode 100644 index 180764449f7..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PluginCreateRandomPrivacyGroupIdTransaction.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.privacy.transaction; - -import org.hyperledger.besu.crypto.SecureRandomProvider; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import org.apache.tuweni.bytes.Bytes; - -public class PluginCreateRandomPrivacyGroupIdTransaction implements Transaction { - - @Override - public String execute(final NodeRequests node) { - final byte[] bytes = new byte[32]; - SecureRandomProvider.createSecureRandom().nextBytes(bytes); - return Bytes.wrap(bytes).toBase64String(); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivDistributeTransactionTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivDistributeTransactionTransaction.java deleted file mode 100644 index 60f0a746a99..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivDistributeTransactionTransaction.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.privacy.transaction; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -public class PrivDistributeTransactionTransaction implements Transaction { - private final String signedPrivateTransaction; - - public PrivDistributeTransactionTransaction(final String signedPrivateTransaction) { - this.signedPrivateTransaction = signedPrivateTransaction; - } - - @Override - public String execute(final NodeRequests node) { - try { - return node.privacy() - .privDistributeTransaction(signedPrivateTransaction) - .send() - .getTransactionKey(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivacyTransactions.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivacyTransactions.java deleted file mode 100644 index d168108c975..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivacyTransactions.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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.privacy.transaction; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.privacy.PrivacyGroupUtil; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.condition.PrivGetTransactionReceiptTransaction; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.util.LogFilterJsonParameter; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.EeaSendRawTransactionTransaction; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivCallTransaction; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivDebugGetStateRoot; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivGetCodeTransaction; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivGetLogsTransaction; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivGetTransaction; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivTraceTransaction; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.filter.PrivGetFilterChangesTransaction; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.filter.PrivGetFilterLogsTransaction; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.filter.PrivNewFilterTransaction; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.filter.PrivUninstallFilterTransaction; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.web3j.crypto.Credentials; -import org.web3j.tx.Contract; - -public class PrivacyTransactions { - - public PrivGetTransactionReceiptTransaction getPrivateTransactionReceipt( - final String transactionHash) { - return new PrivGetTransactionReceiptTransaction(transactionHash); - } - - public RestrictedCreatePrivacyGroupTransaction createPrivacyGroup( - final String name, final String description, final PrivacyNode... nodes) { - return new RestrictedCreatePrivacyGroupTransaction(name, description, nodes); - } - - public CreateFlexiblePrivacyGroupTransaction createFlexiblePrivacyGroup( - final PrivacyNode creator, - final String privateFrom, - final List addresses, - final String token) { - creator.getBesu().useAuthenticationTokenInHeaderForJsonRpc(token); - return new CreateFlexiblePrivacyGroupTransaction(creator, privateFrom, addresses); - } - - public CreateFlexiblePrivacyGroupTransaction createFlexiblePrivacyGroup( - final PrivacyNode creator, final String privateFrom, final List addresses) { - return new CreateFlexiblePrivacyGroupTransaction(creator, privateFrom, addresses); - } - - public AddToFlexiblePrivacyGroupTransaction addToPrivacyGroup( - final String privacyGroupId, - final PrivacyNode adder, - final Credentials signer, - final PrivacyNode... nodes) { - return new AddToFlexiblePrivacyGroupTransaction(privacyGroupId, adder, signer, nodes); - } - - public LockFlexiblePrivacyGroupTransaction privxLockPrivacyGroupAndCheck( - final String privacyGroupId, final PrivacyNode locker, final Credentials signer) { - return new LockFlexiblePrivacyGroupTransaction(privacyGroupId, locker, signer); - } - - public UnlockFlexiblePrivacyGroupTransaction privxUnlockPrivacyGroupAndCheck( - final String privacyGroupId, final PrivacyNode locker, final Credentials signer) { - return new UnlockFlexiblePrivacyGroupTransaction(privacyGroupId, locker, signer); - } - - public FindPrivacyGroupTransaction findPrivacyGroup(final List nodes) { - return new FindPrivacyGroupTransaction(nodes); - } - - public FindFlexiblePrivacyGroupTransaction findFlexiblePrivacyGroup(final List nodes) { - return new FindFlexiblePrivacyGroupTransaction(nodes); - } - - public PrivDistributeTransactionTransaction privDistributeTransaction( - final String signedPrivateTransaction) { - return new PrivDistributeTransactionTransaction(signedPrivateTransaction); - } - - public PrivCallTransaction privCall( - final String privacyGroupId, final Contract contract, final String encoded) { - return new PrivCallTransaction(privacyGroupId, contract, encoded); - } - - public PrivGetTransaction privGetTransaction(final String transactionHash) { - return new PrivGetTransaction(transactionHash); - } - - public PrivGetCodeTransaction privGetCode( - final String privacyGroupId, final Address contractAddress, final String blockParameter) { - return new PrivGetCodeTransaction(privacyGroupId, contractAddress, blockParameter); - } - - public PrivGetLogsTransaction privGetLogs( - final String privacyGroupId, final LogFilterJsonParameter filterParameter) { - return new PrivGetLogsTransaction(privacyGroupId, filterParameter); - } - - public PrivTraceTransaction privTraceTransaction( - final String privacyGroupId, final Hash transactionHash) { - return new PrivTraceTransaction(privacyGroupId, transactionHash); - } - - public RemoveFromFlexiblePrivacyGroupTransaction removeFromPrivacyGroup( - final String privacyGroupId, - final String remover, - final Credentials signer, - final String memberToRemove) { - return new RemoveFromFlexiblePrivacyGroupTransaction( - privacyGroupId, remover, signer, memberToRemove); - } - - public EeaSendRawTransactionTransaction sendRawTransaction(final String transaction) { - return new EeaSendRawTransactionTransaction(transaction); - } - - public PrivNewFilterTransaction newFilter( - final String privacyGroupId, final LogFilterJsonParameter filterParameter) { - return new PrivNewFilterTransaction(privacyGroupId, filterParameter); - } - - public PrivUninstallFilterTransaction uninstallFilter( - final String privacyGroupId, final String filterId) { - return new PrivUninstallFilterTransaction(privacyGroupId, filterId); - } - - public PrivGetFilterLogsTransaction getFilterLogs( - final String privacyGroupId, final String filterId) { - return new PrivGetFilterLogsTransaction(privacyGroupId, filterId); - } - - public PrivGetFilterChangesTransaction getFilterChanges( - final String privacyGroupId, final String filterId) { - return new PrivGetFilterChangesTransaction(privacyGroupId, filterId); - } - - public PrivDebugGetStateRoot debugGetStateRoot( - final String privacyGroupId, final String blockParam) { - return new PrivDebugGetStateRoot(privacyGroupId, blockParam); - } - - public String getLegacyPrivacyGroupId(final String privateFrom, final String... privateFor) { - - final Bytes32 privacyGroupId = - PrivacyGroupUtil.calculateEeaPrivacyGroupId( - Bytes.fromBase64String(privateFrom), - Arrays.stream(privateFor).map(Bytes::fromBase64String).collect(Collectors.toList())); - - return privacyGroupId.toBase64String(); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/RemoveFromFlexiblePrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/RemoveFromFlexiblePrivacyGroupTransaction.java deleted file mode 100644 index 7f2712c81dc..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/RemoveFromFlexiblePrivacyGroupTransaction.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.privacy.transaction; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -import org.web3j.crypto.Credentials; -import org.web3j.utils.Base64String; - -public class RemoveFromFlexiblePrivacyGroupTransaction implements Transaction { - private final Base64String privacyGroupId; - private final String remover; - private final String toRemove; - private final Credentials signer; - - public RemoveFromFlexiblePrivacyGroupTransaction( - final String privacyGroupId, - final String remover, - final Credentials signer, - final String toRemove) { - this.privacyGroupId = Base64String.wrap(privacyGroupId); - this.remover = remover; - this.signer = signer; - this.toRemove = toRemove; - } - - @Override - public String execute(final NodeRequests node) { - try { - return node.privacy().privxRemoveFromPrivacyGroup(privacyGroupId, remover, signer, toRemove); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/RestrictedCreatePrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/RestrictedCreatePrivacyGroupTransaction.java deleted file mode 100644 index a455076f9fb..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/RestrictedCreatePrivacyGroupTransaction.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.privacy.transaction; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import org.web3j.protocol.besu.Besu; -import org.web3j.protocol.besu.response.privacy.PrivCreatePrivacyGroup; -import org.web3j.utils.Base64String; - -public class RestrictedCreatePrivacyGroupTransaction implements Transaction { - private final String name; - private final String description; - private final List addresses; - - public RestrictedCreatePrivacyGroupTransaction( - final String name, final String description, final PrivacyNode... nodes) { - this.name = name; - this.description = description; - this.addresses = - Arrays.stream(nodes) - .map(n -> Base64String.wrap(n.getEnclave().getDefaultPublicKey())) - .collect(Collectors.toList()); - } - - @Override - public String execute(final NodeRequests node) { - final Besu besu = node.privacy().getBesuClient(); - try { - final PrivCreatePrivacyGroup result = - besu.privCreatePrivacyGroup(addresses, name, description).send(); - if (result.hasError()) { - throw new RuntimeException(result.getError().getMessage()); - } else { - return result.getPrivacyGroupId().toString(); - } - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/UnlockFlexiblePrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/UnlockFlexiblePrivacyGroupTransaction.java deleted file mode 100644 index 98b0236c32d..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/UnlockFlexiblePrivacyGroupTransaction.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.privacy.transaction; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -import org.web3j.crypto.Credentials; -import org.web3j.protocol.exceptions.TransactionException; -import org.web3j.utils.Base64String; - -public class UnlockFlexiblePrivacyGroupTransaction implements Transaction { - private final Base64String privacyGroupId; - private final PrivacyNode locker; - private final Credentials signer; - - public UnlockFlexiblePrivacyGroupTransaction( - final String privacyGroupId, final PrivacyNode locker, final Credentials signer) { - this.privacyGroupId = Base64String.wrap(privacyGroupId); - this.locker = locker; - this.signer = signer; - } - - @Override - public String execute(final NodeRequests node) { - try { - return node.privacy().privxUnlockPrivacyGroup(locker, privacyGroupId, signer); - } catch (final IOException | TransactionException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/util/LogFilterJsonParameter.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/util/LogFilterJsonParameter.java deleted file mode 100644 index 0ef7c51dc00..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/util/LogFilterJsonParameter.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.privacy.util; - -import java.util.List; - -public class LogFilterJsonParameter { - - private final String fromBlock; - private final String toBlock; - private final List addresses; - private final List> topics; - private final String blockhash; - - public LogFilterJsonParameter( - final String fromBlock, - final String toBlock, - final List addresses, - final List> topics, - final String blockhash) { - this.fromBlock = fromBlock; - this.toBlock = toBlock; - this.addresses = addresses; - this.topics = topics; - this.blockhash = blockhash; - } - - public String getFromBlock() { - return fromBlock; - } - - public String getToBlock() { - return toBlock; - } - - public List getAddresses() { - return addresses; - } - - public List> getTopics() { - return topics; - } - - public String getBlockhash() { - return blockhash; - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/NodeRequests.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/NodeRequests.java index 1151100065b..fea5dba3ff0 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/NodeRequests.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/NodeRequests.java @@ -21,7 +21,6 @@ import org.hyperledger.besu.tests.acceptance.dsl.transaction.miner.MinerRequestFactory; import org.hyperledger.besu.tests.acceptance.dsl.transaction.net.CustomRequestFactory; import org.hyperledger.besu.tests.acceptance.dsl.transaction.perm.PermissioningJsonRpcRequestFactory; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory; import org.hyperledger.besu.tests.acceptance.dsl.transaction.txpool.TxPoolRequestFactory; import java.util.Optional; @@ -37,7 +36,6 @@ public class NodeRequests { private final BftRequestFactory bft; private final PermissioningJsonRpcRequestFactory perm; private final AdminRequestFactory admin; - private final PrivacyRequestFactory privacy; private final CustomRequestFactory custom; private final Optional websocketService; private final LoginRequestFactory login; @@ -51,7 +49,6 @@ public NodeRequests( final BftRequestFactory bft, final PermissioningJsonRpcRequestFactory perm, final AdminRequestFactory admin, - final PrivacyRequestFactory privacy, final CustomRequestFactory custom, final MinerRequestFactory miner, final TxPoolRequestFactory txPool, @@ -63,7 +60,6 @@ public NodeRequests( this.bft = bft; this.perm = perm; this.admin = admin; - this.privacy = privacy; this.custom = custom; this.miner = miner; this.txPool = txPool; @@ -99,10 +95,6 @@ public CustomRequestFactory custom() { return custom; } - public PrivacyRequestFactory privacy() { - return privacy; - } - public LoginRequestFactory login() { return login; } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/EeaSendRawTransactionTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/EeaSendRawTransactionTransaction.java deleted file mode 100644 index 5d2786ae8a6..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/EeaSendRawTransactionTransaction.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -public class EeaSendRawTransactionTransaction implements Transaction { - - final String transaction; - - public EeaSendRawTransactionTransaction(final String transaction) { - this.transaction = transaction; - } - - @Override - public Hash execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.SendRawTransactionResponse result = - node.privacy().eeaSendRawTransaction(transaction).send(); - assertThat(result).isNotNull(); - if (result.hasError()) { - throw new RuntimeException(result.getError().getMessage()); - } - return result.getResult(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivCallTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivCallTransaction.java deleted file mode 100644 index 7520ada4838..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivCallTransaction.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -import org.web3j.protocol.core.methods.response.EthCall; -import org.web3j.tx.Contract; - -public class PrivCallTransaction implements Transaction { - - private final String privacyGroupId; - private final Contract contract; - private final String encoded; - private final String blockNumberLatestPending; - - public PrivCallTransaction( - final String privacyGroupId, final Contract contract, final String encoded) { - this(privacyGroupId, contract, encoded, "latest"); - } - - public PrivCallTransaction( - final String privacyGroupId, - final Contract contract, - final String encoded, - final String blockNumberLatestPending) { - this.privacyGroupId = privacyGroupId; - this.contract = contract; - this.encoded = encoded; - this.blockNumberLatestPending = blockNumberLatestPending; - } - - @Override - public EthCall execute(final NodeRequests node) { - try { - final EthCall response = - node.privacy() - .privCall(privacyGroupId, contract, encoded, blockNumberLatestPending) - .send(); - assertThat(response).as("check response is not null").isNotNull(); - assertThat(response.getResult()).as("check result in response isn't null").isNotNull(); - return response; - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivCreatePrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivCreatePrivacyGroupTransaction.java deleted file mode 100644 index eaddb84fc52..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivCreatePrivacyGroupTransaction.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.parameters.CreatePrivacyGroupParameter; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; -import java.util.List; - -public class PrivCreatePrivacyGroupTransaction implements Transaction { - - final CreatePrivacyGroupParameter params; - - public PrivCreatePrivacyGroupTransaction( - final List addresses, final String groupName, final String groupDescription) { - this.params = new CreatePrivacyGroupParameter(addresses, groupName, groupDescription); - } - - @Override - public String execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.CreatePrivacyGroupResponse result = - node.privacy().privCreatePrivacyGroup(params).send(); - assertThat(result).isNotNull(); - return result.getResult(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivDebugGetStateRoot.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivDebugGetStateRoot.java deleted file mode 100644 index 59e9dd36a6d..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivDebugGetStateRoot.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -public class PrivDebugGetStateRoot implements Transaction { - - private final String privacyGroupId; - private final String blockParam; - - public PrivDebugGetStateRoot(final String privacyGroupId, final String blockParam) { - this.privacyGroupId = privacyGroupId; - this.blockParam = blockParam; - } - - @Override - public PrivacyRequestFactory.DebugGetStateRoot execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.DebugGetStateRoot response = - node.privacy().privDebugGetStateRoot(privacyGroupId, blockParam).send(); - assertThat(response).as("check response is not null").isNotNull(); - return response; - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivDeletePrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivDeletePrivacyGroupTransaction.java deleted file mode 100644 index caf755839d8..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivDeletePrivacyGroupTransaction.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -public class PrivDeletePrivacyGroupTransaction implements Transaction { - - final String transactionHash; - - public PrivDeletePrivacyGroupTransaction(final String transactionHash) { - this.transactionHash = transactionHash; - } - - @Override - public String execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.DeletePrivacyGroupResponse result = - node.privacy().privDeletePrivacyGroup(transactionHash).send(); - assertThat(result).isNotNull(); - if (result.hasError()) { - throw new RuntimeException(result.getError().getMessage()); - } - return result.getResult(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivDistributeRawTransactionTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivDistributeRawTransactionTransaction.java deleted file mode 100644 index 8a9c70f8736..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivDistributeRawTransactionTransaction.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -public class PrivDistributeRawTransactionTransaction implements Transaction { - - final String transaction; - - public PrivDistributeRawTransactionTransaction(final String transaction) { - this.transaction = transaction; - } - - @Override - public String execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.PrivDistributeTransactionResponse result = - node.privacy().privDistributeTransaction(transaction).send(); - assertThat(result).isNotNull(); - if (result.hasError()) { - throw new RuntimeException(result.getError().getMessage()); - } - return result.getTransactionKey(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivFindPrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivFindPrivacyGroupTransaction.java deleted file mode 100644 index 47fad9455c6..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivFindPrivacyGroupTransaction.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.enclave.types.PrivacyGroup; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -public class PrivFindPrivacyGroupTransaction implements Transaction { - - final String[] groupMembers; - - public PrivFindPrivacyGroupTransaction(final String[] groupMembers) { - this.groupMembers = groupMembers; - } - - @Override - public PrivacyGroup[] execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.FindPrivacyGroupResponse result = - node.privacy().privFindPrivacyGroup(groupMembers).send(); - assertThat(result).isNotNull(); - if (result.hasError()) { - throw new RuntimeException(result.getError().getMessage()); - } - return result.getResult(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetCodeTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetCodeTransaction.java deleted file mode 100644 index dbe708f53b5..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetCodeTransaction.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -import org.apache.tuweni.bytes.Bytes; - -public class PrivGetCodeTransaction implements Transaction { - - private final String privacyGroupId; - private final Address contractAddress; - private final String blockParameter; - - public PrivGetCodeTransaction( - final String privacyGroupId, final Address contractAddress, final String blockParameter) { - this.privacyGroupId = privacyGroupId; - this.contractAddress = contractAddress; - this.blockParameter = blockParameter; - } - - @Override - public Bytes execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.GetCodeResponse response = - node.privacy() - .privGetCode(privacyGroupId, contractAddress.toHexString(), blockParameter) - .send(); - assertThat(response).as("check response is not null").isNotNull(); - assertThat(response.getResult()).as("check code in response isn't null").isNotNull(); - return Bytes.fromHexString(response.getResult()); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetEeaTransactionCountTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetEeaTransactionCountTransaction.java deleted file mode 100644 index b27240d1bc8..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetEeaTransactionCountTransaction.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -public class PrivGetEeaTransactionCountTransaction implements Transaction { - - private final Object[] params; - - public PrivGetEeaTransactionCountTransaction( - final String accountAddress, final String privateFrom, final String[] privateFor) { - this.params = new Object[] {accountAddress, privateFrom, privateFor}; - } - - @Override - public Integer execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.GetTransactionCountResponse result = - node.privacy().privGetEeaTransactionCount(params).send(); - assertThat(result).isNotNull(); - if (result.hasError()) { - throw new RuntimeException(result.getError().getMessage()); - } - return result.getCount(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetLogsTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetLogsTransaction.java deleted file mode 100644 index 562a247b5fd..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetLogsTransaction.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.util.LogFilterJsonParameter; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; -import java.util.List; - -import org.web3j.protocol.core.methods.response.EthLog; -import org.web3j.protocol.core.methods.response.EthLog.LogResult; - -@SuppressWarnings("rawtypes") -public class PrivGetLogsTransaction implements Transaction> { - - private final String privacyGroupId; - private final LogFilterJsonParameter filterParameter; - - public PrivGetLogsTransaction( - final String privacyGroupId, final LogFilterJsonParameter filterParameter) { - this.privacyGroupId = privacyGroupId; - this.filterParameter = filterParameter; - } - - @Override - public List execute(final NodeRequests node) { - try { - final EthLog response = node.privacy().privGetLogs(privacyGroupId, filterParameter).send(); - - assertThat(response).as("check response is not null").isNotNull(); - assertThat(response.getResult()).as("check result in response isn't null").isNotNull(); - - return response.getLogs(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetPrivacyPrecompileAddressTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetPrivacyPrecompileAddressTransaction.java deleted file mode 100644 index cf8cd3f0656..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetPrivacyPrecompileAddressTransaction.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -public class PrivGetPrivacyPrecompileAddressTransaction implements Transaction
{ - - @Override - public Address execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.GetPrivacyPrecompileAddressResponse result = - node.privacy().privGetPrivacyPrecompileAddress().send(); - assertThat(result).isNotNull(); - return result.getResult(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetPrivateTransactionTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetPrivateTransactionTransaction.java deleted file mode 100644 index e91a83f314b..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetPrivateTransactionTransaction.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivateTransactionGroupResponse; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -public class PrivGetPrivateTransactionTransaction - implements Transaction { - - private final Hash transactionHash; - - public PrivGetPrivateTransactionTransaction(final Hash transactionHash) { - this.transactionHash = transactionHash; - } - - @Override - public PrivateTransactionGroupResponse execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.GetPrivateTransactionResponse result = - node.privacy().privGetPrivateTransaction(transactionHash).send(); - assertThat(result).isNotNull(); - return result.getResult(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetTransaction.java deleted file mode 100644 index 0d6e599a1e2..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetTransaction.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -public class PrivGetTransaction - implements Transaction { - - private final String transactionHash; - - public PrivGetTransaction(final String transactionHash) { - this.transactionHash = transactionHash; - } - - @Override - public PrivacyRequestFactory.GetPrivateTransactionResponse execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.GetPrivateTransactionResponse response = - node.privacy().privGetPrivateTransaction(Hash.fromHexString(transactionHash)).send(); - assertThat(response).as("check response is not null").isNotNull(); - assertThat(response.getResult()).as("check result in response isn't null").isNotNull(); - return response; - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetTransactionCountTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetTransactionCountTransaction.java deleted file mode 100644 index e222516beeb..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetTransactionCountTransaction.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -public class PrivGetTransactionCountTransaction implements Transaction { - - private final Object[] params; - - public PrivGetTransactionCountTransaction( - final String accountAddress, final String privacyGroupId) { - this.params = new String[] {accountAddress, privacyGroupId}; - } - - @Override - public Integer execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.GetTransactionCountResponse result = - node.privacy().privGetTransactionCount(params).send(); - assertThat(result).isNotNull(); - if (result.hasError()) { - throw new RuntimeException(result.getError().getMessage()); - } - return result.getCount(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetTransactionReceiptTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetTransactionReceiptTransaction.java deleted file mode 100644 index da2f6b310c6..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivGetTransactionReceiptTransaction.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; - -public class PrivGetTransactionReceiptTransaction - implements Transaction { - - private final Hash transaction; - - public PrivGetTransactionReceiptTransaction(final Hash transaction) { - this.transaction = transaction; - } - - @Override - public PrivateTransactionReceipt execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.GetTransactionReceiptResponse result = - node.privacy().privGetTransactionReceipt(transaction).send(); - assertThat(result).isNotNull(); - return result.getResult(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivSyncingTransactions.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivSyncingTransactions.java deleted file mode 100644 index 361d2c556a0..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivSyncingTransactions.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -import org.web3j.protocol.core.methods.response.EthSyncing; - -public class PrivSyncingTransactions implements Transaction { - - PrivSyncingTransactions() {} - - @Override - public Boolean execute(final NodeRequests node) { - try { - EthSyncing response = node.eth().ethSyncing().send(); - assertThat(response).isNotNull(); - return response.isSyncing(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivTraceTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivTraceTransaction.java deleted file mode 100644 index b971c4afde7..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivTraceTransaction.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.transaction.privacy; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -public class PrivTraceTransaction implements Transaction { - - private final String privacyGroupId; - private final Hash transactionHash; - - public PrivTraceTransaction(final String privacyGroupId, final Hash transactionHash) { - this.privacyGroupId = privacyGroupId; - this.transactionHash = transactionHash; - } - - @Override - public String execute(final NodeRequests node) { - try { - final PrivacyRequestFactory.PrivTraceTransaction response = - node.privacy().privTraceTransaction(privacyGroupId, transactionHash).send(); - - assertThat(response).as("check response is not null").isNotNull(); - assertThat(response.getResult()).as("check result in response is not null").isNotNull(); - - return response.getResult(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyRequestFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyRequestFactory.java deleted file mode 100644 index 7c01c02c48e..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyRequestFactory.java +++ /dev/null @@ -1,629 +0,0 @@ -/* - * 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.transaction.privacy; - -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY_PROXY; - -import org.hyperledger.besu.crypto.SecureRandomProvider; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.enclave.types.PrivacyGroup; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.parameters.CreatePrivacyGroupParameter; -import org.hyperledger.besu.ethereum.privacy.group.FlexibleGroupManagement; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivateTransactionGroupResponse; -import org.hyperledger.besu.tests.acceptance.dsl.privacy.util.LogFilterJsonParameter; - -import java.io.IOException; -import java.math.BigInteger; -import java.security.SecureRandom; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.tuweni.bytes.Bytes; -import org.web3j.abi.FunctionEncoder; -import org.web3j.abi.TypeReference; -import org.web3j.abi.Utils; -import org.web3j.abi.datatypes.Bool; -import org.web3j.abi.datatypes.DynamicArray; -import org.web3j.abi.datatypes.DynamicBytes; -import org.web3j.abi.datatypes.Function; -import org.web3j.abi.datatypes.Type; -import org.web3j.crypto.Credentials; -import org.web3j.protocol.Web3jService; -import org.web3j.protocol.besu.Besu; -import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; -import org.web3j.protocol.core.Request; -import org.web3j.protocol.core.Response; -import org.web3j.protocol.core.methods.response.EthCall; -import org.web3j.protocol.core.methods.response.EthFilter; -import org.web3j.protocol.core.methods.response.EthLog; -import org.web3j.protocol.core.methods.response.EthSendTransaction; -import org.web3j.protocol.core.methods.response.EthUninstallFilter; -import org.web3j.protocol.eea.crypto.PrivateTransactionEncoder; -import org.web3j.protocol.eea.crypto.RawPrivateTransaction; -import org.web3j.protocol.exceptions.TransactionException; -import org.web3j.tx.ChainIdLong; -import org.web3j.tx.Contract; -import org.web3j.tx.PrivateTransactionManager; -import org.web3j.tx.response.PollingPrivateTransactionReceiptProcessor; -import org.web3j.utils.Base64String; -import org.web3j.utils.Numeric; -import org.web3j.utils.Restriction; - -public class PrivacyRequestFactory { - - private final SecureRandom secureRandom; - - public PrivateTransactionManager getTransactionManager( - final Credentials credentials, - final Base64String privateFrom, - final List privateFor, - final Restriction restriction) { - return new PrivateTransactionManager( - getBesuClient(), - credentials, - new PollingPrivateTransactionReceiptProcessor(getBesuClient(), 1000, 60), - ChainIdLong.NONE, - privateFrom, - privateFor, - restriction); - } - - public PrivateTransactionManager getTransactionManager( - final Credentials credentials, - final Base64String privateFrom, - final Base64String privacyGroupId, - final Restriction restriction) { - return new PrivateTransactionManager( - getBesuClient(), - credentials, - new PollingPrivateTransactionReceiptProcessor(getBesuClient(), 1000, 60), - ChainIdLong.NONE, - privateFrom, - privacyGroupId, - restriction); - } - - public static class GetPrivacyPrecompileAddressResponse extends Response
{} - - public static class GetPrivateTransactionResponse - extends Response {} - - public static class PrivTraceTransaction extends Response {} - - public static class CreatePrivacyGroupResponse extends Response {} - - public static class DeletePrivacyGroupResponse extends Response {} - - public static class FindPrivacyGroupResponse extends Response {} - - public static class SendRawTransactionResponse extends Response {} - - public static class GetTransactionReceiptResponse extends Response {} - - public static class GetTransactionCountResponse extends Response { - - final Integer count; - - @JsonCreator - public GetTransactionCountResponse(@JsonProperty("result") final String result) { - this.count = result == null ? null : Integer.decode(result); - } - - public Integer getCount() { - return count; - } - } - - public static class GetCodeResponse extends Response {} - - public static class DebugGetStateRoot extends Response {} - - public Request privDistributeTransaction( - final String signedPrivateTransaction) { - return new Request<>( - "priv_distributeRawTransaction", - singletonList(signedPrivateTransaction), - web3jService, - PrivDistributeTransactionResponse.class); - } - - private final Besu besuClient; - private final Web3jService web3jService; - - public PrivacyRequestFactory(final Web3jService web3jService) { - this.web3jService = web3jService; - this.besuClient = Besu.build(web3jService); - this.secureRandom = SecureRandomProvider.createSecureRandom(); - } - - public Besu getBesuClient() { - return besuClient; - } - - public static class PrivDistributeTransactionResponse extends Response { - - public PrivDistributeTransactionResponse() {} - - public String getTransactionKey() { - return getResult(); - } - } - - public String privxAddToPrivacyGroup( - final Base64String privacyGroupId, - final PrivacyNode adder, - final Credentials signer, - final List addresses) - throws IOException { - - final BigInteger nonce = - besuClient - .privGetTransactionCount(signer.getAddress(), privacyGroupId) - .send() - .getTransactionCount(); - - final Bytes payload = - encodeAddToGroupFunctionCall( - addresses.stream().map(Bytes::fromBase64String).collect(Collectors.toList())); - - final RawPrivateTransaction privateTransaction = - RawPrivateTransaction.createTransaction( - nonce, - BigInteger.valueOf(1000), - BigInteger.valueOf(3000000), - FLEXIBLE_PRIVACY_PROXY.toHexString(), - payload.toHexString(), - Base64String.wrap(adder.getEnclaveKey()), - privacyGroupId, - org.web3j.utils.Restriction.RESTRICTED); - - return besuClient - .eeaSendRawTransaction( - Numeric.toHexString(PrivateTransactionEncoder.signMessage(privateTransaction, signer))) - .send() - .getTransactionHash(); - } - - public String privxRemoveFromPrivacyGroup( - final Base64String privacyGroupId, - final String removerTenant, - final Credentials signer, - final String toRemove) - throws IOException { - - final BigInteger nonce = - besuClient - .privGetTransactionCount(signer.getAddress(), privacyGroupId) - .send() - .getTransactionCount(); - - final Bytes payload = encodeRemoveFromGroupFunctionCall(Bytes.fromBase64String(toRemove)); - - final RawPrivateTransaction privateTransaction = - RawPrivateTransaction.createTransaction( - nonce, - BigInteger.valueOf(1000), - BigInteger.valueOf(3000000), - FLEXIBLE_PRIVACY_PROXY.toHexString(), - payload.toHexString(), - Base64String.wrap(removerTenant), - privacyGroupId, - org.web3j.utils.Restriction.RESTRICTED); - - return besuClient - .eeaSendRawTransaction( - Numeric.toHexString(PrivateTransactionEncoder.signMessage(privateTransaction, signer))) - .send() - .getTransactionHash(); - } - - private Bytes encodeRemoveFromGroupFunctionCall(final Bytes toRemove) { - final Function function = - new Function( - "removeParticipant", - Arrays.asList(new DynamicBytes(toRemove.toArrayUnsafe())), - Arrays.asList(new TypeReference() {})); - - return Bytes.fromHexString(FunctionEncoder.encode(function)); - } - - public String privxLockPrivacyGroup( - final PrivacyNode locker, final Base64String privacyGroupId, final Credentials signer) - throws IOException, TransactionException { - return privxLockOrUnlockPrivacyGroup( - locker, - privacyGroupId, - signer, - FlexibleGroupManagement.LOCK_GROUP_METHOD_SIGNATURE.toHexString()); - } - - public String privxUnlockPrivacyGroup( - final PrivacyNode locker, final Base64String privacyGroupId, final Credentials signer) - throws IOException, TransactionException { - return privxLockOrUnlockPrivacyGroup( - locker, - privacyGroupId, - signer, - FlexibleGroupManagement.UNLOCK_GROUP_METHOD_SIGNATURE.toHexString()); - } - - private String privxLockOrUnlockPrivacyGroup( - final PrivacyNode locker, - final Base64String privacyGroupId, - final Credentials signer, - final String callData) - throws IOException, TransactionException { - final BigInteger nonce = - besuClient - .privGetTransactionCount(signer.getAddress(), privacyGroupId) - .send() - .getTransactionCount(); - - final RawPrivateTransaction privateTransaction = - RawPrivateTransaction.createTransaction( - nonce, - BigInteger.valueOf(1000), - BigInteger.valueOf(3000000), - FLEXIBLE_PRIVACY_PROXY.toHexString(), - callData, - Base64String.wrap(locker.getEnclaveKey()), - privacyGroupId, - org.web3j.utils.Restriction.RESTRICTED); - - final String transactionHash = - besuClient - .eeaSendRawTransaction( - Numeric.toHexString( - PrivateTransactionEncoder.signMessage(privateTransaction, signer))) - .send() - .getTransactionHash(); - - final PrivateTransactionReceipt privateTransactionReceipt = - new PollingPrivateTransactionReceiptProcessor(besuClient, 3000, 10) - .waitForTransactionReceipt(transactionHash); - - assertThat(privateTransactionReceipt.getStatus()).isEqualTo("0x1"); - - return privateTransactionReceipt.getcommitmentHash(); - } - - public PrivxCreatePrivacyGroupResponse privxCreatePrivacyGroup( - final PrivacyNode creator, final String privateFrom, final List addresses) - throws IOException { - - final byte[] bytes = new byte[32]; - secureRandom.nextBytes(bytes); - final Bytes privacyGroupId = Bytes.wrap(bytes); - - final Bytes payload = - encodeAddToGroupFunctionCall( - addresses.stream().map(Bytes::fromBase64String).collect(Collectors.toList())); - - final RawPrivateTransaction privateTransaction = - RawPrivateTransaction.createTransaction( - BigInteger.ZERO, - BigInteger.valueOf(1000), - BigInteger.valueOf(3000000), - FLEXIBLE_PRIVACY_PROXY.toHexString(), - payload.toHexString(), - Base64String.wrap(privateFrom), - Base64String.wrap(privacyGroupId.toArrayUnsafe()), - org.web3j.utils.Restriction.RESTRICTED); - - final Request ethSendTransactionRequest = - besuClient.eeaSendRawTransaction( - Numeric.toHexString( - PrivateTransactionEncoder.signMessage( - privateTransaction, Credentials.create(creator.getTransactionSigningKey())))); - final String transactionHash = ethSendTransactionRequest.send().getTransactionHash(); - return new PrivxCreatePrivacyGroupResponse(privacyGroupId.toBase64String(), transactionHash); - } - - public Request privxFindFlexiblePrivacyGroup( - final List nodes) { - return new Request<>( - "privx_findFlexiblePrivacyGroup", - singletonList(nodes), - web3jService, - PrivxFindPrivacyGroupResponse.class); - } - - public Request privGetPrivacyPrecompileAddress() { - return new Request<>( - "priv_getPrivacyPrecompileAddress", - Collections.emptyList(), - web3jService, - GetPrivacyPrecompileAddressResponse.class); - } - - public Request privGetPrivateTransaction( - final Hash transactionHash) { - return new Request<>( - "priv_getPrivateTransaction", - singletonList(transactionHash.toHexString()), - web3jService, - GetPrivateTransactionResponse.class); - } - - public Request privCreatePrivacyGroup( - final CreatePrivacyGroupParameter params) { - return new Request<>( - "priv_createPrivacyGroup", - singletonList(params), - web3jService, - CreatePrivacyGroupResponse.class); - } - - public Request privDeletePrivacyGroup(final String groupId) { - return new Request<>( - "priv_deletePrivacyGroup", - singletonList(groupId), - web3jService, - DeletePrivacyGroupResponse.class); - } - - public Request privFindPrivacyGroup(final String[] groupMembers) { - return new Request<>( - "priv_findPrivacyGroup", - singletonList(groupMembers), - web3jService, - FindPrivacyGroupResponse.class); - } - - public Request eeaSendRawTransaction(final String transaction) { - return new Request<>( - "eea_sendRawTransaction", - singletonList(transaction), - web3jService, - SendRawTransactionResponse.class); - } - - public Request privGetTransactionReceipt( - final Hash transactionHash) { - return new Request<>( - "priv_getTransactionReceipt", - singletonList(transactionHash.toHexString()), - web3jService, - GetTransactionReceiptResponse.class); - } - - public Request privGetTransactionCount(final Object[] params) { - return new Request<>( - "priv_getTransactionCount", - List.of(params), - web3jService, - GetTransactionCountResponse.class); - } - - public Request privGetEeaTransactionCount(final Object[] params) { - return new Request<>( - "priv_getEeaTransactionCount", - List.of(params), - web3jService, - GetTransactionCountResponse.class); - } - - public Request privGetCode( - final String privacyGroupId, final String contractAddress, final String blockParameter) { - return new Request<>( - "priv_getCode", - List.of(privacyGroupId, contractAddress, blockParameter), - web3jService, - GetCodeResponse.class); - } - - public Request privCall( - final String privacyGroupId, - final Contract contract, - final String encoded, - final String blockNumberLatestPending) { - - final org.web3j.protocol.core.methods.request.Transaction transaction = - org.web3j.protocol.core.methods.request.Transaction.createEthCallTransaction( - null, contract.getContractAddress(), encoded); - - return new Request<>( - "priv_call", - Arrays.asList(privacyGroupId, transaction, blockNumberLatestPending), - web3jService, - EthCall.class); - } - - public Request privGetLogs( - final String privacyGroupId, final LogFilterJsonParameter filterParameter) { - - return new Request<>( - "priv_getLogs", Arrays.asList(privacyGroupId, filterParameter), web3jService, EthLog.class); - } - - public Request privTraceTransaction( - final String privacyGroupId, final Hash transactionHash) { - - return new Request<>( - "priv_traceTransaction", - Arrays.asList(privacyGroupId, transactionHash), - web3jService, - PrivTraceTransaction.class); - } - - public Request privNewFilter( - final String privacyGroupId, final LogFilterJsonParameter filterParameter) { - return new Request<>( - "priv_newFilter", - Arrays.asList(privacyGroupId, filterParameter), - web3jService, - EthFilter.class); - } - - public Request privUninstallFilter( - final String privacyGroupId, final String filterId) { - return new Request<>( - "priv_uninstallFilter", - Arrays.asList(privacyGroupId, filterId), - web3jService, - EthUninstallFilter.class); - } - - public Request privGetFilterLogs(final String privacyGroupId, final String filterId) { - - return new Request<>( - "priv_getFilterLogs", Arrays.asList(privacyGroupId, filterId), web3jService, EthLog.class); - } - - public Request privGetFilterChanges( - final String privacyGroupId, final String filterId) { - - return new Request<>( - "priv_getFilterChanges", - Arrays.asList(privacyGroupId, filterId), - web3jService, - EthLog.class); - } - - public Request privDebugGetStateRoot( - final String privacyGroupId, final String blockParam) { - return new Request<>( - "priv_debugGetStateRoot", - Arrays.asList(privacyGroupId, blockParam), - web3jService, - DebugGetStateRoot.class); - } - - public static class PrivxFindPrivacyGroupResponse extends Response> { - - public List getGroups() { - return getResult(); - } - } - - public static class FlexiblePrivacyGroup { - - private final Base64String privacyGroupId; - private final List members; - private final String name; - private final String description; - - public enum Type { - FLEXIBLE - } - - @JsonCreator - public FlexiblePrivacyGroup( - @JsonProperty(value = "privacyGroupId") final String privacyGroupId, - @JsonProperty(value = "type") final Type type, - @JsonProperty(value = "name") final String name, - @JsonProperty(value = "description") final String description, - @JsonProperty(value = "members") final List members) { - this(privacyGroupId, members); - } - - public FlexiblePrivacyGroup(final String privacyGroupId, final List members) { - this.privacyGroupId = Base64String.wrap(privacyGroupId); - this.name = ""; - this.description = ""; - this.members = members; - } - - public Base64String getPrivacyGroupId() { - return privacyGroupId; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public Type getType() { - return Type.FLEXIBLE; - } - - public List getMembers() { - return members; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final FlexiblePrivacyGroup that = (FlexiblePrivacyGroup) o; - return getPrivacyGroupId().equals(that.getPrivacyGroupId()) - && getName().equals(that.getName()) - && getDescription().equals(that.getDescription()) - && getType() == that.getType() - && getMembers().equals(that.getMembers()); - } - - @Override - public int hashCode() { - return Objects.hash( - getPrivacyGroupId(), getName(), getDescription(), getType(), getMembers()); - } - } - - public static class PrivxCreatePrivacyGroupResponse { - - final String privacyGroupId; - final String transactionHash; - - @JsonCreator - public PrivxCreatePrivacyGroupResponse( - @JsonProperty("privacyGroupId") final String privacyGroupId, - @JsonProperty("transactionHash") final String transactionHash) { - this.privacyGroupId = privacyGroupId; - this.transactionHash = transactionHash; - } - - public String getPrivacyGroupId() { - return privacyGroupId; - } - - public String getTransactionHash() { - return transactionHash; - } - } - - private Bytes encodeAddToGroupFunctionCall(final List participants) { - final Function function = - new Function( - "addParticipants", - Arrays.asList( - new DynamicArray<>( - DynamicBytes.class, - Utils.typeMap( - participants.stream() - .map(Bytes::toArrayUnsafe) - .collect(Collectors.toList()), - DynamicBytes.class))), - Collections.emptyList()); - - return Bytes.fromHexString(FunctionEncoder.encode(function)); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyTransactions.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyTransactions.java deleted file mode 100644 index db51fc2742d..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyTransactions.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.transaction.privacy; - -import org.hyperledger.besu.datatypes.Hash; - -import java.util.List; - -public class PrivacyTransactions { - public PrivGetPrivacyPrecompileAddressTransaction getPrivacyPrecompileAddress() { - return new PrivGetPrivacyPrecompileAddressTransaction(); - } - - public PrivGetPrivateTransactionTransaction getPrivateTransaction(final Hash transactionHash) { - return new PrivGetPrivateTransactionTransaction(transactionHash); - } - - public PrivCreatePrivacyGroupTransaction createPrivacyGroup( - final List addresses, final String groupName, final String groupDescription) { - return new PrivCreatePrivacyGroupTransaction(addresses, groupName, groupDescription); - } - - public PrivDeletePrivacyGroupTransaction deletePrivacyGroup(final String transactionHash) { - return new PrivDeletePrivacyGroupTransaction(transactionHash); - } - - public PrivFindPrivacyGroupTransaction findPrivacyGroup(final String[] groupMembers) { - return new PrivFindPrivacyGroupTransaction(groupMembers); - } - - public EeaSendRawTransactionTransaction sendRawTransaction(final String transaction) { - return new EeaSendRawTransactionTransaction(transaction); - } - - public PrivDistributeRawTransactionTransaction distributeRawTransaction( - final String transaction) { - return new PrivDistributeRawTransactionTransaction(transaction); - } - - public PrivGetTransactionCountTransaction getTransactionCount( - final String accountAddress, final String privacyGroupId) { - return new PrivGetTransactionCountTransaction(accountAddress, privacyGroupId); - } - - public PrivGetEeaTransactionCountTransaction getEeaTransactionCount( - final String accountAddress, final String privateFrom, final String[] privateFor) { - return new PrivGetEeaTransactionCountTransaction(accountAddress, privateFrom, privateFor); - } - - public PrivGetTransactionReceiptTransaction getTransactionReceipt(final Hash transactionHash) { - return new PrivGetTransactionReceiptTransaction(transactionHash); - } - - public PrivSyncingTransactions syncing() { - return new PrivSyncingTransactions(); - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/filter/PrivGetFilterChangesTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/filter/PrivGetFilterChangesTransaction.java deleted file mode 100644 index de8f2390c86..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/filter/PrivGetFilterChangesTransaction.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.transaction.privacy.filter; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; -import java.util.List; - -import org.web3j.protocol.core.methods.response.EthLog; -import org.web3j.protocol.core.methods.response.EthLog.LogResult; - -@SuppressWarnings("rawtypes") -public class PrivGetFilterChangesTransaction implements Transaction> { - - private final String privacyGroupId; - private final String filterId; - - public PrivGetFilterChangesTransaction(final String privacyGroupId, final String filterId) { - this.privacyGroupId = privacyGroupId; - this.filterId = filterId; - } - - @Override - public List execute(final NodeRequests node) { - try { - final EthLog response = node.privacy().privGetFilterChanges(privacyGroupId, filterId).send(); - - assertThat(response).as("check response is not null").isNotNull(); - assertThat(response.getResult()).as("check result in response isn't null").isNotNull(); - assertThat(response.getLogs()).isNotNull(); - - return response.getLogs(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/filter/PrivGetFilterLogsTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/filter/PrivGetFilterLogsTransaction.java deleted file mode 100644 index 4362062d8f2..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/filter/PrivGetFilterLogsTransaction.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.transaction.privacy.filter; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; -import java.util.List; - -import org.web3j.protocol.core.methods.response.EthLog; -import org.web3j.protocol.core.methods.response.EthLog.LogResult; - -@SuppressWarnings("rawtypes") -public class PrivGetFilterLogsTransaction implements Transaction> { - - private final String privacyGroupId; - private final String filterId; - - public PrivGetFilterLogsTransaction(final String privacyGroupId, final String filterId) { - this.privacyGroupId = privacyGroupId; - this.filterId = filterId; - } - - @Override - public List execute(final NodeRequests node) { - try { - final EthLog response = node.privacy().privGetFilterLogs(privacyGroupId, filterId).send(); - - assertThat(response).as("check response is not null").isNotNull(); - assertThat(response.getResult()).as("check result in response isn't null").isNotNull(); - assertThat(response.getLogs()).isNotNull(); - - return response.getLogs(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/filter/PrivNewFilterTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/filter/PrivNewFilterTransaction.java deleted file mode 100644 index fd2d76f4323..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/filter/PrivNewFilterTransaction.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.transaction.privacy.filter; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.util.LogFilterJsonParameter; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -import org.web3j.protocol.core.methods.response.EthFilter; - -public class PrivNewFilterTransaction implements Transaction { - - private final String privacyGroupId; - private final LogFilterJsonParameter filterParameter; - - public PrivNewFilterTransaction( - final String privacyGroupId, final LogFilterJsonParameter filterParameter) { - this.privacyGroupId = privacyGroupId; - this.filterParameter = filterParameter; - } - - @Override - public String execute(final NodeRequests node) { - try { - final EthFilter response = - node.privacy().privNewFilter(privacyGroupId, filterParameter).send(); - - assertThat(response).as("check response is not null").isNotNull(); - assertThat(response.getResult()).as("check result in response isn't null").isNotNull(); - - return response.getResult(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/filter/PrivUninstallFilterTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/filter/PrivUninstallFilterTransaction.java deleted file mode 100644 index b628d99cd41..00000000000 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/filter/PrivUninstallFilterTransaction.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.transaction.privacy.filter; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.io.IOException; - -import org.web3j.protocol.core.methods.response.EthUninstallFilter; - -public class PrivUninstallFilterTransaction implements Transaction { - - private final String privacyGroupId; - private final String filterId; - - public PrivUninstallFilterTransaction(final String privacyGroupId, final String filterId) { - this.privacyGroupId = privacyGroupId; - this.filterId = filterId; - } - - @Override - public Boolean execute(final NodeRequests node) { - try { - final EthUninstallFilter response = - node.privacy().privUninstallFilter(privacyGroupId, filterId).send(); - - assertThat(response).as("check response is not null").isNotNull(); - assertThat(response.getResult()).as("check result in response isn't null").isNotNull(); - - return response.isUninstalled(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/acceptance-tests/tests/build.gradle b/acceptance-tests/tests/build.gradle index 953d1859e8e..8bb8fb2f2f7 100644 --- a/acceptance-tests/tests/build.gradle +++ b/acceptance-tests/tests/build.gradle @@ -209,33 +209,6 @@ task acceptanceTestBftSoak(type: Test) { doFirst { mkdir "${buildDir}/jvmErrorLogs" } } -task acceptanceTestPrivacy(type: Test) { - inputs.property "integration.date", LocalTime.now() // so it runs at every invocation - include '**/privacy/**' - - useJUnitPlatform {} - - dependsOn(rootProject.installDist) - setSystemProperties(test.getSystemProperties()) - systemProperty 'acctests.runBesuAsProcess', 'true' - systemProperty 'java.security.properties', "${buildDir}/resources/test/acceptanceTesting.security" - mustRunAfter rootProject.subprojects*.test - description = 'Runs Privacy Besu acceptance tests.' - group = 'verification' - - jvmArgs "-XX:ErrorFile=${buildDir}/jvmErrorLogs/java_err_pid%p.log" - - testLogging { - exceptionFormat = 'full' - showStackTraces = true - showStandardStreams = Boolean.getBoolean('acctests.showStandardStreams') - showExceptions = true - showCauses = true - } - - doFirst { mkdir "${buildDir}/jvmErrorLogs" } -} - task acceptanceTestPermissioning(type: Test) { inputs.property "integration.date", LocalTime.now() // so it runs at every invocation include '**/permissioning/**' diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyGroupTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyGroupTest.java deleted file mode 100644 index b805fa43c4e..00000000000 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyGroupTest.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * 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.privacy.contracts; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import org.hyperledger.besu.privacy.contracts.generated.DefaultFlexiblePrivacyGroupManagementContract; -import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; -import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.web3j.protocol.core.RemoteFunctionCall; -import org.web3j.protocol.core.methods.response.TransactionReceipt; -import org.web3j.protocol.exceptions.TransactionException; -import org.web3j.utils.Base64String; - -@SuppressWarnings("unchecked") -public class PrivacyGroupTest extends AcceptanceTestBase { - - private final Base64String firstParticipant = - Base64String.wrap("A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="); - private final Base64String secondParticipant = - Base64String.wrap("Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs="); - private final Base64String thirdParticipant = - Base64String.wrap("Jo2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs="); - private DefaultFlexiblePrivacyGroupManagementContract defaultPrivacyGroupManagementContract; - - private static final String RAW_FIRST_PARTICIPANT = "0x5aa68ac0"; - private static final String RAW_ADD_PARTICIPANT = - "0x965a25ef00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000202a8d9b56a0fe9cd94d60be4413bcb721d3a7be27ed8e28b3a6346df874ee141b"; - private static final String RAW_REMOVE_PARTICIPANT = - "0x1f52a8ee000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000202a8d9b56a0fe9cd94d60be4413bcb721d3a7be27ed8e28b3a6346df874ee141b"; - private static final String RAW_LOCK = "0xf83d08ba"; - private static final String RAW_UNLOCK = "0xa69df4b5"; - private static final String RAW_CAN_EXECUTE = "0x78b90337"; - private static final String RAW_GET_VERSION = "0x0d8e6e2c"; - - private BesuNode minerNode; - - @BeforeEach - public void setUp() throws Exception { - minerNode = besu.createMinerNode("node"); - cluster.start(minerNode); - defaultPrivacyGroupManagementContract = - minerNode.execute( - contractTransactions.createSmartContract( - DefaultFlexiblePrivacyGroupManagementContract.class)); - } - - @Test - public void rlp() throws Exception { - final String contractAddress = "0x42699a7612a82f1d9c36148af9c77354759b210b"; - assertThat(defaultPrivacyGroupManagementContract.isValid()).isEqualTo(true); - contractVerifier - .validTransactionReceipt(contractAddress) - .verify(defaultPrivacyGroupManagementContract); - // 0x0b0235be - assertThat(defaultPrivacyGroupManagementContract.getParticipants().encodeFunctionCall()) - .isEqualTo(RAW_FIRST_PARTICIPANT); - // 0xf744b089 - assertThat( - defaultPrivacyGroupManagementContract - .addParticipants(Collections.singletonList(secondParticipant.raw())) - .encodeFunctionCall()) - .isEqualTo(RAW_ADD_PARTICIPANT); - // 0xf744b089 - assertThat( - defaultPrivacyGroupManagementContract - .removeParticipant(secondParticipant.raw()) - .encodeFunctionCall()) - .isEqualTo(RAW_REMOVE_PARTICIPANT); - assertThat(defaultPrivacyGroupManagementContract.lock().encodeFunctionCall()) - .isEqualTo(RAW_LOCK); - assertThat(defaultPrivacyGroupManagementContract.unlock().encodeFunctionCall()) - .isEqualTo(RAW_UNLOCK); - assertThat(defaultPrivacyGroupManagementContract.canExecute().encodeFunctionCall()) - .isEqualTo(RAW_CAN_EXECUTE); - assertThat(defaultPrivacyGroupManagementContract.getVersion().encodeFunctionCall()) - .isEqualTo(RAW_GET_VERSION); - } - - @Test - public void canInitiallyAddParticipants() throws Exception { - final RemoteFunctionCall transactionReceiptRemoteFunctionCall = - defaultPrivacyGroupManagementContract.addParticipants( - Arrays.asList(firstParticipant.raw(), secondParticipant.raw())); - transactionReceiptRemoteFunctionCall.send(); - final List participants = - defaultPrivacyGroupManagementContract.getParticipants().send(); - assertThat(participants.size()).isEqualTo(2); - assertThat(firstParticipant.raw()).isEqualTo(participants.get(0)); - assertThat(secondParticipant.raw()).isEqualTo(participants.get(1)); - } - - @Test - public void canRemoveParticipant() throws Exception { - defaultPrivacyGroupManagementContract - .addParticipants(Arrays.asList(firstParticipant.raw(), secondParticipant.raw())) - .send(); - final List participants = - defaultPrivacyGroupManagementContract.getParticipants().send(); - assertThat(participants.size()).isEqualTo(2); - assertThat(firstParticipant.raw()).isEqualTo(participants.get(0)); - assertThat(secondParticipant.raw()).isEqualTo(participants.get(1)); - defaultPrivacyGroupManagementContract.removeParticipant(secondParticipant.raw()).send(); - final List participantsAfterRemove = - defaultPrivacyGroupManagementContract.getParticipants().send(); - assertThat(participantsAfterRemove.size()).isEqualTo(1); - assertThat(firstParticipant.raw()).isEqualTo(participantsAfterRemove.get(0)); - } - - @Test - public void cannotAddToContractWhenNotLocked() throws Exception { - defaultPrivacyGroupManagementContract - .addParticipants(Collections.singletonList(thirdParticipant.raw())) - .send(); - - assertThatThrownBy( - () -> - defaultPrivacyGroupManagementContract - .addParticipants(Collections.singletonList(secondParticipant.raw())) - .send()) - .isInstanceOf(TransactionException.class); - } - - @Test - public void ensureContractIsLockedAfterDeploy() throws Exception { - assertThat(defaultPrivacyGroupManagementContract.canExecute().send()).isFalse(); - } - - @Test - public void ensurePrivacyGroupVersionIsAlwaysDifferent() throws Exception { - defaultPrivacyGroupManagementContract - .addParticipants(Collections.singletonList(secondParticipant.raw())) - .send(); - final byte[] version1 = defaultPrivacyGroupManagementContract.getVersion().send(); - defaultPrivacyGroupManagementContract.lock().send(); - defaultPrivacyGroupManagementContract - .addParticipants(Collections.singletonList(thirdParticipant.raw())) - .send(); - final byte[] version2 = defaultPrivacyGroupManagementContract.getVersion().send(); - defaultPrivacyGroupManagementContract.removeParticipant(secondParticipant.raw()).send(); - final byte[] version3 = defaultPrivacyGroupManagementContract.getVersion().send(); - - assertThat(version1).isNotEqualTo(version2); - assertThat(version1).isNotEqualTo(version3); - assertThat(version2).isNotEqualTo(version3); - } - - @Test - public void canAddTwiceToContractWhenCallLock() throws Exception { - defaultPrivacyGroupManagementContract - .addParticipants(Arrays.asList(firstParticipant.raw(), thirdParticipant.raw())) - .send(); - defaultPrivacyGroupManagementContract.lock().send(); - defaultPrivacyGroupManagementContract - .addParticipants(Collections.singletonList(secondParticipant.raw())) - .send(); - - final List participants = - defaultPrivacyGroupManagementContract.getParticipants().send(); - assertThat(participants.size()).isEqualTo(3); - assertThat(firstParticipant.raw()).isEqualTo(participants.get(0)); - assertThat(thirdParticipant.raw()).isEqualTo(participants.get(1)); - assertThat(secondParticipant.raw()).isEqualTo(participants.get(2)); - } - - @Test - public void cannotLockTwice() throws Exception { - defaultPrivacyGroupManagementContract - .addParticipants(Collections.singletonList(thirdParticipant.raw())) - .send(); - defaultPrivacyGroupManagementContract.lock().send(); - assertThatThrownBy(() -> defaultPrivacyGroupManagementContract.lock().send()) - .isInstanceOf(TransactionException.class); - } -} diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyProxyTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyProxyTest.java deleted file mode 100644 index 931770ee321..00000000000 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyProxyTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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.privacy.contracts; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import org.hyperledger.besu.privacy.contracts.generated.DefaultFlexiblePrivacyGroupManagementContract; -import org.hyperledger.besu.privacy.contracts.generated.FlexiblePrivacyGroupManagementProxy; -import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; -import org.hyperledger.besu.tests.acceptance.dsl.account.Accounts; -import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.web3j.crypto.Credentials; -import org.web3j.protocol.Web3j; -import org.web3j.protocol.exceptions.TransactionException; -import org.web3j.protocol.http.HttpService; -import org.web3j.tx.gas.DefaultGasProvider; -import org.web3j.utils.Base64String; - -@SuppressWarnings("unchecked") -public class PrivacyProxyTest extends AcceptanceTestBase { - - private final Base64String firstParticipant = - Base64String.wrap("93Ky7lXwFkMc7+ckoFgUMku5bpr9tz4zhmWmk9RlNng="); - private final Base64String secondParticipant = - Base64String.wrap("9iaJ6OObl6TUWYjXAOyZsL0VaDPwF+tRFkMwwYSeqqw="); - private final Base64String thirdParticipant = - Base64String.wrap("Jo2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs="); - private FlexiblePrivacyGroupManagementProxy flexiblePrivacyGroupManagementProxy; - - private static final String RAW_GET_PARTICIPANTS = "0x5aa68ac0"; - private static final String RAW_ADD_PARTICIPANT = - "0x965a25ef0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020f772b2ee55f016431cefe724a05814324bb96e9afdb73e338665a693d4653678"; - - private BesuNode minerNode; - private DefaultFlexiblePrivacyGroupManagementContract - defaultFlexiblePrivacyGroupManagementContract; - - @BeforeEach - public void setUp() throws Exception { - minerNode = besu.createMinerNode("node"); - cluster.start(minerNode); - defaultFlexiblePrivacyGroupManagementContract = - minerNode.execute( - contractTransactions.createSmartContract( - DefaultFlexiblePrivacyGroupManagementContract.class)); - flexiblePrivacyGroupManagementProxy = - minerNode.execute( - contractTransactions.createSmartContract( - FlexiblePrivacyGroupManagementProxy.class, - defaultFlexiblePrivacyGroupManagementContract.getContractAddress())); - } - - @Test - public void rlp() throws Exception { - assertThat(flexiblePrivacyGroupManagementProxy.isValid()).isEqualTo(true); - contractVerifier - .validTransactionReceipt(flexiblePrivacyGroupManagementProxy.getContractAddress()) - .verify(flexiblePrivacyGroupManagementProxy); - assertThat(flexiblePrivacyGroupManagementProxy.getParticipants().encodeFunctionCall()) - .isEqualTo(RAW_GET_PARTICIPANTS); - - assertThat( - flexiblePrivacyGroupManagementProxy - .addParticipants(List.of(firstParticipant.raw())) - .encodeFunctionCall()) - .isEqualTo(RAW_ADD_PARTICIPANT); - } - - @Test - public void deploysWithNoParticipant() throws Exception { - final List participants = flexiblePrivacyGroupManagementProxy.getParticipants().send(); - assertThat(participants.size()).isEqualTo(0); - } - - @Test - public void canAddParticipants() throws Exception { - flexiblePrivacyGroupManagementProxy - .addParticipants(Arrays.asList(firstParticipant.raw(), secondParticipant.raw())) - .send(); - final List participants = flexiblePrivacyGroupManagementProxy.getParticipants().send(); - assertThat(participants.size()).isEqualTo(2); - assertThat(firstParticipant.raw()).isEqualTo(participants.get(0)); - assertThat(secondParticipant.raw()).isEqualTo(participants.get(1)); - } - - @Test - public void nonOwnerCannotUpgrade() throws Exception { - flexiblePrivacyGroupManagementProxy - .addParticipants(Arrays.asList(firstParticipant.raw(), secondParticipant.raw())) - .send(); - final List participants = flexiblePrivacyGroupManagementProxy.getParticipants().send(); - assertThat(participants.size()).isEqualTo(2); - assertThat(firstParticipant.raw()).isEqualTo(participants.get(0)); - assertThat(secondParticipant.raw()).isEqualTo(participants.get(1)); - - final DefaultFlexiblePrivacyGroupManagementContract upgradedContract = - minerNode.execute( - contractTransactions.createSmartContract( - DefaultFlexiblePrivacyGroupManagementContract.class)); - - final HttpService httpService = - new HttpService( - "http://" + minerNode.getHostName() + ":" + minerNode.getJsonRpcPort().get()); - final Web3j web3j = Web3j.build(httpService); - - // load the proxy contract, use it with another signer - final FlexiblePrivacyGroupManagementProxy proxyContractAccount2 = - FlexiblePrivacyGroupManagementProxy.load( - flexiblePrivacyGroupManagementProxy.getContractAddress(), - web3j, - Credentials.create(Accounts.GENESIS_ACCOUNT_TWO_PRIVATE_KEY), - new DefaultGasProvider()); - // contract is the proxy contract and uses genesis account 2. It should not be able to upgrade - // the contract, because it is not the owner of "upgradedContract" - assertThatThrownBy( - () -> proxyContractAccount2.upgradeTo(upgradedContract.getContractAddress()).send()) - .isInstanceOf(TransactionException.class); - } - - @Test - public void ownerCanUpgrade() throws Exception { - flexiblePrivacyGroupManagementProxy - .addParticipants(Arrays.asList(firstParticipant.raw(), secondParticipant.raw())) - .send(); - final List participants = flexiblePrivacyGroupManagementProxy.getParticipants().send(); - assertThat(participants.size()).isEqualTo(2); - assertThat(firstParticipant.raw()).isEqualTo(participants.get(0)); - assertThat(secondParticipant.raw()).isEqualTo(participants.get(1)); - - final DefaultFlexiblePrivacyGroupManagementContract upgradedContract = - minerNode.execute( - contractTransactions.createSmartContract( - DefaultFlexiblePrivacyGroupManagementContract.class)); - - flexiblePrivacyGroupManagementProxy.upgradeTo(upgradedContract.getContractAddress()).send(); - final List participantsAfterUpgrade = - flexiblePrivacyGroupManagementProxy.getParticipants().send(); - assertThat(participantsAfterUpgrade.size()).isEqualTo(2); - assertThat(firstParticipant.raw()).isEqualTo(participantsAfterUpgrade.get(0)); - assertThat(secondParticipant.raw()).isEqualTo(participantsAfterUpgrade.get(1)); - } - - @Test - public void canAddTwiceToContractWhenCallLock() throws Exception { - flexiblePrivacyGroupManagementProxy - .addParticipants(Arrays.asList(firstParticipant.raw(), thirdParticipant.raw())) - .send(); - flexiblePrivacyGroupManagementProxy.lock().send(); - flexiblePrivacyGroupManagementProxy - .addParticipants(Collections.singletonList(secondParticipant.raw())) - .send(); - final List participants = flexiblePrivacyGroupManagementProxy.getParticipants().send(); - assertThat(participants.size()).isEqualTo(3); - assertThat(firstParticipant.raw()).isEqualTo(participants.get(0)); - assertThat(thirdParticipant.raw()).isEqualTo(participants.get(1)); - assertThat(secondParticipant.raw()).isEqualTo(participants.get(2)); - } -} diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyAcceptanceTest.java deleted file mode 100644 index b1c175f6461..00000000000 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyAcceptanceTest.java +++ /dev/null @@ -1,408 +0,0 @@ -/* - * 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.privacy.multitenancy; - -import static com.github.tomakehurst.wiremock.client.WireMock.ok; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; -import static java.nio.charset.StandardCharsets.UTF_8; -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; -import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; - -import org.hyperledger.besu.crypto.KeyPair; -import org.hyperledger.besu.crypto.SignatureAlgorithm; -import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.enclave.types.PrivacyGroup; -import org.hyperledger.besu.enclave.types.ReceiveResponse; -import org.hyperledger.besu.enclave.types.SendResponse; -import org.hyperledger.besu.ethereum.privacy.PrivacyGroupUtil; -import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; -import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; -import org.hyperledger.besu.plugin.data.Restriction; -import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; -import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; -import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.Cluster; -import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfiguration; -import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; -import javax.annotation.Nonnull; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { - private BesuNode node; - private final ObjectMapper mapper = new ObjectMapper(); - private Cluster multiTenancyCluster; - - private static final Supplier SIGNATURE_ALGORITHM = - Suppliers.memoize(SignatureAlgorithmFactory::getInstance); - private static final KeyPair TEST_KEY = - SIGNATURE_ALGORITHM - .get() - .createKeyPair( - SIGNATURE_ALGORITHM - .get() - .createPrivateKey( - new BigInteger( - "853d7f0010fd86d0d7811c1f9d968ea89a24484a8127b4a483ddf5d2cfec766d", 16))); - private static final String PRIVACY_GROUP_ID = "B1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; - private static final String PARTICIPANT_ENCLAVE_KEY0 = - "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; - private static final Bytes LEAGCY_PRIVATE_FROM = Bytes.fromBase64String(PARTICIPANT_ENCLAVE_KEY0); - private static final String PARTICIPANT_ENCLAVE_KEY1 = - "sgFkVOyFndZe/5SAZJO5UYbrl7pezHetveriBBWWnE8="; - private static final List LEGACY_PRIVATE_FOR = - List.of(Bytes.fromBase64String(PARTICIPANT_ENCLAVE_KEY1)); - private static final String PARTICIPANT_ENCLAVE_KEY2 = - "R1kW75NQC9XX3kwNpyPjCBFflM29+XvnKKS9VLrUkzo="; - private static final String PARTICIPANT_ENCLAVE_KEY3 = - "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; - private final Address senderAddress = - Address.wrap(Bytes.fromHexString(accounts.getPrimaryBenefactor().getAddress())); - - @Rule public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort()); - - @Before - public void setUp() throws Exception { - final ClusterConfiguration clusterConfiguration = - new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build(); - multiTenancyCluster = new Cluster(clusterConfiguration, net); - node = - besu.createNodeWithMultiTenantedPrivacy( - "node1", - "http://127.0.0.1:" + wireMockRule.port(), - "authentication/auth_priv.toml", - "authentication/auth_priv_key", - false, - false); - multiTenancyCluster.start(node); - final String token = - node.execute(permissioningTransactions.createSuccessfulLogin("user", "pegasys")); - node.useAuthenticationTokenInHeaderForJsonRpc(token); - } - - @After - public void tearDown() { - multiTenancyCluster.close(); - } - - @Test - public void privGetPrivacyPrecompileAddressShouldReturnExpectedAddress() { - node.verify(priv.getPrivacyPrecompileAddress(DEFAULT_PRIVACY)); - } - - @Test - public void privGetPrivateTransactionSuccessShouldReturnExpectedPrivateTransaction() - throws JsonProcessingException { - final PrivateTransaction validSignedPrivateTransaction = - getValidSignedPrivateTransaction(senderAddress); - - receiveEnclaveStub(validSignedPrivateTransaction); - retrievePrivacyGroupEnclaveStub(); - sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1); - - final Hash transactionHash = - node.execute( - privacyTransactions.sendRawTransaction( - getRLPOutput(validSignedPrivateTransaction).encoded().toHexString())); - node.verify(priv.getSuccessfulTransactionReceipt(transactionHash)); - node.verify(priv.getPrivateTransaction(transactionHash, validSignedPrivateTransaction)); - } - - @Test - public void privCreatePrivacyGroupSuccessShouldReturnNewId() throws JsonProcessingException { - createPrivacyGroupEnclaveStub(); - - node.verify( - priv.createPrivacyGroup( - List.of(PARTICIPANT_ENCLAVE_KEY1, PARTICIPANT_ENCLAVE_KEY2, PARTICIPANT_ENCLAVE_KEY3), - "GroupName", - "Group description.", - PRIVACY_GROUP_ID)); - } - - @Test - public void privDeletePrivacyGroupSuccessShouldReturnId() throws JsonProcessingException { - retrievePrivacyGroupEnclaveStub(); - deletePrivacyGroupEnclaveStub(); - - node.verify(priv.deletePrivacyGroup(PRIVACY_GROUP_ID)); - } - - @Test - public void privFindPrivacyGroupSuccessShouldReturnExpectedGroupMembership() - throws JsonProcessingException { - final List groupMembership = - List.of( - testPrivacyGroup(singletonList(PARTICIPANT_ENCLAVE_KEY0), PrivacyGroup.Type.PANTHEON), - testPrivacyGroup(singletonList(PARTICIPANT_ENCLAVE_KEY0), PrivacyGroup.Type.PANTHEON), - testPrivacyGroup(singletonList(PARTICIPANT_ENCLAVE_KEY0), PrivacyGroup.Type.PANTHEON)); - - findPrivacyGroupEnclaveStub(groupMembership); - - node.verify(priv.findPrivacyGroup(groupMembership.size(), PARTICIPANT_ENCLAVE_KEY0)); - } - - @Test - public void eeaSendRawTransactionSuccessShouldReturnPrivateTransactionHash() - throws JsonProcessingException { - final PrivateTransaction validSignedPrivateTransaction = - getValidSignedPrivateTransaction(senderAddress); - - retrievePrivacyGroupEnclaveStub(); - sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1); - receiveEnclaveStub(validSignedPrivateTransaction); - - node.verify( - priv.eeaSendRawTransaction( - getRLPOutput(validSignedPrivateTransaction).encoded().toHexString())); - } - - @Test - public void privGetTransactionCountSuccessShouldReturnExpectedTransactionCount() - throws JsonProcessingException { - final PrivateTransaction validSignedPrivateTransaction = - getValidSignedPrivateTransaction(senderAddress); - final String accountAddress = validSignedPrivateTransaction.getSender().toHexString(); - final BytesValueRLPOutput rlpOutput = getRLPOutput(validSignedPrivateTransaction); - - retrievePrivacyGroupEnclaveStub(); - sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1); - receiveEnclaveStub(validSignedPrivateTransaction); - - node.verify(priv.getTransactionCount(accountAddress, PRIVACY_GROUP_ID, 0)); - final Hash transactionReceipt = - node.execute(privacyTransactions.sendRawTransaction(rlpOutput.encoded().toHexString())); - - node.verify(priv.getSuccessfulTransactionReceipt(transactionReceipt)); - node.verify(priv.getTransactionCount(accountAddress, PRIVACY_GROUP_ID, 1)); - } - - @Test - public void privDistributeRawTransactionSuccessShouldReturnEnclaveKey() - throws JsonProcessingException { - final String enclaveResponseKeyBytes = - Bytes.wrap(Bytes.fromBase64String(PARTICIPANT_ENCLAVE_KEY1)).toString(); - - retrievePrivacyGroupEnclaveStub(); - sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1); - - node.verify( - priv.distributeRawTransaction( - getRLPOutput(getValidSignedPrivateTransaction(senderAddress)).encoded().toHexString(), - enclaveResponseKeyBytes)); - } - - @Test - public void privGetTransactionReceiptSuccessShouldReturnTransactionReceiptAfterMined() - throws JsonProcessingException { - final PrivateTransaction validSignedPrivateTransaction = - getValidSignedPrivateTransaction(senderAddress); - final BytesValueRLPOutput rlpOutput = getRLPOutput(validSignedPrivateTransaction); - - retrievePrivacyGroupEnclaveStub(); - sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1); - receiveEnclaveStub(validSignedPrivateTransaction); - - final Hash transactionReceipt = - node.execute(privacyTransactions.sendRawTransaction(rlpOutput.encoded().toHexString())); - - node.verify(priv.getSuccessfulTransactionReceipt(transactionReceipt)); - } - - @Test - public void privGetEeaTransactionCountSuccessShouldReturnExpectedTransactionCount() - throws JsonProcessingException { - final PrivateTransaction validSignedPrivateTransaction = - getValidLegacySignedPrivateTransaction(senderAddress); - final String accountAddress = validSignedPrivateTransaction.getSender().toHexString(); - final String privateTxRlp = getRLPOutput(validSignedPrivateTransaction).encoded().toHexString(); - - retrieveEeaPrivacyGroupEnclaveStub(validSignedPrivateTransaction); - sendEnclaveStub( - Bytes32.ZERO.toBase64String()); // can be any value, as we are stubbing the enclave - receiveEnclaveStubEea(validSignedPrivateTransaction); - - final String privateFrom = validSignedPrivateTransaction.getPrivateFrom().toBase64String(); - final String[] privateFor = - validSignedPrivateTransaction.getPrivateFor().orElseThrow().stream() - .map(Bytes::toBase64String) - .toArray(String[]::new); - node.verify(priv.getEeaTransactionCount(accountAddress, privateFrom, privateFor, 0)); - - final Hash transactionHash = node.execute(privacyTransactions.sendRawTransaction(privateTxRlp)); - - node.verify(priv.getSuccessfulTransactionReceipt(transactionHash)); - - node.verify(priv.getEeaTransactionCount(accountAddress, privateFrom, privateFor, 1)); - } - - @Nonnull - private Bytes32 getPrivacyGroupIdFromEeaTransaction( - final PrivateTransaction validSignedPrivateTransaction) { - return PrivacyGroupUtil.calculateEeaPrivacyGroupId( - validSignedPrivateTransaction.getPrivateFrom(), - validSignedPrivateTransaction.getPrivateFor().get()); - } - - private void findPrivacyGroupEnclaveStub(final List groupMembership) - throws JsonProcessingException { - final String findGroupResponse = mapper.writeValueAsString(groupMembership); - stubFor(post("/findPrivacyGroup").willReturn(ok(findGroupResponse))); - } - - private void createPrivacyGroupEnclaveStub() throws JsonProcessingException { - final String createGroupResponse = - mapper.writeValueAsString(testPrivacyGroup(emptyList(), PrivacyGroup.Type.PANTHEON)); - stubFor(post("/createPrivacyGroup").willReturn(ok(createGroupResponse))); - } - - private void deletePrivacyGroupEnclaveStub() throws JsonProcessingException { - final String deleteGroupResponse = mapper.writeValueAsString(PRIVACY_GROUP_ID); - stubFor(post("/deletePrivacyGroup").willReturn(ok(deleteGroupResponse))); - } - - private void retrievePrivacyGroupEnclaveStub() throws JsonProcessingException { - final String retrieveGroupResponse = - mapper.writeValueAsString( - testPrivacyGroup( - List.of(PARTICIPANT_ENCLAVE_KEY0, PARTICIPANT_ENCLAVE_KEY1), - PrivacyGroup.Type.PANTHEON)); - stubFor(post("/retrievePrivacyGroup").willReturn(ok(retrieveGroupResponse))); - } - - private void retrieveEeaPrivacyGroupEnclaveStub(final PrivateTransaction tx) - throws JsonProcessingException { - final ArrayList members = new ArrayList<>(); - members.add(tx.getPrivateFrom().toBase64String()); - members.addAll( - tx.getPrivateFor().orElseThrow().stream() - .map(Bytes::toBase64String) - .collect(Collectors.toList())); - final String retrieveGroupResponse = - mapper.writeValueAsString(testPrivacyGroupEea(members, PrivacyGroup.Type.LEGACY)); - stubFor(post("/retrievePrivacyGroup").willReturn(ok(retrieveGroupResponse))); - } - - private void sendEnclaveStub(final String testKey) throws JsonProcessingException { - final String sendResponse = mapper.writeValueAsString(new SendResponse(testKey)); - stubFor(post("/send").willReturn(ok(sendResponse))); - } - - private void receiveEnclaveStub(final PrivateTransaction privTx) throws JsonProcessingException { - final BytesValueRLPOutput rlpOutput = getRLPOutputForReceiveResponse(privTx); - final String senderKey = privTx.getPrivateFrom().toBase64String(); - final String receiveResponse = - mapper.writeValueAsString( - new ReceiveResponse( - rlpOutput.encoded().toBase64String().getBytes(UTF_8), PRIVACY_GROUP_ID, senderKey)); - stubFor(post("/receive").willReturn(ok(receiveResponse))); - } - - private void receiveEnclaveStubEea(final PrivateTransaction privTx) - throws JsonProcessingException { - final BytesValueRLPOutput rlpOutput = getRLPOutputForReceiveResponse(privTx); - final String senderKey = privTx.getPrivateFrom().toBase64String(); - final String receiveResponse = - mapper.writeValueAsString( - new ReceiveResponse( - rlpOutput.encoded().toBase64String().getBytes(UTF_8), - getPrivacyGroupIdFromEeaTransaction(privTx).toBase64String(), - senderKey)); - stubFor(post("/receive").willReturn(ok(receiveResponse))); - } - - private BytesValueRLPOutput getRLPOutputForReceiveResponse( - final PrivateTransaction privateTransaction) { - final BytesValueRLPOutput bvrlpo = new BytesValueRLPOutput(); - privateTransaction.writeTo(bvrlpo); - return bvrlpo; - } - - private BytesValueRLPOutput getRLPOutput(final PrivateTransaction privateTransaction) { - final BytesValueRLPOutput bvrlpo = new BytesValueRLPOutput(); - privateTransaction.writeTo(bvrlpo); - return bvrlpo; - } - - private PrivacyGroup testPrivacyGroup( - final List groupMembers, final PrivacyGroup.Type groupType) { - return new PrivacyGroup(PRIVACY_GROUP_ID, groupType, "test", "testGroup", groupMembers); - } - - private PrivacyGroup testPrivacyGroupEea( - final List groupMembers, final PrivacyGroup.Type groupType) { - final Bytes32 privacyGroupId = - PrivacyGroupUtil.calculateEeaPrivacyGroupId( - Bytes.fromBase64String(groupMembers.get(0)), - groupMembers.stream() - .map(gm -> Bytes.fromBase64String(gm)) - .collect(Collectors.toList())); - return new PrivacyGroup( - privacyGroupId.toBase64String(), groupType, "test", "testGroup", groupMembers); - } - - private static PrivateTransaction getValidSignedPrivateTransaction(final Address senderAddress) { - return PrivateTransaction.builder() - .nonce(0) - .gasPrice(Wei.ZERO) - .gasLimit(3000000) - .to(null) - .value(Wei.ZERO) - .payload(Bytes.wrap(new byte[] {})) - .sender(senderAddress) - .chainId(BigInteger.valueOf(1337)) - .privateFrom(Bytes.fromBase64String(PARTICIPANT_ENCLAVE_KEY0)) - .restriction(Restriction.RESTRICTED) - .privacyGroupId(Bytes.fromBase64String(PRIVACY_GROUP_ID)) - .signAndBuild(TEST_KEY); - } - - private static PrivateTransaction getValidLegacySignedPrivateTransaction( - final Address senderAddress) { - return PrivateTransaction.builder() - .nonce(0) - .gasPrice(Wei.ZERO) - .gasLimit(3000000) - .to(null) - .value(Wei.ZERO) - .payload(Bytes.wrap(new byte[] {})) - .sender(senderAddress) - .chainId(BigInteger.valueOf(1337)) - .privateFrom(LEAGCY_PRIVATE_FROM) - .privateFor(LEGACY_PRIVATE_FOR) - .restriction(Restriction.RESTRICTED) - .signAndBuild(TEST_KEY); - } -} diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyPrivacyGroup.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyPrivacyGroup.java deleted file mode 100644 index a53a173a0d7..00000000000 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyPrivacyGroup.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.privacy.multitenancy; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -public class MultiTenancyPrivacyGroup { - - private final Map> map; - - public MultiTenancyPrivacyGroup() { - this.map = new HashMap<>(); - } - - public MultiTenancyPrivacyGroup addNodeWithTenants( - final MultiTenancyPrivacyNode privacyNode, final List tenants) { - map.put(privacyNode, tenants); - return this; - } - - public List getPrivacyNodes() { - return map.keySet().stream().collect(Collectors.toList()); - } - - public List getTenantsForNode(final MultiTenancyPrivacyNode privacyNode) { - return map.get(privacyNode); - } - - public List getTenants() { - return map.values().stream().flatMap(Collection::stream).collect(Collectors.toList()); - } - - public PrivacyNode getGroupCreatingPrivacyNode() { - return getPrivacyNodes().get(0).getPrivacyNode(); - } - - public String getGroupCreatingTenant() { - return getPrivacyNodes().get(0).getTenants().get(0); - } -} diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyPrivacyNode.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyPrivacyNode.java deleted file mode 100644 index 1126d440674..00000000000 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyPrivacyNode.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.privacy.multitenancy; - -import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -public class MultiTenancyPrivacyNode { - - private final PrivacyNode privacyNode; - private final Map tenantToTokenMap; - - public MultiTenancyPrivacyNode(final PrivacyNode privacyNode) { - this.privacyNode = privacyNode; - this.tenantToTokenMap = new HashMap<>(); - } - - public MultiTenancyPrivacyNode addTenantWithToken(final String tenant, final String token) { - tenantToTokenMap.put(tenant, token); - return this; - } - - public List getTenants() { - return tenantToTokenMap.keySet().stream().collect(Collectors.toList()); - } - - public String getTokenForTenant(final String tenant) { - return tenantToTokenMap.get(tenant); - } - - public PrivacyNode getPrivacyNode() { - return privacyNode; - } -} diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyPrivateNonceIncrementingTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyPrivateNonceIncrementingTest.java deleted file mode 100644 index 11c405c37a8..00000000000 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyPrivateNonceIncrementingTest.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.privacy.multitenancy; - -import static com.github.tomakehurst.wiremock.client.WireMock.ok; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; -import static java.nio.charset.StandardCharsets.UTF_8; - -import org.hyperledger.besu.crypto.KeyPair; -import org.hyperledger.besu.crypto.SignatureAlgorithm; -import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.enclave.types.PrivacyGroup; -import org.hyperledger.besu.enclave.types.ReceiveResponse; -import org.hyperledger.besu.enclave.types.SendResponse; -import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; -import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; -import org.hyperledger.besu.plugin.data.Restriction; -import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; -import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; -import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.Cluster; -import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfiguration; -import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; - -import java.math.BigInteger; -import java.util.List; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import org.apache.tuweni.bytes.Bytes; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -public class MultiTenancyPrivateNonceIncrementingTest extends AcceptanceTestBase { - private BesuNode node; - private final ObjectMapper mapper = new ObjectMapper(); - private Cluster multiTenancyCluster; - - private static final Supplier SIGNATURE_ALGORITHM = - Suppliers.memoize(SignatureAlgorithmFactory::getInstance); - private static final KeyPair TEST_KEY = - SIGNATURE_ALGORITHM - .get() - .createKeyPair( - SIGNATURE_ALGORITHM - .get() - .createPrivateKey( - new BigInteger( - "853d7f0010fd86d0d7811c1f9d968ea89a24484a8127b4a483ddf5d2cfec766d", 16))); - private static final String PRIVACY_GROUP_ID = "B1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; - private static final String PARTICIPANT_ENCLAVE_KEY0 = - "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; - private static final String PARTICIPANT_ENCLAVE_KEY1 = - "sgFkVOyFndZe/5SAZJO5UYbrl7pezHetveriBBWWnE8="; - private final Address senderAddress = - Address.wrap(Bytes.fromHexString(accounts.getPrimaryBenefactor().getAddress())); - - @Rule public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort()); - - @Before - public void setUp() throws Exception { - final ClusterConfiguration clusterConfiguration = - new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build(); - multiTenancyCluster = new Cluster(clusterConfiguration, net); - node = - besu.createNodeWithMultiTenantedPrivacy( - "node1", - "http://127.0.0.1:" + wireMockRule.port(), - "authentication/auth_priv.toml", - "authentication/auth_priv_key", - false, - true); - multiTenancyCluster.start(node); - final String token = - node.execute(permissioningTransactions.createSuccessfulLogin("user", "pegasys")); - node.useAuthenticationTokenInHeaderForJsonRpc(token); - } - - @After - public void tearDown() { - multiTenancyCluster.close(); - } - - @Test - public void validateUnsuccessfulPrivateTransactionsNonceIncrementation() - throws JsonProcessingException { - executePrivateFailingTransaction(0, 0, 1); - executePrivateValidTransaction(1, 1, 2); - executePrivateFailingTransaction(2, 2, 3); - executePrivateFailingTransaction(3, 3, 4); - executePrivateValidTransaction(4, 4, 5); - } - - private void executePrivateValidTransaction( - final int nonce, - final int expectedTransactionCountBeforeExecution, - final int expectedTransactionCountAfterExecution) - throws JsonProcessingException { - final PrivateTransaction validSignedPrivateTransaction = - getValidSignedPrivateTransaction(senderAddress, nonce); - - final String accountAddress = validSignedPrivateTransaction.getSender().toHexString(); - final BytesValueRLPOutput rlpOutput = getRLPOutput(validSignedPrivateTransaction); - - processEnclaveStub(validSignedPrivateTransaction); - - node.verify( - priv.getTransactionCount( - accountAddress, PRIVACY_GROUP_ID, expectedTransactionCountBeforeExecution)); - - final Hash transactionReceipt = - node.execute(privacyTransactions.sendRawTransaction(rlpOutput.encoded().toHexString())); - - node.verify(priv.getSuccessfulTransactionReceipt(transactionReceipt)); - node.verify( - priv.getTransactionCount( - accountAddress, PRIVACY_GROUP_ID, expectedTransactionCountAfterExecution)); - } - - private void executePrivateFailingTransaction( - final int nonce, - final int expectedTransactionCountBeforeExecution, - final int expectedTransactionCountAfterExecution) - throws JsonProcessingException { - final PrivateTransaction invalidSignedPrivateTransaction = - getInvalidSignedPrivateTransaction(senderAddress, nonce); - final String accountAddress = invalidSignedPrivateTransaction.getSender().toHexString(); - final BytesValueRLPOutput invalidTxRlp = getRLPOutput(invalidSignedPrivateTransaction); - - processEnclaveStub(invalidSignedPrivateTransaction); - - node.verify( - priv.getTransactionCount( - accountAddress, PRIVACY_GROUP_ID, expectedTransactionCountBeforeExecution)); - final Hash invalidTransactionReceipt = - node.execute(privacyTransactions.sendRawTransaction(invalidTxRlp.encoded().toHexString())); - - node.verify(priv.getFailedTransactionReceipt(invalidTransactionReceipt)); - node.verify( - priv.getTransactionCount( - accountAddress, PRIVACY_GROUP_ID, expectedTransactionCountAfterExecution)); - } - - private void processEnclaveStub(final PrivateTransaction validSignedPrivateTransaction) - throws JsonProcessingException { - retrievePrivacyGroupEnclaveStub(); - sendEnclaveStub(); - receiveEnclaveStub(validSignedPrivateTransaction); - } - - private void retrievePrivacyGroupEnclaveStub() throws JsonProcessingException { - final String retrieveGroupResponse = - mapper.writeValueAsString( - createPrivacyGroup( - List.of(PARTICIPANT_ENCLAVE_KEY0, PARTICIPANT_ENCLAVE_KEY1), - PrivacyGroup.Type.PANTHEON)); - stubFor(post("/retrievePrivacyGroup").willReturn(ok(retrieveGroupResponse))); - } - - private void sendEnclaveStub() throws JsonProcessingException { - final String sendResponse = - mapper.writeValueAsString(new SendResponse(PARTICIPANT_ENCLAVE_KEY1)); - stubFor(post("/send").willReturn(ok(sendResponse))); - } - - private void receiveEnclaveStub(final PrivateTransaction privTx) throws JsonProcessingException { - final BytesValueRLPOutput rlpOutput = getRLPOutput(privTx); - final String senderKey = privTx.getPrivateFrom().toBase64String(); - final String receiveResponse = - mapper.writeValueAsString( - new ReceiveResponse( - rlpOutput.encoded().toBase64String().getBytes(UTF_8), PRIVACY_GROUP_ID, senderKey)); - stubFor(post("/receive").willReturn(ok(receiveResponse))); - } - - private BytesValueRLPOutput getRLPOutput(final PrivateTransaction privateTransaction) { - final BytesValueRLPOutput bvrlpo = new BytesValueRLPOutput(); - privateTransaction.writeTo(bvrlpo); - return bvrlpo; - } - - private PrivacyGroup createPrivacyGroup( - final List groupMembers, final PrivacyGroup.Type groupType) { - return new PrivacyGroup(PRIVACY_GROUP_ID, groupType, "test", "testGroup", groupMembers); - } - - private static PrivateTransaction getInvalidSignedPrivateTransaction( - final Address senderAddress, final int nonce) { - return PrivateTransaction.builder() - .nonce(nonce) - .gasPrice(Wei.ZERO) - .gasLimit(3000000) - .to(null) - .value(Wei.ZERO) - .payload(Bytes.fromHexString("0x1234")) - .sender(senderAddress) - .chainId(BigInteger.valueOf(1337)) - .privateFrom(Bytes.fromBase64String(PARTICIPANT_ENCLAVE_KEY0)) - .restriction(Restriction.RESTRICTED) - .privacyGroupId(Bytes.fromBase64String(PRIVACY_GROUP_ID)) - .signAndBuild(TEST_KEY); - } - - private static PrivateTransaction getValidSignedPrivateTransaction( - final Address senderAddress, final int nonce) { - return PrivateTransaction.builder() - .nonce(nonce) - .gasPrice(Wei.ZERO) - .gasLimit(3000000) - .to(null) - .value(Wei.ZERO) - .payload(Bytes.wrap(new byte[] {})) - .sender(senderAddress) - .chainId(BigInteger.valueOf(1337)) - .privateFrom(Bytes.fromBase64String(PARTICIPANT_ENCLAVE_KEY0)) - .restriction(Restriction.RESTRICTED) - .privacyGroupId(Bytes.fromBase64String(PRIVACY_GROUP_ID)) - .signAndBuild(TEST_KEY); - } -} diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyValidationFailAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyValidationFailAcceptanceTest.java deleted file mode 100644 index 28bf140bb36..00000000000 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyValidationFailAcceptanceTest.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * 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.privacy.multitenancy; - -import static com.github.tomakehurst.wiremock.client.WireMock.ok; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.DELETE_PRIVACY_GROUP_ERROR; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.ENCLAVE_ERROR; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.FIND_PRIVACY_GROUP_ERROR; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.GET_PRIVATE_TRANSACTION_NONCE_ERROR; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY; - -import org.hyperledger.besu.crypto.SignatureAlgorithm; -import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.enclave.types.PrivacyGroup; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; -import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; -import org.hyperledger.besu.plugin.data.Restriction; -import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; -import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; -import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.Cluster; -import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfiguration; -import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; -import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; - -import java.math.BigInteger; -import java.util.List; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import org.apache.tuweni.bytes.Bytes; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -public class MultiTenancyValidationFailAcceptanceTest extends AcceptanceTestBase { - private BesuNode node; - private final ObjectMapper mapper = new ObjectMapper(); - private Cluster multiTenancyCluster; - - private static final String PRIVACY_GROUP_ID = "B1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; - private static final String ENCLAVE_PUBLIC_KEY = "B1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; - private static final String OTHER_ENCLAVE_PUBLIC_KEY = - "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; - private final Address senderAddress = - Address.wrap(Bytes.fromHexString(accounts.getPrimaryBenefactor().getAddress())); - - @Rule public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort()); - - @Before - public void setUp() throws Exception { - final ClusterConfiguration clusterConfiguration = - new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build(); - multiTenancyCluster = new Cluster(clusterConfiguration, net); - node = - besu.createNodeWithMultiTenantedPrivacy( - "node1", - "http://127.0.0.1:" + wireMockRule.port(), - "authentication/auth_priv.toml", - "authentication/auth_priv_key", - false, - false); - multiTenancyCluster.start(node); - - final String token = - node.execute(permissioningTransactions.createSuccessfulLogin("failUser", "pegasys")); - node.useAuthenticationTokenInHeaderForJsonRpc(token); - } - - @After - public void tearDown() { - multiTenancyCluster.close(); - } - - @Test - public void sendRawTransactionShouldFailWhenPrivateFromNotMatchEnclaveKey() - throws JsonProcessingException { - final PrivateTransaction validSignedPrivateTransaction = - getValidSignedPrivateTransaction(senderAddress, OTHER_ENCLAVE_PUBLIC_KEY); - retrievePrivacyGroupEnclaveStub(); - final Transaction transaction = - privacyTransactions.sendRawTransaction( - getRLPOutput(validSignedPrivateTransaction).encoded().toHexString()); - node.verify( - priv.multiTenancyValidationFail( - transaction, RpcErrorType.PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY)); - } - - @Test - public void sendRawTransactionShouldFailWhenPrivacyGroupDoesNotContainEnclaveKey() - throws JsonProcessingException { - final PrivateTransaction validSignedPrivateTransaction = - getValidSignedPrivateTransaction(senderAddress, ENCLAVE_PUBLIC_KEY); - retrievePrivacyGroupEnclaveStub(); - final Transaction transaction = - privacyTransactions.sendRawTransaction( - getRLPOutput(validSignedPrivateTransaction).encoded().toHexString()); - node.verify(priv.multiTenancyValidationFail(transaction, ENCLAVE_ERROR)); - } - - @Test - public void distributeRawTransactionShouldFailWhenPrivateFromNotMatchEnclaveKey() { - final Address senderAddress = - Address.wrap(Bytes.fromHexString(accounts.getPrimaryBenefactor().getAddress())); - - final Transaction transaction = - privacyTransactions.distributeRawTransaction( - getRLPOutput(getValidSignedPrivateTransaction(senderAddress, OTHER_ENCLAVE_PUBLIC_KEY)) - .encoded() - .toHexString()); - node.verify( - priv.multiTenancyValidationFail( - transaction, PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY)); - } - - @Test - public void distributeRawTransactionShouldFailWhenPrivacyGroupDoesNotContainEnclaveKey() - throws JsonProcessingException { - final Address senderAddress = - Address.wrap(Bytes.fromHexString(accounts.getPrimaryBenefactor().getAddress())); - - retrievePrivacyGroupEnclaveStub(); - - final Transaction transaction = - privacyTransactions.distributeRawTransaction( - getRLPOutput(getValidSignedPrivateTransaction(senderAddress, ENCLAVE_PUBLIC_KEY)) - .encoded() - .toHexString()); - node.verify(priv.multiTenancyValidationFail(transaction, ENCLAVE_ERROR)); - } - - @Test - public void deletePrivacyGroupShouldFailWhenEnclaveKeyNotInPrivacyGroup() - throws JsonProcessingException { - retrievePrivacyGroupEnclaveStub(); - final Transaction transaction = - privacyTransactions.deletePrivacyGroup(PRIVACY_GROUP_ID); - node.verify(priv.multiTenancyValidationFail(transaction, DELETE_PRIVACY_GROUP_ERROR)); - } - - @Test - public void findPrivacyGroupShouldFailWhenEnclaveKeyNotInPrivacyGroup() { - final Transaction transaction = - privacyTransactions.findPrivacyGroup(new String[] {OTHER_ENCLAVE_PUBLIC_KEY}); - node.verify(priv.multiTenancyValidationFail(transaction, FIND_PRIVACY_GROUP_ERROR)); - } - - @Test - public void determineEeaNonceShouldFailWhenPrivateFromNotMatchEnclaveKey() { - final String accountAddress = Address.ZERO.toHexString(); - final String senderAddressBase64 = Bytes.fromHexString(accountAddress).toBase64String(); - final String[] privateFor = {senderAddressBase64}; - final Transaction transaction = - privacyTransactions.getEeaTransactionCount( - accountAddress, OTHER_ENCLAVE_PUBLIC_KEY, privateFor); - node.verify( - priv.multiTenancyValidationFail( - transaction, PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY)); - } - - @Test - public void determineBesuNonceShouldFailWhenEnclaveKeyNotInPrivacyGroup() - throws JsonProcessingException { - retrievePrivacyGroupEnclaveStub(); - final String accountAddress = Address.ZERO.toHexString(); - final Transaction transaction = - privacyTransactions.getTransactionCount(accountAddress, PRIVACY_GROUP_ID); - node.verify(priv.multiTenancyValidationFail(transaction, GET_PRIVATE_TRANSACTION_NONCE_ERROR)); - } - - private void retrievePrivacyGroupEnclaveStub() throws JsonProcessingException { - final String retrieveGroupResponse = - mapper.writeValueAsString( - testPrivacyGroup(List.of(OTHER_ENCLAVE_PUBLIC_KEY), PrivacyGroup.Type.PANTHEON)); - stubFor(post("/retrievePrivacyGroup").willReturn(ok(retrieveGroupResponse))); - } - - private PrivacyGroup testPrivacyGroup( - final List groupMembers, final PrivacyGroup.Type groupType) { - return new PrivacyGroup(PRIVACY_GROUP_ID, groupType, "test", "testGroup", groupMembers); - } - - private BytesValueRLPOutput getRLPOutput(final PrivateTransaction validSignedPrivateTransaction) { - final BytesValueRLPOutput bvrlpo = new BytesValueRLPOutput(); - validSignedPrivateTransaction.writeTo(bvrlpo); - return bvrlpo; - } - - private static PrivateTransaction getValidSignedPrivateTransaction( - final Address senderAddress, final String privateFrom) { - - final SignatureAlgorithm signatureAlgorithm = SignatureAlgorithmFactory.getInstance(); - - return PrivateTransaction.builder() - .nonce(0) - .gasPrice(Wei.ZERO) - .gasLimit(3000000) - .to(null) - .value(Wei.ZERO) - .payload(Bytes.wrap(new byte[] {})) - .sender(senderAddress) - .chainId(BigInteger.valueOf(2018)) - .privateFrom(Bytes.fromBase64String(privateFrom)) - .restriction(Restriction.RESTRICTED) - .privacyGroupId(Bytes.fromBase64String(PRIVACY_GROUP_ID)) - .signAndBuild( - signatureAlgorithm.createKeyPair( - signatureAlgorithm.createPrivateKey( - new BigInteger( - "853d7f0010fd86d0d7811c1f9d968ea89a24484a8127b4a483ddf5d2cfec766d", 16)))); - } -}