diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcMethodsFactory.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcMethodsFactory.java index 59c3026148d..cb11f445881 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcMethodsFactory.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcMethodsFactory.java @@ -90,17 +90,17 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning.PermRemoveAccountsFromWhitelist; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning.PermRemoveNodesFromWhitelist; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea.EeaGetTransactionCount; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea.EeaPrivateNonceProvider; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea.EeaSendRawTransaction; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivCreatePrivacyGroup; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivDeletePrivacyGroup; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivDistributeRawTransaction; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivFindPrivacyGroup; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivGetEeaTransactionCount; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivGetPrivacyPrecompileAddress; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivGetPrivateTransaction; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivGetTransactionCount; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivGetTransactionReceipt; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivateEeaNonceProvider; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockReplay; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTracer; @@ -367,8 +367,8 @@ blockchainQueries, new TransactionTracer(blockReplay), parameter), addMethods( enabledMethods, new EeaSendRawTransaction(privateTransactionHandler, transactionPool, parameter), - new EeaGetTransactionCount( - parameter, new EeaPrivateNonceProvider(enclave, privateTransactionHandler))); + new PrivGetEeaTransactionCount( + parameter, new PrivateEeaNonceProvider(enclave, privateTransactionHandler))); } if (priv) { addMethods( diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java index 958bc2bbfdf..a09e056b932 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java @@ -43,8 +43,8 @@ public enum RpcMethod { PRIV_DELETE_PRIVACY_GROUP("priv_deletePrivacyGroup"), PRIV_FIND_PRIVACY_GROUP("priv_findPrivacyGroup"), PRIV_DISTRIBUTE_RAW_TRANSACTION("priv_distributeRawTransaction"), + PRIV_GET_EEA_TRANSACTION_COUNT("priv_getEeaTransactionCount"), EEA_SEND_RAW_TRANSACTION("eea_sendRawTransaction"), - EEA_GET_TRANSACTION_COUNT("eea_getTransactionCount"), ETH_ACCOUNTS("eth_accounts"), ETH_BLOCK_NUMBER("eth_blockNumber"), ETH_CALL("eth_call"), diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaGetTransactionCount.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetEeaTransactionCount.java similarity index 89% rename from ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaGetTransactionCount.java rename to ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetEeaTransactionCount.java index c714dc387d8..b29535edb95 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaGetTransactionCount.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetEeaTransactionCount.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea; +package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; import static org.apache.logging.log4j.LogManager.getLogger; @@ -29,22 +29,22 @@ import org.apache.logging.log4j.Logger; -public class EeaGetTransactionCount implements JsonRpcMethod { +public class PrivGetEeaTransactionCount implements JsonRpcMethod { private static final Logger LOG = getLogger(); private final JsonRpcParameter parameters; - private final EeaPrivateNonceProvider nonceProvider; + private final PrivateEeaNonceProvider nonceProvider; - public EeaGetTransactionCount( - final JsonRpcParameter parameters, final EeaPrivateNonceProvider nonceProvider) { + public PrivGetEeaTransactionCount( + final JsonRpcParameter parameters, final PrivateEeaNonceProvider nonceProvider) { this.parameters = parameters; this.nonceProvider = nonceProvider; } @Override public String getName() { - return RpcMethod.EEA_GET_TRANSACTION_COUNT.getMethodName(); + return RpcMethod.PRIV_GET_EEA_TRANSACTION_COUNT.getMethodName(); } @Override diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaPrivateNonceProvider.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivateEeaNonceProvider.java similarity index 96% rename from ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaPrivateNonceProvider.java rename to ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivateEeaNonceProvider.java index d05c9e4d6aa..cc458bb6922 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaPrivateNonceProvider.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivateEeaNonceProvider.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea; +package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; import org.hyperledger.besu.enclave.Enclave; import org.hyperledger.besu.enclave.types.FindPrivacyGroupRequest; @@ -27,12 +27,12 @@ import com.google.common.collect.Lists; import org.bouncycastle.util.Arrays; -public class EeaPrivateNonceProvider { +public class PrivateEeaNonceProvider { private final Enclave enclave; private final PrivateTransactionHandler privateTransactionHandler; - public EeaPrivateNonceProvider( + public PrivateEeaNonceProvider( final Enclave enclave, final PrivateTransactionHandler privateTransactionHandler) { this.enclave = enclave; this.privateTransactionHandler = privateTransactionHandler; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionCountTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/PrivGetEeaTransactionCountTest.java similarity index 81% rename from ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionCountTest.java rename to ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/PrivGetEeaTransactionCountTest.java index e7287be7b1a..6a92d019a41 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/EeaGetTransactionCountTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/PrivGetEeaTransactionCountTest.java @@ -20,8 +20,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea.EeaGetTransactionCount; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea.EeaPrivateNonceProvider; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivGetEeaTransactionCount; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivateEeaNonceProvider; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; @@ -31,9 +31,9 @@ import org.junit.Before; import org.junit.Test; -public class EeaGetTransactionCountTest { +public class PrivGetEeaTransactionCountTest { - private EeaPrivateNonceProvider nonceProvider = mock(EeaPrivateNonceProvider.class); + private final PrivateEeaNonceProvider nonceProvider = mock(PrivateEeaNonceProvider.class); private JsonRpcRequest request; private final String privateFrom = "thePrivateFromKey"; @@ -43,14 +43,14 @@ public class EeaGetTransactionCountTest { @Before public void setup() { final Object[] jsonBody = new Object[] {address.toString(), privateFrom, privateFor}; - request = new JsonRpcRequest("2.0", "eea_getTransactionCount", jsonBody); + request = new JsonRpcRequest("2.0", "priv_getEeaTransactionCount", jsonBody); } @Test public void validRequestProducesExpectedNonce() { final long reportedNonce = 8L; - final EeaGetTransactionCount method = - new EeaGetTransactionCount(new JsonRpcParameter(), nonceProvider); + final PrivGetEeaTransactionCount method = + new PrivGetEeaTransactionCount(new JsonRpcParameter(), nonceProvider); when(nonceProvider.determineNonce(privateFrom, privateFor, address)).thenReturn(reportedNonce); @@ -58,14 +58,14 @@ public void validRequestProducesExpectedNonce() { assertThat(response).isInstanceOf(JsonRpcSuccessResponse.class); final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response; - int returnedValue = Integer.decode((String) successResponse.getResult()); + final int returnedValue = Integer.decode((String) successResponse.getResult()); assertThat(returnedValue).isEqualTo(reportedNonce); } @Test public void nonceProviderThrowsRuntimeExceptionProducesErrorResponse() { - final EeaGetTransactionCount method = - new EeaGetTransactionCount(new JsonRpcParameter(), nonceProvider); + final PrivGetEeaTransactionCount method = + new PrivGetEeaTransactionCount(new JsonRpcParameter(), nonceProvider); when(nonceProvider.determineNonce(privateFrom, privateFor, address)) .thenThrow(RuntimeException.class); @@ -80,8 +80,8 @@ public void nonceProviderThrowsRuntimeExceptionProducesErrorResponse() { @Test public void nonceProviderThrowsAnExceptionProducesErrorResponse() { - final EeaGetTransactionCount method = - new EeaGetTransactionCount(new JsonRpcParameter(), nonceProvider); + final PrivGetEeaTransactionCount method = + new PrivGetEeaTransactionCount(new JsonRpcParameter(), nonceProvider); when(nonceProvider.determineNonce(privateFrom, privateFor, address)) .thenThrow(RuntimeException.class); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/EeaPrivateNonceProviderTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/PrivateEeaNonceProviderTest.java similarity index 89% rename from ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/EeaPrivateNonceProviderTest.java rename to ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/PrivateEeaNonceProviderTest.java index cd9b9731124..c8fe54986b4 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/EeaPrivateNonceProviderTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/PrivateEeaNonceProviderTest.java @@ -25,7 +25,7 @@ import org.hyperledger.besu.enclave.types.FindPrivacyGroupRequest; import org.hyperledger.besu.enclave.types.PrivacyGroup; import org.hyperledger.besu.enclave.types.PrivacyGroup.Type; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea.EeaPrivateNonceProvider; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivateEeaNonceProvider; import org.hyperledger.besu.ethereum.core.Address; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionHandler; @@ -33,20 +33,20 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; -public class EeaPrivateNonceProviderTest { +public class PrivateEeaNonceProviderTest { private final Address address = Address.fromHexString("55"); - private Enclave enclave = mock(Enclave.class); - private PrivateTransactionHandler privateTransactionHandler = + private final Enclave enclave = mock(Enclave.class); + private final PrivateTransactionHandler privateTransactionHandler = mock(PrivateTransactionHandler.class); - private final EeaPrivateNonceProvider nonceProvider = - new EeaPrivateNonceProvider(enclave, privateTransactionHandler); + private final PrivateEeaNonceProvider nonceProvider = + new PrivateEeaNonceProvider(enclave, privateTransactionHandler); @Test public void validRequestProducesExpectedNonce() { final long reportedNonce = 8L; - PrivacyGroup[] returnedGroups = + final PrivacyGroup[] returnedGroups = new PrivacyGroup[] { new PrivacyGroup("Group1", Type.LEGACY, "Group1_Name", "Group1_Desc", new String[0]), }; @@ -68,7 +68,7 @@ public void validRequestProducesExpectedNonce() { @Test public void noMatchingLegacyGroupsProducesExpectedNonce() { final long reportedNonce = 0L; - PrivacyGroup[] returnedGroups = new PrivacyGroup[0]; + final PrivacyGroup[] returnedGroups = new PrivacyGroup[0]; final ArgumentCaptor groupMembersCaptor = ArgumentCaptor.forClass(FindPrivacyGroupRequest.class); @@ -86,7 +86,7 @@ public void noMatchingLegacyGroupsProducesExpectedNonce() { @Test public void moreThanOneMatchingLegacyGroupThrowsException() { - PrivacyGroup[] returnedGroups = + final PrivacyGroup[] returnedGroups = new PrivacyGroup[] { new PrivacyGroup("Group1", Type.LEGACY, "Group1_Name", "Group1_Desc", new String[0]), new PrivacyGroup("Group2", Type.LEGACY, "Group2_Name", "Group2_Desc", new String[0]),