Rename eea_getTransactionCount to priv_getEeaTransactionCount (#110)

Rename eea_getTransactionCount to priv_getEeaTransactionCount

Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net>
Signed-off-by: Jason Frame <jasonwframe@gmail.com>
pull/141/head
pinges 5 years ago committed by Jason Frame
parent 7fbdcbcaa9
commit 2ca95c0b61
  1. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcMethodsFactory.java
  2. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java
  3. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetEeaTransactionCount.java
  4. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivateEeaNonceProvider.java
  5. 24
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/PrivGetEeaTransactionCountTest.java
  6. 18
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/privacy/eea/PrivateEeaNonceProviderTest.java

@ -90,17 +90,17 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning.
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 @@ public class JsonRpcMethodsFactory {
addMethods(
enabledMethods,
new EeaSendRawTransaction(privateTransactionHandler, transactionPool, parameter),
new EeaGetTransactionCount(
parameter, new EeaPrivateNonceProvider(enclave, privateTransactionHandler)));
new PrivGetEeaTransactionCount(
parameter, new PrivateEeaNonceProvider(enclave, privateTransactionHandler)));
}
if (priv) {
addMethods(

@ -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"),

@ -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.hyperledger.besu.ethereum.core.Address;
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

@ -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 java.util.stream.Collectors;
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;

@ -20,8 +20,8 @@ import static org.mockito.Mockito.when;
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.hyperledger.besu.ethereum.core.Address;
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 class EeaGetTransactionCountTest {
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 class EeaGetTransactionCountTest {
@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);

@ -25,7 +25,7 @@ import org.hyperledger.besu.enclave.EnclaveException;
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 com.google.common.collect.Lists;
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 class EeaPrivateNonceProviderTest {
@Test
public void noMatchingLegacyGroupsProducesExpectedNonce() {
final long reportedNonce = 0L;
PrivacyGroup[] returnedGroups = new PrivacyGroup[0];
final PrivacyGroup[] returnedGroups = new PrivacyGroup[0];
final ArgumentCaptor<FindPrivacyGroupRequest> groupMembersCaptor =
ArgumentCaptor.forClass(FindPrivacyGroupRequest.class);
@ -86,7 +86,7 @@ public class EeaPrivateNonceProviderTest {
@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]),
Loading…
Cancel
Save