Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
[PAN-2959] return the ethereum address of the privacy precompile from…
Browse files Browse the repository at this point in the history
… priv_getPrivacyPrecompileAddress (#1766) (#1786)
  • Loading branch information
iikirilov authored and MadelineMurray committed Jul 30, 2019
1 parent 05586f6 commit ded93b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy;

import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcMethod;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest;
Expand Down Expand Up @@ -40,7 +41,8 @@ public String getName() {
public JsonRpcResponse response(final JsonRpcRequest request) {

if (privacyEnabled) {
return new JsonRpcSuccessResponse(request.getId(), privacyAddress);
return new JsonRpcSuccessResponse(
request.getId(), Address.privacyPrecompiled(privacyAddress).toString());
} else {
return new JsonRpcErrorResponse(request.getId(), JsonRpcError.PRIVACY_NOT_ENABLED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError;
Expand All @@ -28,12 +29,13 @@

public class EeaGetPrivacyPrecompileAddressTest {

private final Integer privacyAddress = 127;
private final int rawPrivacyAddress = Address.PRIVACY;
private final String privacyAddress = Address.privacyPrecompiled(rawPrivacyAddress).toString();
private final PrivacyParameters privacyParameters = mock(PrivacyParameters.class);

@Test
public void verifyPrivacyPrecompileAddress() {
when(privacyParameters.getPrivacyAddress()).thenReturn(privacyAddress);
when(privacyParameters.getPrivacyAddress()).thenReturn(rawPrivacyAddress);
when(privacyParameters.isEnabled()).thenReturn(true);

final EeaGetPrivacyPrecompileAddress eeaGetPrivacyPrecompileAddress =
Expand All @@ -50,7 +52,7 @@ public void verifyPrivacyPrecompileAddress() {

@Test
public void verifyErrorPrivacyDisabled() {
when(privacyParameters.getPrivacyAddress()).thenReturn(privacyAddress);
when(privacyParameters.getPrivacyAddress()).thenReturn(rawPrivacyAddress);
when(privacyParameters.isEnabled()).thenReturn(false);

final EeaGetPrivacyPrecompileAddress eeaGetPrivacyPrecompileAddress =
Expand Down

0 comments on commit ded93b1

Please sign in to comment.