From 572b03b22661c6b8535b4c4afc65b02c716f5985 Mon Sep 17 00:00:00 2001 From: Ivaylo Kirilov Date: Fri, 30 Aug 2019 01:07:45 +0100 Subject: [PATCH] [PAN-3071] Use object parameter instead of list of parameters for priv_createPrivacyGroup (#1868) --- .../dsl/privacy/PrivateTransactions.java | 12 + ...acyGroupTransactionWithoutDescription.java | 44 +++ ...atePrivacyGroupTransactionWithoutName.java | 44 +++ .../transaction/priv/PrivRequestFactory.java | 27 +- .../privacy/PrivacyGroupAcceptanceTest.java | 88 +++++- ...vGetPrivateTransactionIntegrationTest.java | 2 +- .../jsonrpc/JsonRpcMethodsFactory.java | 21 +- .../methods}/eea/EeaGetTransactionCount.java | 2 +- .../eea/EeaGetTransactionReceipt.java | 2 +- .../methods}/eea/EeaPrivateNonceProvider.java | 2 +- .../methods}/eea/EeaSendRawTransaction.java | 2 +- .../methods}/priv/PrivCreatePrivacyGroup.java | 27 +- .../methods}/priv/PrivDeletePrivacyGroup.java | 2 +- .../methods}/priv/PrivFindPrivacyGroup.java | 2 +- .../priv/PrivGetPrivacyPrecompileAddress.java | 2 +- .../priv/PrivGetPrivateTransaction.java | 2 +- .../priv/PrivGetTransactionCount.java | 2 +- .../CreatePrivacyGroupParameter.java | 50 ++++ .../eea/EeaGetTransactionCountTest.java | 2 + .../eea/EeaPrivateNonceProviderTest.java | 1 + .../eea/PrivCreatePrivacyGroupTest.java | 67 ----- .../eea/EeaGetTransactionReceiptTest.java | 2 +- .../eea/EeaSendRawTransactionTest.java | 2 +- .../priv/PrivCreatePrivacyGroupTest.java | 252 ++++++++++++++++++ .../PrivGetPrivacyPrecompileAddressTest.java | 2 +- .../priv}/PrivGetPrivateTransactionTest.java | 3 +- .../priv}/PrivGetTransactionCountTest.java | 3 +- 27 files changed, 555 insertions(+), 112 deletions(-) create mode 100644 acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/priv/PrivCreatePrivacyGroupTransactionWithoutDescription.java create mode 100644 acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/priv/PrivCreatePrivacyGroupTransactionWithoutName.java rename ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy => privacy/methods}/eea/EeaGetTransactionCount.java (97%) rename ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy => privacy/methods}/eea/EeaGetTransactionReceipt.java (98%) rename ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy => privacy/methods}/eea/EeaPrivateNonceProvider.java (96%) rename ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy => privacy/methods}/eea/EeaSendRawTransaction.java (98%) rename ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy => privacy/methods}/priv/PrivCreatePrivacyGroup.java (76%) rename ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy => privacy/methods}/priv/PrivDeletePrivacyGroup.java (97%) rename ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy => privacy/methods}/priv/PrivFindPrivacyGroup.java (97%) rename ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy => privacy/methods}/priv/PrivGetPrivacyPrecompileAddress.java (96%) rename ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy => privacy/methods}/priv/PrivGetPrivateTransaction.java (98%) rename ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy => privacy/methods}/priv/PrivGetTransactionCount.java (96%) create mode 100644 ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/parameters/CreatePrivacyGroupParameter.java delete mode 100644 ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/PrivCreatePrivacyGroupTest.java rename ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy => privacy/methods}/eea/EeaGetTransactionReceiptTest.java (99%) rename ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy => privacy/methods}/eea/EeaSendRawTransactionTest.java (99%) create mode 100644 ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroupTest.java rename ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy => privacy/methods}/priv/PrivGetPrivacyPrecompileAddressTest.java (97%) rename ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy/eea => privacy/methods/priv}/PrivGetPrivateTransactionTest.java (97%) rename ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/{methods/privacy/eea => privacy/methods/priv}/PrivGetTransactionCountTest.java (93%) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/PrivateTransactions.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/PrivateTransactions.java index a95e7a2834..053e9b6d37 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/PrivateTransactions.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/PrivateTransactions.java @@ -14,6 +14,8 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eea.EeaSendRawTransactionTransaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv.PrivCreatePrivacyGroupTransaction; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv.PrivCreatePrivacyGroupTransactionWithoutDescription; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv.PrivCreatePrivacyGroupTransactionWithoutName; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv.PrivCreatePrivacyGroupWithoutOptionalParamsTransaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv.PrivFindPrivacyGroupTransaction; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv.PrivGetTransactionCountTransaction; @@ -44,6 +46,16 @@ public PrivCreatePrivacyGroupTransaction createPrivacyGroup( return new PrivCreatePrivacyGroupTransaction(addresses, name, description); } + public PrivCreatePrivacyGroupTransactionWithoutName createPrivacyGroupWithoutName( + final List addresses, final String description) { + return new PrivCreatePrivacyGroupTransactionWithoutName(addresses, description); + } + + public PrivCreatePrivacyGroupTransactionWithoutDescription createPrivacyGroupWithoutDescription( + final List addresses, final String name) { + return new PrivCreatePrivacyGroupTransactionWithoutDescription(addresses, name); + } + public PrivCreatePrivacyGroupWithoutOptionalParamsTransaction createPrivacyGroupWithoutOptionalParams(final List addresses) { return new PrivCreatePrivacyGroupWithoutOptionalParamsTransaction(addresses); diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/priv/PrivCreatePrivacyGroupTransactionWithoutDescription.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/priv/PrivCreatePrivacyGroupTransactionWithoutDescription.java new file mode 100644 index 0000000000..8924984a29 --- /dev/null +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/priv/PrivCreatePrivacyGroupTransactionWithoutDescription.java @@ -0,0 +1,44 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv; + +import static org.assertj.core.api.Assertions.assertThat; + +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.NodeRequests; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; + +import java.io.IOException; +import java.util.List; + +public class PrivCreatePrivacyGroupTransactionWithoutDescription implements Transaction { + private final List addresses; + private final String name; + + public PrivCreatePrivacyGroupTransactionWithoutDescription( + final List addresses, final String name) { + this.addresses = addresses; + this.name = name; + } + + @Override + public String execute(final NodeRequests node) { + try { + final PrivRequestFactory.PrivCreatePrivacyGroupResponse result = + node.priv().privCreatePrivacyGroupWithoutDescription(addresses, name).send(); + assertThat(result).isNotNull(); + return result.getResult(); + } catch (final IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/priv/PrivCreatePrivacyGroupTransactionWithoutName.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/priv/PrivCreatePrivacyGroupTransactionWithoutName.java new file mode 100644 index 0000000000..796f4fba03 --- /dev/null +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/priv/PrivCreatePrivacyGroupTransactionWithoutName.java @@ -0,0 +1,44 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv; + +import static org.assertj.core.api.Assertions.assertThat; + +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.NodeRequests; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; + +import java.io.IOException; +import java.util.List; + +public class PrivCreatePrivacyGroupTransactionWithoutName implements Transaction { + private final List addresses; + private final String description; + + public PrivCreatePrivacyGroupTransactionWithoutName( + final List addresses, final String description) { + this.addresses = addresses; + this.description = description; + } + + @Override + public String execute(final NodeRequests node) { + try { + final PrivRequestFactory.PrivCreatePrivacyGroupResponse result = + node.priv().privCreatePrivacyGroupWithoutName(addresses, description).send(); + assertThat(result).isNotNull(); + return result.getResult(); + } catch (final IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/priv/PrivRequestFactory.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/priv/PrivRequestFactory.java index c8faa0af90..700496ad63 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/priv/PrivRequestFactory.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/priv/PrivRequestFactory.java @@ -13,6 +13,7 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv; import tech.pegasys.pantheon.enclave.types.PrivacyGroup; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.parameters.CreatePrivacyGroupParameter; import java.util.Collections; import java.util.List; @@ -48,7 +49,28 @@ public Request privCreatePrivacyGroup( final List addresses, final String name, final String description) { return new Request<>( "priv_createPrivacyGroup", - Lists.newArrayList(addresses, name, description), + Lists.newArrayList( + new CreatePrivacyGroupParameter(addresses.toArray(new String[] {}), name, description)), + web3jService, + PrivCreatePrivacyGroupResponse.class); + } + + public Request privCreatePrivacyGroupWithoutName( + final List addresses, final String description) { + return new Request<>( + "priv_createPrivacyGroup", + Collections.singletonList( + new CreatePrivacyGroupParameter(addresses.toArray(new String[] {}), null, description)), + web3jService, + PrivCreatePrivacyGroupResponse.class); + } + + public Request privCreatePrivacyGroupWithoutDescription( + final List addresses, final String name) { + return new Request<>( + "priv_createPrivacyGroup", + Collections.singletonList( + new CreatePrivacyGroupParameter(addresses.toArray(new String[] {}), name, null)), web3jService, PrivCreatePrivacyGroupResponse.class); } @@ -57,7 +79,8 @@ public Request privCreatePrivacyGroupWithoutO final List addresses) { return new Request<>( "priv_createPrivacyGroup", - Collections.singletonList(addresses), + Collections.singletonList( + new CreatePrivacyGroupParameter(addresses.toArray(new String[] {}), null, null)), web3jService, PrivCreatePrivacyGroupResponse.class); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/privacy/PrivacyGroupAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/privacy/PrivacyGroupAcceptanceTest.java index 7041bee6db..fc2d4e6ffb 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/privacy/PrivacyGroupAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/web3j/privacy/PrivacyGroupAcceptanceTest.java @@ -22,6 +22,7 @@ import java.util.List; +import org.awaitility.Awaitility; import org.junit.Before; import org.junit.Test; @@ -86,7 +87,7 @@ public void nodeCanCreatePrivacyGroup() { "my group description")); assertThat(privacyGroupId).isNotNull(); - + verifyGroupWasCreated(); final List privacyGroups = privacyNet .getNode("Alice") @@ -103,6 +104,66 @@ public void nodeCanCreatePrivacyGroup() { assertThat(privacyGroups.get(0).getMembers().length).isEqualTo(2); } + @Test + public void nodeCanCreatePrivacyGroupWithoutName() { + final String privacyGroupId = + privacyNet + .getNode("Alice") + .execute( + privateTransactions.createPrivacyGroupWithoutName( + List.of( + privacyNet.getEnclave("Alice").getPublicKeys().get(0), + privacyNet.getEnclave("Bob").getPublicKeys().get(0)), + "my group description")); + + assertThat(privacyGroupId).isNotNull(); + verifyGroupWasCreated(); + final List privacyGroups = + privacyNet + .getNode("Alice") + .execute( + privateTransactions.findPrivacyGroup( + List.of( + privacyNet.getEnclave("Alice").getPublicKeys().get(0), + privacyNet.getEnclave("Bob").getPublicKeys().get(0)))); + + assertThat(privacyGroups.size()).isEqualTo(1); + assertThat(privacyGroups.get(0).getPrivacyGroupId()).isEqualTo(privacyGroupId); + assertThat(privacyGroups.get(0).getName()).isEqualTo("Default Name"); + assertThat(privacyGroups.get(0).getDescription()).isEqualTo("my group description"); + assertThat(privacyGroups.get(0).getMembers().length).isEqualTo(2); + } + + @Test + public void nodeCanCreatePrivacyGroupWithoutDescription() { + final String privacyGroupId = + privacyNet + .getNode("Alice") + .execute( + privateTransactions.createPrivacyGroupWithoutDescription( + List.of( + privacyNet.getEnclave("Alice").getPublicKeys().get(0), + privacyNet.getEnclave("Bob").getPublicKeys().get(0)), + "myGroupName")); + + assertThat(privacyGroupId).isNotNull(); + verifyGroupWasCreated(); + final List privacyGroups = + privacyNet + .getNode("Alice") + .execute( + privateTransactions.findPrivacyGroup( + List.of( + privacyNet.getEnclave("Alice").getPublicKeys().get(0), + privacyNet.getEnclave("Bob").getPublicKeys().get(0)))); + + assertThat(privacyGroups.size()).isEqualTo(1); + assertThat(privacyGroups.get(0).getPrivacyGroupId()).isEqualTo(privacyGroupId); + assertThat(privacyGroups.get(0).getName()).isEqualTo("myGroupName"); + assertThat(privacyGroups.get(0).getDescription()).isEqualTo("Default Description"); + assertThat(privacyGroups.get(0).getMembers().length).isEqualTo(2); + } + @Test public void nodeCanCreatePrivacyGroupWithoutOptionalParams() { final String privacyGroupId = @@ -115,7 +176,7 @@ public void nodeCanCreatePrivacyGroupWithoutOptionalParams() { privacyNet.getEnclave("Bob").getPublicKeys().get(0)))); assertThat(privacyGroupId).isNotNull(); - + verifyGroupWasCreated(); final List privacyGroups = privacyNet .getNode("Alice") @@ -131,4 +192,27 @@ public void nodeCanCreatePrivacyGroupWithoutOptionalParams() { assertThat(privacyGroups.get(0).getDescription()).isEqualTo("Default Description"); assertThat(privacyGroups.get(0).getMembers().length).isEqualTo(2); } + + private void verifyGroupWasCreated() { + privacyNet + .getNode("Alice") + .verify( + node -> + Awaitility.await() + .until( + () -> + node.execute( + privateTransactions.findPrivacyGroup( + List.of( + privacyNet + .getEnclave("Alice") + .getPublicKeys() + .get(0), + privacyNet + .getEnclave("Bob") + .getPublicKeys() + .get(0)))) + .size() + > 0)); + } } diff --git a/ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/methods/PrivGetPrivateTransactionIntegrationTest.java b/ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/methods/PrivGetPrivateTransactionIntegrationTest.java index e55dde9a01..fd620debec 100644 --- a/ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/methods/PrivGetPrivateTransactionIntegrationTest.java +++ b/ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/methods/PrivGetPrivateTransactionIntegrationTest.java @@ -31,8 +31,8 @@ import tech.pegasys.pantheon.ethereum.core.Transaction; import tech.pegasys.pantheon.ethereum.core.Wei; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv.PrivGetPrivateTransaction; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.parameters.JsonRpcParameter; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv.PrivGetPrivateTransaction; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.queries.BlockchainQueries; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.queries.TransactionWithMetadata; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java index 8df9745949..9de410a0ec 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java @@ -94,18 +94,17 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.permissioning.PermReloadPermissionsFromFile; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.permissioning.PermRemoveAccountsFromWhitelist; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.permissioning.PermRemoveNodesFromWhitelist; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.eea.EeaGetTransactionCount; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.eea.EeaGetTransactionReceipt; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.eea.EeaPrivateNonceProvider; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.eea.EeaSendRawTransaction; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv.PrivCreatePrivacyGroup; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv.PrivDeletePrivacyGroup; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv.PrivFindPrivacyGroup; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv.PrivGetCode; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv.PrivGetPrivacyPrecompileAddress; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv.PrivGetPrivateTransaction; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv.PrivGetTransactionCount; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.parameters.JsonRpcParameter; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.eea.EeaGetTransactionCount; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.eea.EeaGetTransactionReceipt; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.eea.EeaPrivateNonceProvider; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.eea.EeaSendRawTransaction; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv.PrivCreatePrivacyGroup; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv.PrivDeletePrivacyGroup; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv.PrivFindPrivacyGroup; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv.PrivGetPrivacyPrecompileAddress; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv.PrivGetPrivateTransaction; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv.PrivGetTransactionCount; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.processor.BlockReplay; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.processor.BlockTracer; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.processor.TransactionTracer; diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionCount.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaGetTransactionCount.java similarity index 97% rename from ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionCount.java rename to ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaGetTransactionCount.java index 6412c22038..c84118c848 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionCount.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaGetTransactionCount.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.eea; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.eea; import static org.apache.logging.log4j.LogManager.getLogger; diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionReceipt.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaGetTransactionReceipt.java similarity index 98% rename from ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionReceipt.java rename to ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaGetTransactionReceipt.java index 3df3a5b128..f4bd7a2c39 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionReceipt.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaGetTransactionReceipt.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.eea; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.eea; import static org.apache.logging.log4j.LogManager.getLogger; diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaPrivateNonceProvider.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaPrivateNonceProvider.java similarity index 96% rename from ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaPrivateNonceProvider.java rename to ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaPrivateNonceProvider.java index 33c0378f5e..4afd145d42 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaPrivateNonceProvider.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaPrivateNonceProvider.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.eea; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.eea; import tech.pegasys.pantheon.enclave.Enclave; import tech.pegasys.pantheon.enclave.types.FindPrivacyGroupRequest; diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaSendRawTransaction.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransaction.java similarity index 98% rename from ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaSendRawTransaction.java rename to ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransaction.java index 2280384922..68970b779b 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaSendRawTransaction.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransaction.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.eea; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.eea; import static tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcEnclaveErrorConverter.convertEnclaveInvalidReason; import static tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcErrorConverter.convertTransactionInvalidReason; diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivCreatePrivacyGroup.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroup.java similarity index 76% rename from ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivCreatePrivacyGroup.java rename to ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroup.java index 2ec1ccfdf3..95cf57f79b 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivCreatePrivacyGroup.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroup.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv; import static org.apache.logging.log4j.LogManager.getLogger; @@ -22,12 +22,12 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.parameters.JsonRpcParameter; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.parameters.CreatePrivacyGroupParameter; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -import java.util.Optional; - import org.apache.logging.log4j.Logger; public class PrivCreatePrivacyGroup implements JsonRpcMethod { @@ -55,25 +55,26 @@ public String getName() { public JsonRpcResponse response(final JsonRpcRequest request) { LOG.trace("Executing {}", RpcMethod.PRIV_CREATE_PRIVACY_GROUP.getMethodName()); - final String[] addresses = parameters.required(request.getParams(), 0, String[].class); - final Optional name = parameters.optional(request.getParams(), 1, String.class); - final Optional description = parameters.optional(request.getParams(), 2, String.class); + final CreatePrivacyGroupParameter parameter = + parameters.required(request.getParams(), 0, CreatePrivacyGroupParameter.class); - LOG.trace("Creating a privacy group with name {} and description {}", name, description); + LOG.trace( + "Creating a privacy group with name {} and description {}", + parameter.getName(), + parameter.getDescription()); final CreatePrivacyGroupRequest createPrivacyGroupRequest = new CreatePrivacyGroupRequest( - addresses, + parameter.getAddresses(), privacyParameters.getEnclavePublicKey(), - name.orElse(null), - description.orElse(null)); + parameter.getName(), + parameter.getDescription()); final PrivacyGroup response; try { response = enclave.createPrivacyGroup(createPrivacyGroupRequest); } catch (Exception e) { - LOG.error("Failed to fetch transaction from Enclave with error " + e.getMessage()); - LOG.error(e); - return new JsonRpcSuccessResponse(request.getId(), JsonRpcError.CREATE_PRIVACY_GROUP_ERROR); + LOG.error("Failed to create privacy group", e); + return new JsonRpcErrorResponse(request.getId(), JsonRpcError.CREATE_PRIVACY_GROUP_ERROR); } return new JsonRpcSuccessResponse(request.getId(), response.getPrivacyGroupId()); } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivDeletePrivacyGroup.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivDeletePrivacyGroup.java similarity index 97% rename from ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivDeletePrivacyGroup.java rename to ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivDeletePrivacyGroup.java index bea8d43824..7aee33ec1f 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivDeletePrivacyGroup.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivDeletePrivacyGroup.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv; import static org.apache.logging.log4j.LogManager.getLogger; diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivFindPrivacyGroup.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivFindPrivacyGroup.java similarity index 97% rename from ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivFindPrivacyGroup.java rename to ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivFindPrivacyGroup.java index c79fcc3865..6c9b1c73cd 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivFindPrivacyGroup.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivFindPrivacyGroup.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv; import static org.apache.logging.log4j.LogManager.getLogger; diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivGetPrivacyPrecompileAddress.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetPrivacyPrecompileAddress.java similarity index 96% rename from ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivGetPrivacyPrecompileAddress.java rename to ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetPrivacyPrecompileAddress.java index 4eda2de8a4..336b268dba 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivGetPrivacyPrecompileAddress.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetPrivacyPrecompileAddress.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv; import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.core.PrivacyParameters; diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivGetPrivateTransaction.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransaction.java similarity index 98% rename from ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivGetPrivateTransaction.java rename to ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransaction.java index 5a6811735c..a75a4bdcca 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivGetPrivateTransaction.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransaction.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv; import static org.apache.logging.log4j.LogManager.getLogger; diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivGetTransactionCount.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCount.java similarity index 96% rename from ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivGetTransactionCount.java rename to ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCount.java index b59386b427..89216c095e 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivGetTransactionCount.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCount.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv; import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.jsonrpc.RpcMethod; diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/parameters/CreatePrivacyGroupParameter.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/parameters/CreatePrivacyGroupParameter.java new file mode 100644 index 0000000000..5defcc5666 --- /dev/null +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/parameters/CreatePrivacyGroupParameter.java @@ -0,0 +1,50 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.parameters; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class CreatePrivacyGroupParameter { + + private final String[] addresses; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private final String name; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private final String description; + + @JsonCreator + public CreatePrivacyGroupParameter( + @JsonProperty(value = "addresses", required = true) final String[] addresses, + @JsonProperty("name") final String name, + @JsonProperty("description") final String description) { + this.addresses = addresses; + this.name = name; + this.description = description; + } + + public String[] getAddresses() { + return addresses; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } +} diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionCountTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionCountTest.java index baf687f062..1e60cb8eb6 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionCountTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionCountTest.java @@ -19,6 +19,8 @@ import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.parameters.JsonRpcParameter; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.eea.EeaGetTransactionCount; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.eea.EeaPrivateNonceProvider; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaPrivateNonceProviderTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaPrivateNonceProviderTest.java index dda17b1bee..c770a8be55 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaPrivateNonceProviderTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaPrivateNonceProviderTest.java @@ -24,6 +24,7 @@ import tech.pegasys.pantheon.enclave.types.PrivacyGroup; import tech.pegasys.pantheon.enclave.types.PrivacyGroup.Type; import tech.pegasys.pantheon.ethereum.core.Address; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.eea.EeaPrivateNonceProvider; import tech.pegasys.pantheon.ethereum.privacy.PrivateTransactionHandler; import com.google.common.collect.Lists; diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/PrivCreatePrivacyGroupTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/PrivCreatePrivacyGroupTest.java deleted file mode 100644 index f8d04a1c5e..0000000000 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/PrivCreatePrivacyGroupTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2019 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.eea; - -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import tech.pegasys.pantheon.enclave.Enclave; -import tech.pegasys.pantheon.enclave.types.PrivacyGroup; -import tech.pegasys.pantheon.ethereum.core.PrivacyParameters; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv.PrivCreatePrivacyGroup; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.parameters.JsonRpcParameter; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; - -import org.junit.Test; - -public class PrivCreatePrivacyGroupTest { - - private final Enclave enclave = mock(Enclave.class); - private final PrivacyParameters privacyParameters = mock(PrivacyParameters.class); - private final JsonRpcParameter parameters = new JsonRpcParameter(); - - private final String from = "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; - private final String name = "testName"; - private final String description = "testDesc"; - private final String[] addresses = - new String[] { - "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=", - "Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs=" - }; - private final String privacyGroupId = - "68/Cq0mVjB8FbXDLE1tbDRAvD/srluIok137uFOaClPU/dLFW34ovZebW+PTzy9wUawTXw=="; - - @Test - public void verifyCreatePrivacyGroup() throws Exception { - final PrivacyGroup privacyGroup = - new PrivacyGroup(privacyGroupId, PrivacyGroup.Type.PANTHEON, name, description, addresses); - when(enclave.createPrivacyGroup(any())).thenReturn(privacyGroup); - when(privacyParameters.getEnclavePublicKey()).thenReturn(from); - - final PrivCreatePrivacyGroup eeaCreatePrivacyGroup = - new PrivCreatePrivacyGroup(enclave, privacyParameters, parameters); - - final Object[] params = new Object[] {addresses, name, description}; - final JsonRpcRequest request = new JsonRpcRequest("1", "priv_createPrivacyGroup", params); - - final JsonRpcSuccessResponse response = - (JsonRpcSuccessResponse) eeaCreatePrivacyGroup.response(request); - - final String result = (String) response.getResult(); - - assertEquals(privacyGroupId, result); - } -} diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionReceiptTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaGetTransactionReceiptTest.java similarity index 99% rename from ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionReceiptTest.java rename to ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaGetTransactionReceiptTest.java index 1c3c2bb797..c8049ab5ca 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionReceiptTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaGetTransactionReceiptTest.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.eea; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.eea; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaSendRawTransactionTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java similarity index 99% rename from ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaSendRawTransactionTest.java rename to ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java index a36207ab0a..bd788ef5f0 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/EeaSendRawTransactionTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.eea; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.eea; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroupTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroupTest.java new file mode 100644 index 0000000000..0615771047 --- /dev/null +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroupTest.java @@ -0,0 +1,252 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowableOfType; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import tech.pegasys.pantheon.enclave.Enclave; +import tech.pegasys.pantheon.enclave.EnclaveException; +import tech.pegasys.pantheon.enclave.types.CreatePrivacyGroupRequest; +import tech.pegasys.pantheon.enclave.types.PrivacyGroup; +import tech.pegasys.pantheon.ethereum.core.PrivacyParameters; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.exception.InvalidJsonRpcParameters; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.parameters.JsonRpcParameter; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.parameters.CreatePrivacyGroupParameter; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; + +import org.junit.Before; +import org.junit.Test; + +public class PrivCreatePrivacyGroupTest { + + private static final String FROM = "first participant"; + private static final String NAME = "testName"; + private static final String DESCRIPTION = "testDesc"; + private static final String[] ADDRESSES = new String[] {FROM, "second participant"}; + + private final Enclave enclave = mock(Enclave.class); + private final Enclave failingEnclave = mock(Enclave.class); + private final PrivacyParameters privacyParameters = mock(PrivacyParameters.class); + private final JsonRpcParameter parameters = new JsonRpcParameter(); + + @Before + public void setUp() { + when(failingEnclave.createPrivacyGroup(any(CreatePrivacyGroupRequest.class))) + .thenThrow(new EnclaveException("")); + } + + @Test + public void verifyCreatePrivacyGroup() { + final String expected = "a wonderful group"; + final PrivacyGroup privacyGroup = + new PrivacyGroup(expected, PrivacyGroup.Type.PANTHEON, NAME, DESCRIPTION, ADDRESSES); + when(enclave.createPrivacyGroup(any(CreatePrivacyGroupRequest.class))).thenReturn(privacyGroup); + when(privacyParameters.getEnclavePublicKey()).thenReturn(FROM); + + final PrivCreatePrivacyGroup privCreatePrivacyGroup = + new PrivCreatePrivacyGroup(enclave, privacyParameters, parameters); + + final CreatePrivacyGroupParameter param = + new CreatePrivacyGroupParameter(ADDRESSES, NAME, DESCRIPTION); + + final Object[] params = new Object[] {param}; + + final JsonRpcRequest request = new JsonRpcRequest("1", "priv_createPrivacyGroup", params); + + final JsonRpcSuccessResponse response = + (JsonRpcSuccessResponse) privCreatePrivacyGroup.response(request); + + final String result = (String) response.getResult(); + + assertThat(result).isEqualTo(expected); + } + + @Test + public void verifyCreatePrivacyGroupWithoutDescription() { + + final String expected = "a wonderful group"; + final PrivacyGroup privacyGroup = + new PrivacyGroup(expected, PrivacyGroup.Type.PANTHEON, NAME, DESCRIPTION, ADDRESSES); + when(enclave.createPrivacyGroup(any(CreatePrivacyGroupRequest.class))).thenReturn(privacyGroup); + when(privacyParameters.getEnclavePublicKey()).thenReturn(FROM); + + final PrivCreatePrivacyGroup privCreatePrivacyGroup = + new PrivCreatePrivacyGroup(enclave, privacyParameters, parameters); + + final Object[] params = + new Object[] { + new Object() { + public String[] getAddresses() { + return ADDRESSES; + } + + public String getName() { + return NAME; + } + } + }; + + final JsonRpcRequest request = new JsonRpcRequest("1", "priv_createPrivacyGroup", params); + + final JsonRpcSuccessResponse response = + (JsonRpcSuccessResponse) privCreatePrivacyGroup.response(request); + + final String result = (String) response.getResult(); + + assertThat(result).isEqualTo(expected); + } + + @Test + public void verifyCreatePrivacyGroupWithoutName() { + + final String expected = "a wonderful group"; + final PrivacyGroup privacyGroup = + new PrivacyGroup(expected, PrivacyGroup.Type.PANTHEON, NAME, DESCRIPTION, ADDRESSES); + when(enclave.createPrivacyGroup(any(CreatePrivacyGroupRequest.class))).thenReturn(privacyGroup); + when(privacyParameters.getEnclavePublicKey()).thenReturn(FROM); + + final PrivCreatePrivacyGroup privCreatePrivacyGroup = + new PrivCreatePrivacyGroup(enclave, privacyParameters, parameters); + + final Object[] params = + new Object[] { + new Object() { + public String[] getAddresses() { + return ADDRESSES; + } + + public String getDescription() { + return DESCRIPTION; + } + } + }; + + final JsonRpcRequest request = new JsonRpcRequest("1", "priv_createPrivacyGroup", params); + + final JsonRpcSuccessResponse response = + (JsonRpcSuccessResponse) privCreatePrivacyGroup.response(request); + + final String result = (String) response.getResult(); + + assertThat(result).isEqualTo(expected); + } + + @Test + public void verifyCreatePrivacyGroupWithoutOptionalParams() { + + final String expected = "a wonderful group"; + final PrivacyGroup privacyGroup = + new PrivacyGroup(expected, PrivacyGroup.Type.PANTHEON, NAME, DESCRIPTION, ADDRESSES); + when(enclave.createPrivacyGroup(any(CreatePrivacyGroupRequest.class))).thenReturn(privacyGroup); + when(privacyParameters.getEnclavePublicKey()).thenReturn(FROM); + + final PrivCreatePrivacyGroup privCreatePrivacyGroup = + new PrivCreatePrivacyGroup(enclave, privacyParameters, parameters); + + final Object[] params = + new Object[] { + new Object() { + public String[] getAddresses() { + return ADDRESSES; + } + } + }; + + final JsonRpcRequest request = new JsonRpcRequest("1", "priv_createPrivacyGroup", params); + + final JsonRpcSuccessResponse response = + (JsonRpcSuccessResponse) privCreatePrivacyGroup.response(request); + + final String result = (String) response.getResult(); + + assertThat(result).isEqualTo(expected); + } + + @Test + public void returnsCorrectExceptionInvalidParam() { + + final String expected = "a wonderful group"; + final PrivacyGroup privacyGroup = + new PrivacyGroup(expected, PrivacyGroup.Type.PANTHEON, NAME, DESCRIPTION, ADDRESSES); + when(enclave.createPrivacyGroup(any(CreatePrivacyGroupRequest.class))).thenReturn(privacyGroup); + when(privacyParameters.getEnclavePublicKey()).thenReturn(FROM); + + final PrivCreatePrivacyGroup privCreatePrivacyGroup = + new PrivCreatePrivacyGroup(enclave, privacyParameters, parameters); + + final Object[] params = + new Object[] { + new Object() { + public String getName() { + return NAME; + } + + public String getDescription() { + return DESCRIPTION; + } + } + }; + + final JsonRpcRequest request = new JsonRpcRequest("1", "priv_createPrivacyGroup", params); + + final Throwable response = + catchThrowableOfType( + () -> privCreatePrivacyGroup.response(request), InvalidJsonRpcParameters.class); + + assertThat(response.getMessage()).isEqualTo("Invalid json rpc parameter at index 0"); + } + + @Test + public void returnsCorrectExceptionMissingParam() { + + final PrivCreatePrivacyGroup privCreatePrivacyGroup = + new PrivCreatePrivacyGroup(enclave, privacyParameters, parameters); + + final Object[] params = new Object[] {}; + + final JsonRpcRequest request = new JsonRpcRequest("1", "priv_createPrivacyGroup", params); + + final Throwable response = + catchThrowableOfType( + () -> privCreatePrivacyGroup.response(request), InvalidJsonRpcParameters.class); + + assertThat(response.getMessage()).isEqualTo("Missing required json rpc parameter at index 0"); + } + + @Test + public void returnsCorrectErrorEnclaveError() { + final PrivCreatePrivacyGroup privCreatePrivacyGroup = + new PrivCreatePrivacyGroup(failingEnclave, privacyParameters, parameters); + + final CreatePrivacyGroupParameter param = + new CreatePrivacyGroupParameter(ADDRESSES, NAME, DESCRIPTION); + + final Object[] params = new Object[] {param}; + + final JsonRpcRequest request = new JsonRpcRequest("1", "priv_createPrivacyGroup", params); + + final JsonRpcErrorResponse response = + (JsonRpcErrorResponse) privCreatePrivacyGroup.response(request); + + final JsonRpcError result = response.getError(); + + assertThat(result).isEqualTo(JsonRpcError.CREATE_PRIVACY_GROUP_ERROR); + } +} diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivGetPrivacyPrecompileAddressTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetPrivacyPrecompileAddressTest.java similarity index 97% rename from ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivGetPrivacyPrecompileAddressTest.java rename to ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetPrivacyPrecompileAddressTest.java index 214907f72d..3e26269f29 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/priv/PrivGetPrivacyPrecompileAddressTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetPrivacyPrecompileAddressTest.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/PrivGetPrivateTransactionTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransactionTest.java similarity index 97% rename from ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/PrivGetPrivateTransactionTest.java rename to ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransactionTest.java index f5add17b09..7dbcb7aea5 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/PrivGetPrivateTransactionTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransactionTest.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.eea; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; @@ -28,7 +28,6 @@ import tech.pegasys.pantheon.ethereum.core.Transaction; import tech.pegasys.pantheon.ethereum.core.Wei; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv.PrivGetPrivateTransaction; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.parameters.JsonRpcParameter; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.queries.BlockchainQueries; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.queries.TransactionWithMetadata; diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/PrivGetTransactionCountTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCountTest.java similarity index 93% rename from ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/PrivGetTransactionCountTest.java rename to ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCountTest.java index 4e00dd1392..864fb30c0d 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/eea/PrivGetTransactionCountTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCountTest.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.eea; +package tech.pegasys.pantheon.ethereum.jsonrpc.internal.privacy.methods.priv; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; @@ -19,7 +19,6 @@ import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy.priv.PrivGetTransactionCount; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.parameters.JsonRpcParameter; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; import tech.pegasys.pantheon.ethereum.privacy.PrivateTransactionHandler;