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

[PAN-2959] return the ethereum address of the privacy precompile from… #1786

Merged
merged 1 commit into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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