diff --git a/ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcTestMethodsFactory.java b/ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcTestMethodsFactory.java index 674daa25ae..3bb8c8e75c 100644 --- a/ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcTestMethodsFactory.java +++ b/ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcTestMethodsFactory.java @@ -36,7 +36,7 @@ import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule; import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSpec; import tech.pegasys.pantheon.ethereum.p2p.api.P2PNetwork; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.worldstate.WorldStateArchive; import tech.pegasys.pantheon.metrics.MetricsSystem; @@ -85,8 +85,8 @@ public Map methods() { blockchainQueries, transactionPool, new FilterIdGenerator(), new FilterRepository()); final EthHashMiningCoordinator miningCoordinator = mock(EthHashMiningCoordinator.class); final MetricsSystem metricsSystem = new NoOpMetricsSystem(); - final Optional accountWhitelistController = - Optional.of(mock(AccountWhitelistController.class)); + final Optional accountWhitelistController = + Optional.of(mock(AccountLocalConfigPermissioningController.class)); final Optional nodeWhitelistController = Optional.of(mock(NodeLocalConfigPermissioningController.class)); final PrivacyParameters privacyParameters = mock(PrivacyParameters.class); diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java index 235789915e..74a0daab8c 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java @@ -102,7 +102,7 @@ import tech.pegasys.pantheon.ethereum.mainnet.ScheduleBasedBlockHashFunction; import tech.pegasys.pantheon.ethereum.p2p.api.P2PNetwork; import tech.pegasys.pantheon.ethereum.p2p.wire.Capability; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.privacy.PrivateTransactionHandler; import tech.pegasys.pantheon.ethereum.transaction.TransactionSimulator; @@ -136,7 +136,7 @@ public Map methods( final Set supportedCapabilities, final Collection rpcApis, final FilterManager filterManager, - final Optional accountsWhitelistController, + final Optional accountsWhitelistController, final Optional nodeWhitelistController, final PrivacyParameters privacyParameters, final JsonRpcConfiguration jsonRpcConfiguration, @@ -179,7 +179,7 @@ public Map methods( final MiningCoordinator miningCoordinator, final MetricsSystem metricsSystem, final Set supportedCapabilities, - final Optional accountsWhitelistController, + final Optional accountsWhitelistController, final Optional nodeWhitelistController, final Collection rpcApis, final PrivacyParameters privacyParameters, diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermAddAccountsToWhitelist.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermAddAccountsToWhitelist.java index 0b8b605f83..46bb833ea1 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermAddAccountsToWhitelist.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermAddAccountsToWhitelist.java @@ -20,7 +20,7 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.WhitelistOperationResult; import java.util.List; @@ -29,10 +29,10 @@ public class PermAddAccountsToWhitelist implements JsonRpcMethod { private final JsonRpcParameter parameters; - private final Optional whitelistController; + private final Optional whitelistController; public PermAddAccountsToWhitelist( - final Optional whitelistController, + final Optional whitelistController, final JsonRpcParameter parameters) { this.whitelistController = whitelistController; this.parameters = parameters; @@ -72,7 +72,8 @@ public JsonRpcResponse response(final JsonRpcRequest request) { case SUCCESS: return new JsonRpcSuccessResponse(request.getId()); default: - throw new IllegalStateException("Unmapped result from AccountWhitelistController"); + throw new IllegalStateException( + "Unmapped result from AccountLocalConfigPermissioningController"); } } else { return new JsonRpcErrorResponse(request.getId(), JsonRpcError.ACCOUNT_WHITELIST_NOT_ENABLED); diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermGetAccountsWhitelist.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermGetAccountsWhitelist.java index b8a991966d..b30a7633fe 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermGetAccountsWhitelist.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermGetAccountsWhitelist.java @@ -19,15 +19,16 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import java.util.Optional; public class PermGetAccountsWhitelist implements JsonRpcMethod { - private final Optional whitelistController; + private final Optional whitelistController; - public PermGetAccountsWhitelist(final Optional whitelistController) { + public PermGetAccountsWhitelist( + final Optional whitelistController) { this.whitelistController = whitelistController; } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermReloadPermissionsFromFile.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermReloadPermissionsFromFile.java index e84834dcd7..f211f14452 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermReloadPermissionsFromFile.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermReloadPermissionsFromFile.java @@ -19,18 +19,18 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import java.util.Optional; public class PermReloadPermissionsFromFile implements JsonRpcMethod { - private final Optional accountWhitelistController; + private final Optional accountWhitelistController; private final Optional nodesWhitelistController; public PermReloadPermissionsFromFile( - final Optional accountWhitelistController, + final Optional accountWhitelistController, final Optional nodesWhitelistController) { this.accountWhitelistController = accountWhitelistController; this.nodesWhitelistController = nodesWhitelistController; @@ -48,7 +48,7 @@ public JsonRpcResponse response(final JsonRpcRequest request) { } try { - accountWhitelistController.ifPresent(AccountWhitelistController::reload); + accountWhitelistController.ifPresent(AccountLocalConfigPermissioningController::reload); nodesWhitelistController.ifPresent(NodeLocalConfigPermissioningController::reload); return new JsonRpcSuccessResponse(request.getId()); } catch (Exception e) { diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermRemoveAccountsFromWhitelist.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermRemoveAccountsFromWhitelist.java index 16c31a7bcb..d03ddc3335 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermRemoveAccountsFromWhitelist.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermRemoveAccountsFromWhitelist.java @@ -20,7 +20,7 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.WhitelistOperationResult; import java.util.List; @@ -29,10 +29,10 @@ public class PermRemoveAccountsFromWhitelist implements JsonRpcMethod { private final JsonRpcParameter parameters; - private final Optional whitelistController; + private final Optional whitelistController; public PermRemoveAccountsFromWhitelist( - final Optional whitelistController, + final Optional whitelistController, final JsonRpcParameter parameters) { this.whitelistController = whitelistController; this.parameters = parameters; @@ -71,7 +71,8 @@ public JsonRpcResponse response(final JsonRpcRequest request) { case SUCCESS: return new JsonRpcSuccessResponse(request.getId()); default: - throw new IllegalStateException("Unmapped result from AccountWhitelistController"); + throw new IllegalStateException( + "Unmapped result from AccountLocalConfigPermissioningController"); } } else { return new JsonRpcErrorResponse(request.getId(), JsonRpcError.ACCOUNT_WHITELIST_NOT_ENABLED); diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceHostWhitelistTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceHostWhitelistTest.java index dacdee5f3a..8f5b17079a 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceHostWhitelistTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceHostWhitelistTest.java @@ -29,7 +29,7 @@ import tech.pegasys.pantheon.ethereum.mainnet.MainnetProtocolSchedule; import tech.pegasys.pantheon.ethereum.p2p.api.P2PNetwork; import tech.pegasys.pantheon.ethereum.p2p.wire.Capability; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.metrics.noop.NoOpMetricsSystem; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; @@ -104,7 +104,7 @@ public void initServerAndClient() throws Exception { mock(EthHashMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, - Optional.of(mock(AccountWhitelistController.class)), + Optional.of(mock(AccountLocalConfigPermissioningController.class)), Optional.of(mock(NodeLocalConfigPermissioningController.class)), JSON_RPC_APIS, mock(PrivacyParameters.class), diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceRpcApisTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceRpcApisTest.java index 929828f7bc..f3868ca990 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceRpcApisTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceRpcApisTest.java @@ -39,7 +39,7 @@ import tech.pegasys.pantheon.ethereum.p2p.network.DefaultP2PNetwork; import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist; import tech.pegasys.pantheon.ethereum.p2p.wire.Capability; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.metrics.noop.NoOpMetricsSystem; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; @@ -199,7 +199,7 @@ private JsonRpcHttpService createJsonRpcHttpServiceWithRpcApis(final JsonRpcConf mock(EthHashMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, - Optional.of(mock(AccountWhitelistController.class)), + Optional.of(mock(AccountLocalConfigPermissioningController.class)), Optional.of(mock(NodeLocalConfigPermissioningController.class)), config.getRpcApis(), mock(PrivacyParameters.class), @@ -285,7 +285,7 @@ private JsonRpcHttpService createJsonRpcHttpService( mock(EthHashMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, - Optional.of(mock(AccountWhitelistController.class)), + Optional.of(mock(AccountLocalConfigPermissioningController.class)), Optional.of(mock(NodeLocalConfigPermissioningController.class)), jsonRpcConfiguration.getRpcApis(), mock(PrivacyParameters.class), diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceTest.java index ddcbfd491a..74e04e5bdc 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceTest.java @@ -44,7 +44,7 @@ import tech.pegasys.pantheon.ethereum.mainnet.MainnetProtocolSchedule; import tech.pegasys.pantheon.ethereum.p2p.api.P2PNetwork; import tech.pegasys.pantheon.ethereum.p2p.wire.Capability; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.metrics.noop.NoOpMetricsSystem; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; @@ -131,7 +131,7 @@ public static void initServerAndClient() throws Exception { mock(EthHashMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, - Optional.of(mock(AccountWhitelistController.class)), + Optional.of(mock(AccountLocalConfigPermissioningController.class)), Optional.of(mock(NodeLocalConfigPermissioningController.class)), JSON_RPC_APIS, mock(PrivacyParameters.class), diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermAddAccountsToWhitelistTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermAddAccountsToWhitelistTest.java index 1dcf686993..cb6487b38f 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermAddAccountsToWhitelistTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermAddAccountsToWhitelistTest.java @@ -25,7 +25,7 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.WhitelistOperationResult; import java.util.ArrayList; @@ -41,7 +41,7 @@ @RunWith(MockitoJUnitRunner.class) public class PermAddAccountsToWhitelistTest { - @Mock private AccountWhitelistController accountWhitelist; + @Mock private AccountLocalConfigPermissioningController accountWhitelist; private PermAddAccountsToWhitelist method; @Before diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermGetAccountsWhitelistTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermGetAccountsWhitelistTest.java index cd060ba150..f231b51599 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermGetAccountsWhitelistTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermGetAccountsWhitelistTest.java @@ -18,7 +18,7 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import java.util.ArrayList; import java.util.Arrays; @@ -36,7 +36,7 @@ public class PermGetAccountsWhitelistTest { private static final JsonRpcRequest request = new JsonRpcRequest("2.0", "perm_getAccountsWhitelist", null); - @Mock private AccountWhitelistController accountWhitelist; + @Mock private AccountLocalConfigPermissioningController accountWhitelist; private PermGetAccountsWhitelist method; @Before diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermReloadPermissionsFromFileTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermReloadPermissionsFromFileTest.java index b6868569a5..8750bff5e4 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermReloadPermissionsFromFileTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermReloadPermissionsFromFileTest.java @@ -21,7 +21,7 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import java.util.Optional; @@ -35,7 +35,7 @@ @RunWith(MockitoJUnitRunner.class) public class PermReloadPermissionsFromFileTest { - @Mock private AccountWhitelistController accountWhitelistController; + @Mock private AccountLocalConfigPermissioningController accountLocalConfigPermissioningController; @Mock private NodeLocalConfigPermissioningController nodeLocalConfigPermissioningController; private PermReloadPermissionsFromFile method; @@ -43,7 +43,7 @@ public class PermReloadPermissionsFromFileTest { public void before() { method = new PermReloadPermissionsFromFile( - Optional.of(accountWhitelistController), + Optional.of(accountLocalConfigPermissioningController), Optional.of(nodeLocalConfigPermissioningController)); } @@ -68,7 +68,7 @@ public void whenBothControllersAreNotPresentMethodShouldReturnPermissioningDisab public void whenControllersReloadSucceedsMethodShouldReturnSuccess() { JsonRpcResponse response = method.response(reloadRequest()); - verify(accountWhitelistController).reload(); + verify(accountLocalConfigPermissioningController).reload(); verify(nodeLocalConfigPermissioningController).reload(); assertThat(response).isEqualToComparingFieldByField(successResponse()); @@ -76,7 +76,7 @@ public void whenControllersReloadSucceedsMethodShouldReturnSuccess() { @Test public void whenControllerReloadFailsMethodShouldReturnError() { - doThrow(new RuntimeException()).when(accountWhitelistController).reload(); + doThrow(new RuntimeException()).when(accountLocalConfigPermissioningController).reload(); JsonRpcResponse expectedErrorResponse = new JsonRpcErrorResponse(null, JsonRpcError.WHITELIST_RELOAD_ERROR); diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermRemoveAccountsFromWhitelistTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermRemoveAccountsFromWhitelistTest.java index 2cb47818d8..2c5a952611 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermRemoveAccountsFromWhitelistTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/permissioning/PermRemoveAccountsFromWhitelistTest.java @@ -25,7 +25,7 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.WhitelistOperationResult; import java.util.ArrayList; @@ -41,7 +41,7 @@ @RunWith(MockitoJUnitRunner.class) public class PermRemoveAccountsFromWhitelistTest { - @Mock private AccountWhitelistController accountWhitelist; + @Mock private AccountLocalConfigPermissioningController accountWhitelist; private PermRemoveAccountsFromWhitelist method; @Before diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/AccountWhitelistController.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/AccountLocalConfigPermissioningController.java similarity index 95% rename from ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/AccountWhitelistController.java rename to ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/AccountLocalConfigPermissioningController.java index 6510921941..2de585377b 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/AccountWhitelistController.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/AccountLocalConfigPermissioningController.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public class AccountWhitelistController { +public class AccountLocalConfigPermissioningController { private static final Logger LOG = LogManager.getLogger(); @@ -34,13 +34,14 @@ public class AccountWhitelistController { private List accountWhitelist = new ArrayList<>(); private final WhitelistPersistor whitelistPersistor; - public AccountWhitelistController(final LocalPermissioningConfiguration configuration) { + public AccountLocalConfigPermissioningController( + final LocalPermissioningConfiguration configuration) { this( configuration, new WhitelistPersistor(configuration.getAccountPermissioningConfigFilePath())); } - public AccountWhitelistController( + public AccountLocalConfigPermissioningController( final LocalPermissioningConfiguration configuration, final WhitelistPersistor whitelistPersistor) { this.configuration = configuration; @@ -154,7 +155,8 @@ public List getAccountWhitelist() { } private boolean containsInvalidAccount(final List accounts) { - return !accounts.stream().allMatch(AccountWhitelistController::isValidAccountString); + return !accounts.stream() + .allMatch(AccountLocalConfigPermissioningController::isValidAccountString); } static boolean isValidAccountString(final String account) { diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationBuilder.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationBuilder.java index 17d8d901dd..ceb48efebf 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationBuilder.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/PermissioningConfigurationBuilder.java @@ -110,7 +110,7 @@ private static LocalPermissioningConfiguration loadAccountPermissioning( .collect(Collectors.toList()); accountsWhitelistToml.stream() - .filter(s -> !AccountWhitelistController.isValidAccountString(s)) + .filter(s -> !AccountLocalConfigPermissioningController.isValidAccountString(s)) .findFirst() .ifPresent( s -> { diff --git a/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/AccountWhitelistControllerTest.java b/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/AccountLocalConfigPermissioningControllerTest.java similarity index 90% rename from ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/AccountWhitelistControllerTest.java rename to ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/AccountLocalConfigPermissioningControllerTest.java index 1b07944af2..d07dc06e28 100644 --- a/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/AccountWhitelistControllerTest.java +++ b/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/AccountLocalConfigPermissioningControllerTest.java @@ -37,15 +37,16 @@ import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) -public class AccountWhitelistControllerTest { +public class AccountLocalConfigPermissioningControllerTest { - private AccountWhitelistController controller; + private AccountLocalConfigPermissioningController controller; @Mock private LocalPermissioningConfiguration permissioningConfig; @Mock private WhitelistPersistor whitelistPersistor; @Before public void before() { - controller = new AccountWhitelistController(permissioningConfig, whitelistPersistor); + controller = + new AccountLocalConfigPermissioningController(permissioningConfig, whitelistPersistor); } @Test @@ -53,7 +54,8 @@ public void whenPermConfigHasAccountsShouldAddAllAccountsToWhitelist() { when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true); when(permissioningConfig.getAccountWhitelist()) .thenReturn(singletonList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73")); - controller = new AccountWhitelistController(permissioningConfig, whitelistPersistor); + controller = + new AccountLocalConfigPermissioningController(permissioningConfig, whitelistPersistor); assertThat(controller.getAccountWhitelist()) .contains("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"); @@ -64,7 +66,8 @@ public void whenLoadingAccountsFromConfigShouldNormalizeAccountsToLowerCase() { when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true); when(permissioningConfig.getAccountWhitelist()) .thenReturn(singletonList("0xFE3B557E8Fb62b89F4916B721be55cEb828dBd73")); - controller = new AccountWhitelistController(permissioningConfig, whitelistPersistor); + controller = + new AccountLocalConfigPermissioningController(permissioningConfig, whitelistPersistor); assertThat(controller.getAccountWhitelist()) .containsExactly("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"); @@ -74,7 +77,8 @@ public void whenLoadingAccountsFromConfigShouldNormalizeAccountsToLowerCase() { public void whenPermConfigContainsEmptyListOfAccountsContainsShouldReturnFalse() { when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true); when(permissioningConfig.getAccountWhitelist()).thenReturn(new ArrayList<>()); - controller = new AccountWhitelistController(permissioningConfig, whitelistPersistor); + controller = + new AccountLocalConfigPermissioningController(permissioningConfig, whitelistPersistor); assertThat(controller.contains("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73")).isFalse(); } @@ -236,7 +240,8 @@ public void reloadAccountWhitelistWithValidConfigFileShouldUpdateWhitelist() thr when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true); when(permissioningConfig.getAccountWhitelist()) .thenReturn(Arrays.asList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73")); - controller = new AccountWhitelistController(permissioningConfig, whitelistPersistor); + controller = + new AccountLocalConfigPermissioningController(permissioningConfig, whitelistPersistor); controller.reload(); @@ -249,7 +254,8 @@ public void reloadAccountWhitelistWithErrorReadingConfigFileShouldKeepOldWhiteli when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true); when(permissioningConfig.getAccountWhitelist()) .thenReturn(Arrays.asList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73")); - controller = new AccountWhitelistController(permissioningConfig, whitelistPersistor); + controller = + new AccountLocalConfigPermissioningController(permissioningConfig, whitelistPersistor); final Throwable thrown = catchThrowable(() -> controller.reload()); @@ -263,13 +269,13 @@ public void reloadAccountWhitelistWithErrorReadingConfigFileShouldKeepOldWhiteli @Test public void accountThatDoesNotStartWith0xIsNotValid() { - assertThat(AccountWhitelistController.isValidAccountString("bob")).isFalse(); + assertThat(AccountLocalConfigPermissioningController.isValidAccountString("bob")).isFalse(); assertThat( - AccountWhitelistController.isValidAccountString( + AccountLocalConfigPermissioningController.isValidAccountString( "b9b81ee349c3807e46bc71aa2632203c5b462032")) .isFalse(); assertThat( - AccountWhitelistController.isValidAccountString( + AccountLocalConfigPermissioningController.isValidAccountString( "0xb9b81ee349c3807e46bc71aa2632203c5b462032")) .isTrue(); } @@ -279,7 +285,8 @@ public void shouldMatchAccountsWithInconsistentCasing() { when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true); when(permissioningConfig.getAccountWhitelist()) .thenReturn(singletonList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73")); - controller = new AccountWhitelistController(permissioningConfig, whitelistPersistor); + controller = + new AccountLocalConfigPermissioningController(permissioningConfig, whitelistPersistor); assertThat(controller.contains("0xFE3B557E8Fb62b89F4916B721be55cEb828dBd73")).isTrue(); } diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java b/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java index 5aa38a57f0..765a54b619 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java @@ -61,7 +61,7 @@ import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist; import tech.pegasys.pantheon.ethereum.p2p.wire.Capability; import tech.pegasys.pantheon.ethereum.p2p.wire.SubProtocol; -import tech.pegasys.pantheon.ethereum.permissioning.AccountWhitelistController; +import tech.pegasys.pantheon.ethereum.permissioning.AccountLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.LocalPermissioningConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.NodePermissioningControllerFactory; @@ -295,13 +295,13 @@ public Runner build() { final TransactionPool transactionPool = pantheonController.getTransactionPool(); final MiningCoordinator miningCoordinator = pantheonController.getMiningCoordinator(); - final Optional accountWhitelistController = + final Optional accountWhitelistController = localPermissioningConfiguration .filter(LocalPermissioningConfiguration::isAccountWhitelistEnabled) .map( configuration -> { - final AccountWhitelistController whitelistController = - new AccountWhitelistController(configuration); + final AccountLocalConfigPermissioningController whitelistController = + new AccountLocalConfigPermissioningController(configuration); transactionPool.setAccountFilter(whitelistController::contains); return whitelistController; }); @@ -468,7 +468,7 @@ private Map jsonRpcMethods( final Set supportedCapabilities, final Collection jsonRpcApis, final FilterManager filterManager, - final Optional accountWhitelistController, + final Optional accountWhitelistController, final Optional nodeWhitelistController, final PrivacyParameters privacyParameters, final JsonRpcConfiguration jsonRpcConfiguration,