@ -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.EeaGet TransactionCount ;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea.EeaPrivate NonceProvider ;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivGetEea TransactionCount ;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv.PrivateEea NonceProvider ;
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 EeaGet TransactionCountTest {
public class PrivGetEea TransactionCountTest {
private EeaPrivate NonceProvider nonceProvider = mock ( Eea PrivateNonceProvider. class ) ;
private final PrivateEea NonceProvider nonceProvider = mock ( PrivateEea NonceProvider . 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_get TransactionCount" , jsonBody ) ;
request = new JsonRpcRequest ( "2.0" , "priv_getEea TransactionCount" , jsonBody ) ;
}
@Test
public void validRequestProducesExpectedNonce ( ) {
final long reportedNonce = 8L ;
final EeaGet TransactionCount method =
new EeaGet TransactionCount( new JsonRpcParameter ( ) , nonceProvider ) ;
final PrivGetEea TransactionCount method =
new PrivGetEea TransactionCount( 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 EeaGet TransactionCount method =
new EeaGet TransactionCount( new JsonRpcParameter ( ) , nonceProvider ) ;
final PrivGetEea TransactionCount method =
new PrivGetEea TransactionCount( new JsonRpcParameter ( ) , nonceProvider ) ;
when ( nonceProvider . determineNonce ( privateFrom , privateFor , address ) )
. thenThrow ( RuntimeException . class ) ;
@ -80,8 +80,8 @@ public class EeaGetTransactionCountTest {
@Test
public void nonceProviderThrowsAnExceptionProducesErrorResponse ( ) {
final EeaGet TransactionCount method =
new EeaGet TransactionCount( new JsonRpcParameter ( ) , nonceProvider ) ;
final PrivGetEea TransactionCount method =
new PrivGetEea TransactionCount( new JsonRpcParameter ( ) , nonceProvider ) ;
when ( nonceProvider . determineNonce ( privateFrom , privateFor , address ) )
. thenThrow ( RuntimeException . class ) ;