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

Commit

Permalink
[FIX] PR fixes and acceptance test refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-terry committed Feb 4, 2019
1 parent 3beab32 commit 3bf6e52
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class PantheonNode implements Node, NodeConfiguration, RunnableNode, Auto
private final JsonRpcConfiguration jsonRpcConfiguration;
private final WebSocketConfiguration webSocketConfiguration;
private final MetricsConfiguration metricsConfiguration;
private final PermissioningConfiguration permissioningConfiguration;
private final Optional<PermissioningConfiguration> permissioningConfiguration;
private final GenesisConfigProvider genesisConfigProvider;
private final boolean devMode;
private final boolean discoveryEnabled;
Expand All @@ -93,7 +93,7 @@ public PantheonNode(
final JsonRpcConfiguration jsonRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration,
final MetricsConfiguration metricsConfiguration,
final PermissioningConfiguration permissioningConfiguration,
final Optional<PermissioningConfiguration> permissioningConfiguration,
final boolean devMode,
final GenesisConfigProvider genesisConfigProvider,
final int p2pPort,
Expand Down Expand Up @@ -348,7 +348,7 @@ public boolean isDiscoveryEnabled() {
return discoveryEnabled;
}

PermissioningConfiguration getPermissioningConfiguration() {
Optional<PermissioningConfiguration> getPermissioningConfiguration() {
return permissioningConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -79,8 +78,11 @@ public void startNode(final PantheonNode node) {
throw new RuntimeException("Error building PantheonController", e);
}

RunnerBuilder runnerBuilder = new RunnerBuilder();
node.getPermissioningConfiguration().ifPresent(runnerBuilder::permissioningConfiguration);

final Runner runner =
new RunnerBuilder()
runnerBuilder
.vertx(Vertx.vertx())
.pantheonController(pantheonController)
.discovery(node.isDiscoveryEnabled())
Expand All @@ -94,7 +96,6 @@ public void startNode(final PantheonNode node) {
.bannedNodeIds(Collections.emptySet())
.metricsSystem(noOpMetricsSystem)
.metricsConfiguration(node.metricsConfiguration())
.permissioningConfiguration(Optional.of(node.getPermissioningConfiguration()))
.p2pEnabled(node.p2pEnabled())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.GenesisConfigProvider;

import java.util.Optional;

class PantheonFactoryConfiguration {

private final String name;
private final MiningParameters miningParameters;
private final JsonRpcConfiguration jsonRpcConfiguration;
private final WebSocketConfiguration webSocketConfiguration;
private final MetricsConfiguration metricsConfiguration;
private final PermissioningConfiguration permissioningConfiguration;
private final Optional<PermissioningConfiguration> permissioningConfiguration;
private final boolean devMode;
private final GenesisConfigProvider genesisConfigProvider;
private final Boolean p2pEnabled;
Expand All @@ -38,7 +40,7 @@ class PantheonFactoryConfiguration {
final JsonRpcConfiguration jsonRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration,
final MetricsConfiguration metricsConfiguration,
final PermissioningConfiguration permissioningConfiguration,
final Optional<PermissioningConfiguration> permissioningConfiguration,
final boolean devMode,
final GenesisConfigProvider genesisConfigProvider,
final Boolean p2pEnabled,
Expand Down Expand Up @@ -75,7 +77,7 @@ public MetricsConfiguration getMetricsConfiguration() {
return metricsConfiguration;
}

public PermissioningConfiguration getPermissioningConfiguration() {
public Optional<PermissioningConfiguration> getPermissioningConfiguration() {
return permissioningConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class PantheonFactoryConfigurationBuilder {
private JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault();
private WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault();
private MetricsConfiguration metricsConfiguration = MetricsConfiguration.createDefault();
private PermissioningConfiguration permissioningConfiguration =
PermissioningConfiguration.createDefault();
private Optional<PermissioningConfiguration> permissioningConfiguration =
PermissioningConfiguration.disabled();
private boolean devMode = true;
private GenesisConfigProvider genesisConfigProvider = ignore -> Optional.empty();
private Boolean p2pEnabled = true;
Expand Down Expand Up @@ -94,7 +94,7 @@ public PantheonFactoryConfigurationBuilder webSocketEnabled() {

public PantheonFactoryConfigurationBuilder setPermissioningConfiguration(
final PermissioningConfiguration permissioningConfiguration) {
this.permissioningConfiguration = permissioningConfiguration;
this.permissioningConfiguration = Optional.of(permissioningConfiguration);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class PermGetNodesWhitelistAcceptanceTest extends AcceptanceTestBase {

@Before
public void setUp() throws Exception {

node = pantheon.createNodeWithNodesWhitelist("node1", nodesWhitelist);
cluster.start(node);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
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.privacy.PrivateTransactionHandler;
import tech.pegasys.pantheon.metrics.noop.NoOpMetricsSystem;

Expand Down Expand Up @@ -148,7 +147,7 @@ public static void initServerAndClient() throws Exception {
mock(EthHashMiningCoordinator.class),
new NoOpMetricsSystem(),
supportedCapabilities,
mock(AccountWhitelistController.class),
Optional.empty(),
JSON_RPC_APIS,
mock(PrivateTransactionHandler.class)));
service = createJsonRpcHttpService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public class RunnerBuilder {
private Collection<String> bannedNodeIds;
private MetricsConfiguration metricsConfiguration;
private MetricsSystem metricsSystem;
private Optional<PermissioningConfiguration> permissioningConfiguration;
private Optional<PermissioningConfiguration> permissioningConfiguration =
PermissioningConfiguration.disabled();

public RunnerBuilder vertx(final Vertx vertx) {
this.vertx = vertx;
Expand Down Expand Up @@ -141,8 +142,8 @@ public RunnerBuilder webSocketConfiguration(final WebSocketConfiguration webSock
}

public RunnerBuilder permissioningConfiguration(
final Optional<PermissioningConfiguration> permissioningConfiguration) {
this.permissioningConfiguration = permissioningConfiguration;
final PermissioningConfiguration permissioningConfiguration) {
this.permissioningConfiguration = Optional.of(permissioningConfiguration);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ MetricsConfiguration metricsConfiguration() {
private Optional<PermissioningConfiguration> permissioningConfiguration() {

if (!permissionsAccountsEnabled && !permissionsNodesEnabled) {
return Optional.empty();
return PermissioningConfiguration.disabled();
}

final PermissioningConfiguration permissioningConfiguration =
Expand Down Expand Up @@ -792,6 +792,8 @@ private void synchronize(

checkNotNull(runnerBuilder);

permissioningConfiguration.ifPresent(runnerBuilder::permissioningConfiguration);

final Runner runner =
runnerBuilder
.vertx(Vertx.vertx())
Expand All @@ -808,7 +810,6 @@ private void synchronize(
.bannedNodeIds(bannedNodeIds)
.metricsSystem(metricsSystem)
.metricsConfiguration(metricsConfiguration)
.permissioningConfiguration(permissioningConfiguration)
.build();

addShutdownHook(runner);
Expand Down
4 changes: 1 addition & 3 deletions pantheon/src/test/java/tech/pegasys/pantheon/RunnerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -132,8 +131,7 @@ private void syncFromGenesis(final SyncMode mode) throws Exception {
final JsonRpcConfiguration aheadJsonRpcConfiguration = jsonRpcConfiguration();
final WebSocketConfiguration aheadWebSocketConfiguration = wsRpcConfiguration();
final MetricsConfiguration aheadMetricsConfiguration = metricsConfiguration();
final Optional<PermissioningConfiguration> aheadPermissioningConfiguration =
Optional.of(permissioningConfiguration());
final PermissioningConfiguration aheadPermissioningConfiguration = permissioningConfiguration();
final RunnerBuilder runnerBuilder =
new RunnerBuilder()
.vertx(Vertx.vertx())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.Optional;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -83,8 +82,7 @@ public abstract class CommandTestAbstract {
@Captor ArgumentCaptor<WebSocketConfiguration> wsRpcConfigArgumentCaptor;
@Captor ArgumentCaptor<MetricsConfiguration> metricsConfigArgumentCaptor;

@Captor
ArgumentCaptor<Optional<PermissioningConfiguration>> permissioningConfigurationArgumentCaptor;
@Captor ArgumentCaptor<PermissioningConfiguration> permissioningConfigurationArgumentCaptor;

@Captor ArgumentCaptor<Collection<URI>> uriListArgumentCaptor;

Expand Down Expand Up @@ -122,7 +120,6 @@ public void initMocks() throws Exception {
when(mockRunnerBuilder.p2pEnabled(anyBoolean())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.jsonRpcConfiguration(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.webSocketConfiguration(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.permissioningConfiguration(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.dataDir(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.bannedNodeIds(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.metricsSystem(any())).thenReturn(mockRunnerBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public void permissionsTomlPathMustUseOption() throws IOException {
.permissioningConfiguration(permissioningConfigurationArgumentCaptor.capture());
verify(mockRunnerBuilder).build();

assertThat(permissioningConfigurationArgumentCaptor.getValue().get())
assertThat(permissioningConfigurationArgumentCaptor.getValue())
.isEqualToComparingFieldByField(permissioningConfiguration);

assertThat(commandErrorOutput.toString()).isEmpty();
Expand Down

0 comments on commit 3bf6e52

Please sign in to comment.