Idiomatic Builder Pattern (#345)

Use the Idiomatic builder pattern for PantheonControllerBuilder and
RunnerBuilder.  This reduces the number of test touch points when a new
object is added to the builder.
Danno Ferrin 6 years ago committed by GitHub
parent d2dcb46f3d
commit 665ae97b84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 46
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java
  2. 96
      pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java
  3. 53
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java
  4. 56
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonControllerBuilder.java
  5. 59
      pantheon/src/test/java/tech/pegasys/pantheon/RunnerTest.java
  6. 11
      pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandTestAbstract.java
  7. 440
      pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java

@ -20,7 +20,7 @@ import tech.pegasys.pantheon.cli.EthNetworkConfig;
import tech.pegasys.pantheon.cli.PantheonControllerBuilder; import tech.pegasys.pantheon.cli.PantheonControllerBuilder;
import tech.pegasys.pantheon.controller.KeyPairUtil; import tech.pegasys.pantheon.controller.KeyPairUtil;
import tech.pegasys.pantheon.controller.PantheonController; import tech.pegasys.pantheon.controller.PantheonController;
import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration.Builder; import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
@ -42,7 +42,6 @@ public class ThreadPantheonNodeRunner implements PantheonNodeRunner {
private final Map<String, Runner> pantheonRunners = new HashMap<>(); private final Map<String, Runner> pantheonRunners = new HashMap<>();
private ExecutorService nodeExecutor = Executors.newCachedThreadPool(); private ExecutorService nodeExecutor = Executors.newCachedThreadPool();
@SuppressWarnings("rawtypes")
@Override @Override
public void startNode(final PantheonNode node) { public void startNode(final PantheonNode node) {
if (nodeExecutor == null || nodeExecutor.isShutdown()) { if (nodeExecutor == null || nodeExecutor.isShutdown()) {
@ -53,35 +52,36 @@ public class ThreadPantheonNodeRunner implements PantheonNodeRunner {
final EthNetworkConfig ethNetworkConfig = final EthNetworkConfig ethNetworkConfig =
node.ethNetworkConfig() node.ethNetworkConfig()
.orElse(new EthNetworkConfig.Builder(mainnet()).setNetworkId(NETWORK_ID).build()); .orElse(new EthNetworkConfig.Builder(mainnet()).setNetworkId(NETWORK_ID).build());
PantheonController<?> pantheonController; final PantheonController<?> pantheonController;
try { try {
pantheonController = pantheonController =
builder.build( builder
new Builder().build(), .synchronizerConfiguration(new SynchronizerConfiguration.Builder().build())
node.homeDirectory(), .homePath(node.homeDirectory())
ethNetworkConfig, .ethNetworkConfig(ethNetworkConfig)
false, .syncWithOttoman(false)
node.getMiningParameters(), .miningParameters(node.getMiningParameters())
node.isDevMode(), .devMode(node.isDevMode())
KeyPairUtil.getDefaultKeyFile(node.homeDirectory())); .nodePrivateKeyFile(KeyPairUtil.getDefaultKeyFile(node.homeDirectory()))
.build();
} catch (final IOException e) { } catch (final IOException e) {
throw new RuntimeException("Error building PantheonController", e); throw new RuntimeException("Error building PantheonController", e);
} }
final Runner runner = final Runner runner =
new RunnerBuilder() new RunnerBuilder()
.build( .vertx(Vertx.vertx())
Vertx.vertx(), .pantheonController(pantheonController)
pantheonController, .discovery(true)
true, .bootstrapPeers(node.bootnodes())
node.bootnodes(), .discoveryHost(node.hostName())
node.hostName(), .discoveryPort(node.p2pPort())
node.p2pPort(), .maxPeers(25)
25, .jsonRpcConfiguration(node.jsonRpcConfiguration())
node.jsonRpcConfiguration(), .webSocketConfiguration(node.webSocketConfiguration())
node.webSocketConfiguration(), .dataDir(node.homeDirectory())
node.homeDirectory(), .bannedNodeIds(Collections.emptySet())
Collections.emptySet()); .build();
nodeExecutor.submit(runner::execute); nodeExecutor.submit(runner::execute);

@ -67,18 +67,74 @@ import io.vertx.core.Vertx;
public class RunnerBuilder { public class RunnerBuilder {
public Runner build( private Vertx vertx;
final Vertx vertx, private PantheonController<?> pantheonController;
final PantheonController<?> pantheonController, private boolean discovery;
final boolean discovery, private Collection<?> bootstrapPeers;
final Collection<?> bootstrapPeers, private String discoveryHost;
final String discoveryHost, private int listenPort;
final int listenPort, private int maxPeers;
final int maxPeers, private JsonRpcConfiguration jsonRpcConfiguration;
final JsonRpcConfiguration jsonRpcConfiguration, private WebSocketConfiguration webSocketConfiguration;
final WebSocketConfiguration webSocketConfiguration, private Path dataDir;
final Path dataDir, private Collection<String> bannedNodeIds;
final Collection<String> bannedNodeIds) {
public RunnerBuilder vertx(final Vertx vertx) {
this.vertx = vertx;
return this;
}
public RunnerBuilder pantheonController(final PantheonController<?> pantheonController) {
this.pantheonController = pantheonController;
return this;
}
public RunnerBuilder discovery(final boolean discovery) {
this.discovery = discovery;
return this;
}
public RunnerBuilder bootstrapPeers(final Collection<?> bootstrapPeers) {
this.bootstrapPeers = bootstrapPeers;
return this;
}
public RunnerBuilder discoveryHost(final String discoveryHost) {
this.discoveryHost = discoveryHost;
return this;
}
public RunnerBuilder discoveryPort(final int listenPort) {
this.listenPort = listenPort;
return this;
}
public RunnerBuilder maxPeers(final int maxPeers) {
this.maxPeers = maxPeers;
return this;
}
public RunnerBuilder jsonRpcConfiguration(final JsonRpcConfiguration jsonRpcConfiguration) {
this.jsonRpcConfiguration = jsonRpcConfiguration;
return this;
}
public RunnerBuilder webSocketConfiguration(final WebSocketConfiguration webSocketConfiguration) {
this.webSocketConfiguration = webSocketConfiguration;
return this;
}
public RunnerBuilder dataDir(final Path dataDir) {
this.dataDir = dataDir;
return this;
}
public RunnerBuilder bannedNodeIds(final Collection<String> bannedNodeIds) {
this.bannedNodeIds = bannedNodeIds;
return this;
}
public Runner build() {
Preconditions.checkNotNull(pantheonController); Preconditions.checkNotNull(pantheonController);
@ -187,7 +243,7 @@ public class RunnerBuilder {
filterManager); filterManager);
final SubscriptionManager subscriptionManager = final SubscriptionManager subscriptionManager =
createSubscriptionManager(vertx, context.getBlockchain(), transactionPool); createSubscriptionManager(vertx, transactionPool);
createLogsSubscriptionService( createLogsSubscriptionService(
context.getBlockchain(), context.getWorldStateArchive(), subscriptionManager); context.getBlockchain(), context.getWorldStateArchive(), subscriptionManager);
@ -251,7 +307,7 @@ public class RunnerBuilder {
} }
private SubscriptionManager createSubscriptionManager( private SubscriptionManager createSubscriptionManager(
final Vertx vertx, final Blockchain blockchain, final TransactionPool transactionPool) { final Vertx vertx, final TransactionPool transactionPool) {
final SubscriptionManager subscriptionManager = new SubscriptionManager(); final SubscriptionManager subscriptionManager = new SubscriptionManager();
final PendingTransactionSubscriptionService pendingTransactions = final PendingTransactionSubscriptionService pendingTransactions =
new PendingTransactionSubscriptionService(subscriptionManager); new PendingTransactionSubscriptionService(subscriptionManager);
@ -261,7 +317,7 @@ public class RunnerBuilder {
return subscriptionManager; return subscriptionManager;
} }
private LogsSubscriptionService createLogsSubscriptionService( private void createLogsSubscriptionService(
final Blockchain blockchain, final Blockchain blockchain,
final WorldStateArchive worldStateArchive, final WorldStateArchive worldStateArchive,
final SubscriptionManager subscriptionManager) { final SubscriptionManager subscriptionManager) {
@ -270,16 +326,14 @@ public class RunnerBuilder {
subscriptionManager, new BlockchainQueries(blockchain, worldStateArchive)); subscriptionManager, new BlockchainQueries(blockchain, worldStateArchive));
blockchain.observeBlockAdded(logsSubscriptionService); blockchain.observeBlockAdded(logsSubscriptionService);
return logsSubscriptionService;
} }
private SyncingSubscriptionService createSyncingSubscriptionService( private void createSyncingSubscriptionService(
final Synchronizer synchronizer, final SubscriptionManager subscriptionManager) { final Synchronizer synchronizer, final SubscriptionManager subscriptionManager) {
return new SyncingSubscriptionService(subscriptionManager, synchronizer); new SyncingSubscriptionService(subscriptionManager, synchronizer);
} }
private NewBlockHeadersSubscriptionService createNewBlockHeadersSubscriptionService( private void createNewBlockHeadersSubscriptionService(
final Blockchain blockchain, final Blockchain blockchain,
final WorldStateArchive worldStateArchive, final WorldStateArchive worldStateArchive,
final SubscriptionManager subscriptionManager) { final SubscriptionManager subscriptionManager) {
@ -288,8 +342,6 @@ public class RunnerBuilder {
subscriptionManager, new BlockchainQueries(blockchain, worldStateArchive)); subscriptionManager, new BlockchainQueries(blockchain, worldStateArchive));
blockchain.observeBlockAdded(newBlockHeadersSubscriptionService); blockchain.observeBlockAdded(newBlockHeadersSubscriptionService);
return newBlockHeadersSubscriptionService;
} }
private WebSocketService createWebsocketService( private WebSocketService createWebsocketService(

@ -45,8 +45,8 @@ import java.nio.file.Files;
import java.nio.file.InvalidPathException; import java.nio.file.InvalidPathException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.function.Function; import java.util.function.Function;
@ -217,7 +217,7 @@ public class PantheonCommand implements Runnable {
split = ",", split = ",",
arity = "1..*" arity = "1..*"
) )
private final Collection<String> bannedNodeIds = null; private final Collection<String> bannedNodeIds = new ArrayList<>();
// TODO: Re-enable as per NC-1057/NC-1681 // TODO: Re-enable as per NC-1057/NC-1681
// @Option( // @Option(
@ -447,14 +447,16 @@ public class PantheonCommand implements Runnable {
PantheonController<?> buildController() { PantheonController<?> buildController() {
try { try {
return controllerBuilder.build( return controllerBuilder
buildSyncConfig(syncMode), .synchronizerConfiguration(buildSyncConfig(syncMode))
dataDir, .homePath(dataDir)
ethNetworkConfig(), .ethNetworkConfig(ethNetworkConfig())
syncWithOttoman, .syncWithOttoman(syncWithOttoman)
new MiningParameters(coinbase, minTransactionGasPrice, extraData, isMiningEnabled), .miningParameters(
isDevMode, new MiningParameters(coinbase, minTransactionGasPrice, extraData, isMiningEnabled))
getNodePrivateKeyFile()); .devMode(isDevMode)
.nodePrivateKeyFile(getNodePrivateKeyFile())
.build();
} catch (final InvalidConfigurationException e) { } catch (final InvalidConfigurationException e) {
throw new ExecutionException(new CommandLine(this), e.getMessage()); throw new ExecutionException(new CommandLine(this), e.getMessage());
} catch (final IOException e) { } catch (final IOException e) {
@ -504,20 +506,21 @@ public class PantheonCommand implements Runnable {
checkNotNull(runnerBuilder); checkNotNull(runnerBuilder);
// BEWARE: Peer discovery boolean must be inverted as it's negated in the options !
final Runner runner = final Runner runner =
runnerBuilder.build( runnerBuilder
Vertx.vertx(), .vertx(Vertx.vertx())
controller, .pantheonController(controller)
!noPeerDiscovery, // BEWARE: Peer discovery boolean must be inverted as it's negated in the options !
bootstrapNodes, .discovery(!noPeerDiscovery)
discoveryHostAndPort.getHost(), .bootstrapPeers(bootstrapNodes)
discoveryHostAndPort.getPort(), .discoveryHost(discoveryHostAndPort.getHost())
maxPeers, .discoveryPort(discoveryHostAndPort.getPort())
jsonRpcConfiguration, .maxPeers(maxPeers)
webSocketConfiguration, .jsonRpcConfiguration(jsonRpcConfiguration)
dataDir, .webSocketConfiguration(webSocketConfiguration)
bannedNodeIds == null ? Collections.emptySet() : bannedNodeIds); .dataDir(dataDir)
.bannedNodeIds(bannedNodeIds)
.build();
addShutdownHook(runner); addShutdownHook(runner);
runner.execute(); runner.execute();
@ -530,7 +533,7 @@ public class PantheonCommand implements Runnable {
() -> { () -> {
try { try {
runner.close(); runner.close();
} catch (Exception e) { } catch (final Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
})); }));
@ -634,7 +637,7 @@ public class PantheonCommand implements Runnable {
private String genesisConfig() { private String genesisConfig() {
try { try {
return Resources.toString(genesisFile.toURI().toURL(), UTF_8); return Resources.toString(genesisFile.toURI().toURL(), UTF_8);
} catch (IOException e) { } catch (final IOException e) {
throw new ParameterException( throw new ParameterException(
new CommandLine(this), String.format("Unable to load genesis file %s.", genesisFile), e); new CommandLine(this), String.format("Unable to load genesis file %s.", genesisFile), e);
} }

@ -31,22 +31,58 @@ import java.nio.file.Path;
public class PantheonControllerBuilder { public class PantheonControllerBuilder {
public PantheonController<?> build( private SynchronizerConfiguration synchronizerConfiguration;
final SynchronizerConfiguration synchronizerConfiguration, private Path homePath;
final Path homePath, private EthNetworkConfig ethNetworkConfig;
final EthNetworkConfig ethNetworkConfig, private boolean syncWithOttoman;
final boolean syncWithOttoman, private MiningParameters miningParameters;
final MiningParameters miningParameters, private boolean devMode;
final boolean isDevMode, private File nodePrivateKeyFile;
final File nodePrivateKeyFile)
throws IOException { public PantheonControllerBuilder synchronizerConfiguration(
final SynchronizerConfiguration synchronizerConfiguration) {
this.synchronizerConfiguration = synchronizerConfiguration;
return this;
}
public PantheonControllerBuilder homePath(final Path homePath) {
this.homePath = homePath;
return this;
}
public PantheonControllerBuilder ethNetworkConfig(final EthNetworkConfig ethNetworkConfig) {
this.ethNetworkConfig = ethNetworkConfig;
return this;
}
public PantheonControllerBuilder syncWithOttoman(final boolean syncWithOttoman) {
this.syncWithOttoman = syncWithOttoman;
return this;
}
public PantheonControllerBuilder miningParameters(final MiningParameters miningParameters) {
this.miningParameters = miningParameters;
return this;
}
public PantheonControllerBuilder devMode(final boolean devMode) {
this.devMode = devMode;
return this;
}
public PantheonControllerBuilder nodePrivateKeyFile(final File nodePrivateKeyFile) {
this.nodePrivateKeyFile = nodePrivateKeyFile;
return this;
}
public PantheonController<?> build() throws IOException {
// instantiate a controller with mainnet config if no genesis file is defined // instantiate a controller with mainnet config if no genesis file is defined
// otherwise use the indicated genesis file // otherwise use the indicated genesis file
final KeyPair nodeKeys = loadKeyPair(nodePrivateKeyFile); final KeyPair nodeKeys = loadKeyPair(nodePrivateKeyFile);
final StorageProvider storageProvider = final StorageProvider storageProvider =
RocksDbStorageProvider.create(homePath.resolve(DATABASE_PATH)); RocksDbStorageProvider.create(homePath.resolve(DATABASE_PATH));
if (isDevMode) { if (devMode) {
final GenesisConfigFile genesisConfig = GenesisConfigFile.development(); final GenesisConfigFile genesisConfig = GenesisConfigFile.development();
return MainnetPantheonController.init( return MainnetPantheonController.init(
storageProvider, storageProvider,

@ -118,20 +118,23 @@ public final class RunnerTest {
final ExecutorService executorService = Executors.newFixedThreadPool(2); final ExecutorService executorService = Executors.newFixedThreadPool(2);
final JsonRpcConfiguration aheadJsonRpcConfiguration = jsonRpcConfiguration(); final JsonRpcConfiguration aheadJsonRpcConfiguration = jsonRpcConfiguration();
final WebSocketConfiguration aheadWebSocketConfiguration = wsRpcConfiguration(); final WebSocketConfiguration aheadWebSocketConfiguration = wsRpcConfiguration();
final RunnerBuilder runnerBuilder = new RunnerBuilder(); final RunnerBuilder runnerBuilder =
new RunnerBuilder()
.vertx(Vertx.vertx())
.discovery(true)
.discoveryHost(listenHost)
.discoveryPort(0)
.maxPeers(3)
.bannedNodeIds(Collections.emptySet());
final Runner runnerAhead = final Runner runnerAhead =
runnerBuilder.build( runnerBuilder
Vertx.vertx(), .pantheonController(controllerAhead)
controllerAhead, .bootstrapPeers(Collections.emptyList())
true, .jsonRpcConfiguration(aheadJsonRpcConfiguration)
Collections.emptyList(), .webSocketConfiguration(aheadWebSocketConfiguration)
listenHost, .dataDir(dbAhead)
0, .build();
3,
aheadJsonRpcConfiguration,
aheadWebSocketConfiguration,
dbAhead,
Collections.emptySet());
try { try {
executorService.submit(runnerAhead::execute); executorService.submit(runnerAhead::execute);
@ -148,23 +151,19 @@ public final class RunnerTest {
new MiningParametersTestBuilder().enabled(false).build(), new MiningParametersTestBuilder().enabled(false).build(),
KeyPair.generate()); KeyPair.generate());
final Runner runnerBehind = final Runner runnerBehind =
runnerBuilder.build( runnerBuilder
Vertx.vertx(), .pantheonController(controllerBehind)
controllerBehind, .bootstrapPeers(
true, Collections.singletonList(
Collections.singletonList( new DefaultPeer(
new DefaultPeer( aheadDbNodeKeys.getPublicKey().getEncodedBytes(),
aheadDbNodeKeys.getPublicKey().getEncodedBytes(), listenHost,
listenHost, runnerAhead.getP2pUdpPort(),
runnerAhead.getP2pUdpPort(), runnerAhead.getP2pTcpPort())))
runnerAhead.getP2pTcpPort())), .jsonRpcConfiguration(behindJsonRpcConfiguration)
listenHost, .webSocketConfiguration(behindWebSocketConfiguration)
0, .dataDir(temp.newFolder().toPath())
3, .build();
behindJsonRpcConfiguration,
behindWebSocketConfiguration,
temp.newFolder().toPath(),
Collections.emptySet());
executorService.submit(runnerBehind::execute); executorService.submit(runnerBehind::execute);
final Call.Factory client = new OkHttpClient(); final Call.Factory client = new OkHttpClient();

@ -75,9 +75,14 @@ public abstract class CommandTestAbstract {
@Before @Before
public void initMocks() throws Exception { public void initMocks() throws Exception {
// doReturn used because of generic PantheonController // doReturn used because of generic PantheonController
Mockito.doReturn(mockController) Mockito.doReturn(mockController).when(mockControllerBuilder).build();
.when(mockControllerBuilder) when(mockControllerBuilder.synchronizerConfiguration(any())).thenReturn(mockControllerBuilder);
.build(any(), any(), any(), anyBoolean(), any(), anyBoolean(), any()); when(mockControllerBuilder.homePath(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.ethNetworkConfig(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.syncWithOttoman(anyBoolean())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.miningParameters(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.devMode(anyBoolean())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.nodePrivateKeyFile(any())).thenReturn(mockControllerBuilder);
when(mockSyncConfBuilder.build()).thenReturn(mockSyncConf); when(mockSyncConfBuilder.build()).thenReturn(mockSyncConf);
} }

@ -84,19 +84,18 @@ public class PantheonCommandTest extends CommandTestAbstract {
public void initMocks() throws Exception { public void initMocks() throws Exception {
super.initMocks(); super.initMocks();
when(mockRunnerBuilder.build( when(mockRunnerBuilder.vertx(any())).thenReturn(mockRunnerBuilder);
any(), when(mockRunnerBuilder.pantheonController(any())).thenReturn(mockRunnerBuilder);
any(), when(mockRunnerBuilder.discovery(anyBoolean())).thenReturn(mockRunnerBuilder);
anyBoolean(), when(mockRunnerBuilder.bootstrapPeers(any())).thenReturn(mockRunnerBuilder);
any(), when(mockRunnerBuilder.discoveryHost(anyString())).thenReturn(mockRunnerBuilder);
anyString(), when(mockRunnerBuilder.discoveryPort(anyInt())).thenReturn(mockRunnerBuilder);
anyInt(), when(mockRunnerBuilder.maxPeers(anyInt())).thenReturn(mockRunnerBuilder);
anyInt(), when(mockRunnerBuilder.jsonRpcConfiguration(any())).thenReturn(mockRunnerBuilder);
any(), when(mockRunnerBuilder.webSocketConfiguration(any())).thenReturn(mockRunnerBuilder);
any(), when(mockRunnerBuilder.dataDir(any())).thenReturn(mockRunnerBuilder);
any(), when(mockRunnerBuilder.bannedNodeIds(any())).thenReturn(mockRunnerBuilder);
any())) when(mockRunnerBuilder.build()).thenReturn(mockRunner);
.thenReturn(mockRunner);
} }
@Test @Test
@ -126,33 +125,27 @@ public class PantheonCommandTest extends CommandTestAbstract {
public void callingPantheonCommandWithoutOptionsMustSyncWithDefaultValues() throws Exception { public void callingPantheonCommandWithoutOptionsMustSyncWithDefaultValues() throws Exception {
parseCommand(); parseCommand();
verify(mockRunnerBuilder) verify(mockRunnerBuilder).discovery(eq(true));
.build( verify(mockRunnerBuilder).bootstrapPeers(MAINNET_BOOTSTRAP_NODES);
any(), verify(mockRunnerBuilder).discoveryHost(eq("127.0.0.1"));
any(), verify(mockRunnerBuilder).discoveryPort(eq(30303));
eq(true), verify(mockRunnerBuilder).maxPeers(eq(25));
eq(MAINNET_BOOTSTRAP_NODES), verify(mockRunnerBuilder).jsonRpcConfiguration(eq(defaultJsonRpcConfiguration));
eq("127.0.0.1"), verify(mockRunnerBuilder).webSocketConfiguration(eq(defaultWebSocketConfiguration));
eq(30303), verify(mockRunnerBuilder).build();
eq(25),
eq(defaultJsonRpcConfiguration),
eq(defaultWebSocketConfiguration),
any(),
any());
final ArgumentCaptor<MiningParameters> miningArg = final ArgumentCaptor<MiningParameters> miningArg =
ArgumentCaptor.forClass(MiningParameters.class); ArgumentCaptor.forClass(MiningParameters.class);
final ArgumentCaptor<EthNetworkConfig> networkArg = final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class); ArgumentCaptor.forClass(EthNetworkConfig.class);
verify(mockControllerBuilder) verify(mockControllerBuilder).synchronizerConfiguration(isNotNull());
.build( verify(mockControllerBuilder).homePath(isNotNull());
any(), verify(mockControllerBuilder).ethNetworkConfig(networkArg.capture());
isNotNull(), verify(mockControllerBuilder).syncWithOttoman(eq(false));
networkArg.capture(), verify(mockControllerBuilder).miningParameters(miningArg.capture());
eq(false), verify(mockControllerBuilder).devMode(eq(false));
miningArg.capture(), verify(mockControllerBuilder).nodePrivateKeyFile(isNotNull());
eq(false), verify(mockControllerBuilder).build();
isNotNull());
verify(mockSyncConfBuilder).syncMode(ArgumentMatchers.eq(SyncMode.FULL)); verify(mockSyncConfBuilder).syncMode(ArgumentMatchers.eq(SyncMode.FULL));
@ -265,19 +258,14 @@ public class PantheonCommandTest extends CommandTestAbstract {
parseCommand("--config", toml.toString()); parseCommand("--config", toml.toString());
verify(mockRunnerBuilder) verify(mockRunnerBuilder).discovery(eq(false));
.build( verify(mockRunnerBuilder).bootstrapPeers(stringListArgumentCaptor.capture());
any(), verify(mockRunnerBuilder).discoveryHost(eq("1.2.3.4"));
any(), verify(mockRunnerBuilder).discoveryPort(eq(1234));
eq(false), verify(mockRunnerBuilder).maxPeers(eq(42));
stringListArgumentCaptor.capture(), verify(mockRunnerBuilder).jsonRpcConfiguration(eq(jsonRpcConfiguration));
eq("1.2.3.4"), verify(mockRunnerBuilder).webSocketConfiguration(eq(webSocketConfiguration));
eq(1234), verify(mockRunnerBuilder).build();
eq(42),
eq(jsonRpcConfiguration),
eq(webSocketConfiguration),
any(),
any());
final Collection<String> nodes = final Collection<String> nodes =
asList("enode://001@123:4567", "enode://002@123:4567", "enode://003@123:4567"); asList("enode://001@123:4567", "enode://002@123:4567", "enode://003@123:4567");
@ -288,15 +276,9 @@ public class PantheonCommandTest extends CommandTestAbstract {
.setGenesisConfig(GENESIS_CONFIG_TESTDATA) .setGenesisConfig(GENESIS_CONFIG_TESTDATA)
.setBootNodes(nodes) .setBootNodes(nodes)
.build(); .build();
verify(mockControllerBuilder) verify(mockControllerBuilder).homePath(eq(Paths.get("~/pantheondata")));
.build( verify(mockControllerBuilder).ethNetworkConfig(eq(networkConfig));
any(), verify(mockControllerBuilder).syncWithOttoman(eq(false));
eq(Paths.get("~/pantheondata")),
eq(networkConfig),
eq(false),
any(),
anyBoolean(),
any());
// TODO: Re-enable as per NC-1057/NC-1681 // TODO: Re-enable as per NC-1057/NC-1681
// verify(mockSyncConfBuilder).syncMode(ArgumentMatchers.eq(SyncMode.FAST)); // verify(mockSyncConfBuilder).syncMode(ArgumentMatchers.eq(SyncMode.FAST));
@ -320,21 +302,18 @@ public class PantheonCommandTest extends CommandTestAbstract {
webSocketConfiguration.addRpcApi(CliqueRpcApis.CLIQUE); webSocketConfiguration.addRpcApi(CliqueRpcApis.CLIQUE);
webSocketConfiguration.addRpcApi(IbftRpcApis.IBFT); webSocketConfiguration.addRpcApi(IbftRpcApis.IBFT);
verify(mockRunnerBuilder) verify(mockRunnerBuilder).discovery(eq(true));
.build( verify(mockRunnerBuilder).bootstrapPeers(MAINNET_BOOTSTRAP_NODES);
any(), verify(mockRunnerBuilder).discoveryHost(eq("127.0.0.1"));
any(), verify(mockRunnerBuilder).discoveryPort(eq(30303));
eq(true), verify(mockRunnerBuilder).maxPeers(eq(25));
eq(MAINNET_BOOTSTRAP_NODES), verify(mockRunnerBuilder).jsonRpcConfiguration(eq(jsonRpcConfiguration));
eq("127.0.0.1"), verify(mockRunnerBuilder).webSocketConfiguration(eq(webSocketConfiguration));
eq(30303), verify(mockRunnerBuilder).build();
eq(25),
eq(jsonRpcConfiguration), verify(mockControllerBuilder).syncWithOttoman(eq(false));
eq(webSocketConfiguration), verify(mockControllerBuilder).devMode(eq(false));
any(), verify(mockControllerBuilder).build();
any());
verify(mockControllerBuilder).build(any(), any(), any(), eq(false), any(), eq(false), any());
// TODO: Re-enable as per NC-1057/NC-1681 // TODO: Re-enable as per NC-1057/NC-1681
// verify(mockSyncConfBuilder).syncMode(ArgumentMatchers.eq(SyncMode.FULL)); // verify(mockSyncConfBuilder).syncMode(ArgumentMatchers.eq(SyncMode.FULL));
@ -351,15 +330,10 @@ public class PantheonCommandTest extends CommandTestAbstract {
parseCommand("--node-private-key", file.getPath()); parseCommand("--node-private-key", file.getPath());
verify(mockControllerBuilder) verify(mockControllerBuilder).homePath(isNotNull());
.build( verify(mockControllerBuilder).syncWithOttoman(eq(false));
any(), verify(mockControllerBuilder).nodePrivateKeyFile(fileArgumentCaptor.capture());
isNotNull(), verify(mockControllerBuilder).build();
any(),
eq(false),
any(),
anyBoolean(),
fileArgumentCaptor.capture());
assertThat(fileArgumentCaptor.getValue()).isEqualTo(file); assertThat(fileArgumentCaptor.getValue()).isEqualTo(file);
@ -373,15 +347,10 @@ public class PantheonCommandTest extends CommandTestAbstract {
parseCommand("--datadir", path.toString()); parseCommand("--datadir", path.toString());
verify(mockControllerBuilder) verify(mockControllerBuilder).homePath(pathArgumentCaptor.capture());
.build( verify(mockControllerBuilder).syncWithOttoman(eq(false));
any(), verify(mockControllerBuilder).nodePrivateKeyFile(eq(path.resolve("key").toFile()));
pathArgumentCaptor.capture(), verify(mockControllerBuilder).build();
any(),
eq(false),
any(),
anyBoolean(),
eq(path.resolve("key").toFile()));
assertThat(pathArgumentCaptor.getValue()).isEqualByComparingTo(path); assertThat(pathArgumentCaptor.getValue()).isEqualByComparingTo(path);
@ -397,8 +366,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
parseCommand("--genesis", genesisFile.toString()); parseCommand("--genesis", genesisFile.toString());
verify(mockControllerBuilder) verify(mockControllerBuilder).ethNetworkConfig(networkArg.capture());
.build(any(), any(), networkArg.capture(), anyBoolean(), any(), anyBoolean(), any()); verify(mockControllerBuilder).build();
assertThat(networkArg.getValue().getGenesisConfig()).isEqualTo("genesis_config"); assertThat(networkArg.getValue().getGenesisConfig()).isEqualTo("genesis_config");
@ -412,19 +381,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
// Discovery stored in runner is the negative of the option passed to CLI // Discovery stored in runner is the negative of the option passed to CLI
// So as passing the option means noDiscovery will be true, then discovery is false in runner // So as passing the option means noDiscovery will be true, then discovery is false in runner
verify(mockRunnerBuilder) verify(mockRunnerBuilder.discovery(eq(false))).build();
.build(
any(),
any(),
eq(false),
any(),
anyString(),
anyInt(),
anyInt(),
any(),
any(),
any(),
any());
assertThat(commandOutput.toString()).isEmpty(); assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty();
@ -453,19 +410,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
final String[] nodes = {"enode://001@123:4567", "enode://002@123:4567", "enode://003@123:4567"}; final String[] nodes = {"enode://001@123:4567", "enode://002@123:4567", "enode://003@123:4567"};
parseCommand("--bootnodes", String.join(",", nodes)); parseCommand("--bootnodes", String.join(",", nodes));
verify(mockRunnerBuilder) verify(mockRunnerBuilder).bootstrapPeers(stringListArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
stringListArgumentCaptor.capture(),
anyString(),
anyInt(),
anyInt(),
any(),
any(),
any(),
any());
assertThat(stringListArgumentCaptor.getValue().toArray()).isEqualTo(nodes); assertThat(stringListArgumentCaptor.getValue().toArray()).isEqualTo(nodes);
@ -478,19 +424,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
final String[] nodes = {"0001", "0002", "0003"}; final String[] nodes = {"0001", "0002", "0003"};
parseCommand("--banned-nodeids", String.join(",", nodes)); parseCommand("--banned-nodeids", String.join(",", nodes));
verify(mockRunnerBuilder) verify(mockRunnerBuilder).bannedNodeIds(stringListArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
anyInt(),
any(),
any(),
any(),
stringListArgumentCaptor.capture());
assertThat(stringListArgumentCaptor.getValue().toArray()).isEqualTo(nodes); assertThat(stringListArgumentCaptor.getValue().toArray()).isEqualTo(nodes);
@ -505,19 +440,9 @@ public class PantheonCommandTest extends CommandTestAbstract {
final int port = 1234; final int port = 1234;
parseCommand("--p2p-listen", String.format("%1$s:%2$s", host, port)); parseCommand("--p2p-listen", String.format("%1$s:%2$s", host, port));
verify(mockRunnerBuilder) verify(mockRunnerBuilder).discoveryHost(stringArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).discoveryPort(intArgumentCaptor.capture());
any(), verify(mockRunnerBuilder).build();
any(),
anyBoolean(),
any(),
stringArgumentCaptor.capture(),
intArgumentCaptor.capture(),
anyInt(),
any(),
any(),
any(),
any());
assertThat(stringArgumentCaptor.getValue()).isEqualTo(host); assertThat(stringArgumentCaptor.getValue()).isEqualTo(host);
assertThat(intArgumentCaptor.getValue()).isEqualTo(port); assertThat(intArgumentCaptor.getValue()).isEqualTo(port);
@ -532,19 +457,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
final int maxPeers = 123; final int maxPeers = 123;
parseCommand("--max-peers", String.valueOf(maxPeers)); parseCommand("--max-peers", String.valueOf(maxPeers));
verify(mockRunnerBuilder) verify(mockRunnerBuilder).maxPeers(intArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
intArgumentCaptor.capture(),
any(),
any(),
any(),
any());
assertThat(intArgumentCaptor.getValue()).isEqualTo(maxPeers); assertThat(intArgumentCaptor.getValue()).isEqualTo(maxPeers);
@ -579,19 +493,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
public void jsonRpcEnabledPropertyDefaultIsFalse() { public void jsonRpcEnabledPropertyDefaultIsFalse() {
parseCommand(); parseCommand();
verify(mockRunnerBuilder) verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
anyInt(),
jsonRpcConfigArgumentCaptor.capture(),
any(),
any(),
any());
assertThat(jsonRpcConfigArgumentCaptor.getValue().isEnabled()).isFalse(); assertThat(jsonRpcConfigArgumentCaptor.getValue().isEnabled()).isFalse();
@ -603,19 +506,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
public void jsonRpcEnabledPropertyMustBeUsed() { public void jsonRpcEnabledPropertyMustBeUsed() {
parseCommand("--rpc-enabled"); parseCommand("--rpc-enabled");
verify(mockRunnerBuilder) verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
anyInt(),
jsonRpcConfigArgumentCaptor.capture(),
any(),
any(),
any());
assertThat(jsonRpcConfigArgumentCaptor.getValue().isEnabled()).isTrue(); assertThat(jsonRpcConfigArgumentCaptor.getValue().isEnabled()).isTrue();
@ -627,19 +519,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
public void rpcApisPropertyMustBeUsed() { public void rpcApisPropertyMustBeUsed() {
parseCommand("--rpc-api", "ETH,NET"); parseCommand("--rpc-api", "ETH,NET");
verify(mockRunnerBuilder) verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
anyInt(),
jsonRpcConfigArgumentCaptor.capture(),
any(),
any(),
any());
assertThat(jsonRpcConfigArgumentCaptor.getValue().getRpcApis()) assertThat(jsonRpcConfigArgumentCaptor.getValue().getRpcApis())
.containsExactlyInAnyOrder(RpcApis.ETH, RpcApis.NET); .containsExactlyInAnyOrder(RpcApis.ETH, RpcApis.NET);
@ -655,19 +536,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
final int port = 1234; final int port = 1234;
parseCommand("--rpc-listen", String.format("%1$s:%2$s", host, port)); parseCommand("--rpc-listen", String.format("%1$s:%2$s", host, port));
verify(mockRunnerBuilder) verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
anyInt(),
jsonRpcConfigArgumentCaptor.capture(),
any(),
any(),
any());
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHost()).isEqualTo(host); assertThat(jsonRpcConfigArgumentCaptor.getValue().getHost()).isEqualTo(host);
assertThat(jsonRpcConfigArgumentCaptor.getValue().getPort()).isEqualTo(port); assertThat(jsonRpcConfigArgumentCaptor.getValue().getPort()).isEqualTo(port);
@ -681,19 +551,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
final String[] origins = {"http://domain1.com", "https://domain2.com"}; final String[] origins = {"http://domain1.com", "https://domain2.com"};
parseCommand("--rpc-cors-origins", String.join(",", origins)); parseCommand("--rpc-cors-origins", String.join(",", origins));
verify(mockRunnerBuilder) verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
anyInt(),
jsonRpcConfigArgumentCaptor.capture(),
any(),
any(),
any());
assertThat(jsonRpcConfigArgumentCaptor.getValue().getCorsAllowedDomains().toArray()) assertThat(jsonRpcConfigArgumentCaptor.getValue().getCorsAllowedDomains().toArray())
.isEqualTo(origins); .isEqualTo(origins);
@ -707,19 +566,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
final String[] origins = {"*"}; final String[] origins = {"*"};
parseCommand("--rpc-cors-origins", String.join(",", origins)); parseCommand("--rpc-cors-origins", String.join(",", origins));
verify(mockRunnerBuilder) verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
anyInt(),
jsonRpcConfigArgumentCaptor.capture(),
any(),
any(),
any());
assertThat(jsonRpcConfigArgumentCaptor.getValue().getCorsAllowedDomains().toArray()) assertThat(jsonRpcConfigArgumentCaptor.getValue().getCorsAllowedDomains().toArray())
.isEqualTo(origins); .isEqualTo(origins);
@ -733,19 +581,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
final String[] origins = {"all"}; final String[] origins = {"all"};
parseCommand("--rpc-cors-origins", String.join(",", origins)); parseCommand("--rpc-cors-origins", String.join(",", origins));
verify(mockRunnerBuilder) verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
anyInt(),
jsonRpcConfigArgumentCaptor.capture(),
any(),
any(),
any());
assertThat(jsonRpcConfigArgumentCaptor.getValue().getCorsAllowedDomains()) assertThat(jsonRpcConfigArgumentCaptor.getValue().getCorsAllowedDomains())
.isEqualTo(Lists.newArrayList("*")); .isEqualTo(Lists.newArrayList("*"));
@ -759,19 +596,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
final String[] origins = {"none"}; final String[] origins = {"none"};
parseCommand("--rpc-cors-origins", String.join(",", origins)); parseCommand("--rpc-cors-origins", String.join(",", origins));
verify(mockRunnerBuilder) verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
anyInt(),
jsonRpcConfigArgumentCaptor.capture(),
any(),
any(),
any());
assertThat(jsonRpcConfigArgumentCaptor.getValue().getCorsAllowedDomains()).isEmpty(); assertThat(jsonRpcConfigArgumentCaptor.getValue().getCorsAllowedDomains()).isEmpty();
@ -831,19 +657,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
public void wsRpcEnabledPropertyDefaultIsFalse() { public void wsRpcEnabledPropertyDefaultIsFalse() {
parseCommand(); parseCommand();
verify(mockRunnerBuilder) verify(mockRunnerBuilder).webSocketConfiguration(wsRpcConfigArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
anyInt(),
any(),
wsRpcConfigArgumentCaptor.capture(),
any(),
any());
assertThat(wsRpcConfigArgumentCaptor.getValue().isEnabled()).isFalse(); assertThat(wsRpcConfigArgumentCaptor.getValue().isEnabled()).isFalse();
@ -855,19 +670,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
public void wsRpcEnabledPropertyMustBeUsed() { public void wsRpcEnabledPropertyMustBeUsed() {
parseCommand("--ws-enabled"); parseCommand("--ws-enabled");
verify(mockRunnerBuilder) verify(mockRunnerBuilder).webSocketConfiguration(wsRpcConfigArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
anyInt(),
any(),
wsRpcConfigArgumentCaptor.capture(),
any(),
any());
assertThat(wsRpcConfigArgumentCaptor.getValue().isEnabled()).isTrue(); assertThat(wsRpcConfigArgumentCaptor.getValue().isEnabled()).isTrue();
@ -879,19 +683,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
public void wsApiPropertyMustBeUsed() { public void wsApiPropertyMustBeUsed() {
parseCommand("--ws-api", "ETH, NET"); parseCommand("--ws-api", "ETH, NET");
verify(mockRunnerBuilder) verify(mockRunnerBuilder).webSocketConfiguration(wsRpcConfigArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
anyInt(),
any(),
wsRpcConfigArgumentCaptor.capture(),
any(),
any());
assertThat(wsRpcConfigArgumentCaptor.getValue().getRpcApis()) assertThat(wsRpcConfigArgumentCaptor.getValue().getRpcApis())
.containsExactlyInAnyOrder(RpcApis.ETH, RpcApis.NET); .containsExactlyInAnyOrder(RpcApis.ETH, RpcApis.NET);
@ -906,19 +699,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
final int port = 1234; final int port = 1234;
parseCommand("--ws-listen", String.format("%1$s:%2$s", host, port)); parseCommand("--ws-listen", String.format("%1$s:%2$s", host, port));
verify(mockRunnerBuilder) verify(mockRunnerBuilder).webSocketConfiguration(wsRpcConfigArgumentCaptor.capture());
.build( verify(mockRunnerBuilder).build();
any(),
any(),
anyBoolean(),
any(),
anyString(),
anyInt(),
anyInt(),
any(),
wsRpcConfigArgumentCaptor.capture(),
any(),
any());
assertThat(wsRpcConfigArgumentCaptor.getValue().getHost()).isEqualTo(host); assertThat(wsRpcConfigArgumentCaptor.getValue().getHost()).isEqualTo(host);
assertThat(wsRpcConfigArgumentCaptor.getValue().getPort()).isEqualTo(port); assertThat(wsRpcConfigArgumentCaptor.getValue().getPort()).isEqualTo(port);
@ -928,12 +710,9 @@ public class PantheonCommandTest extends CommandTestAbstract {
} }
@Test @Test
public void pantheonDoesNotStartInMiningModeIfCoinbaseNotSet() throws Exception { public void pantheonDoesNotStartInMiningModeIfCoinbaseNotSet() {
parseCommand("--miner-enabled"); parseCommand("--miner-enabled");
final ArgumentCaptor<MiningParameters> miningArg =
ArgumentCaptor.forClass(MiningParameters.class);
verifyZeroInteractions(mockControllerBuilder); verifyZeroInteractions(mockControllerBuilder);
} }
@ -945,8 +724,9 @@ public class PantheonCommandTest extends CommandTestAbstract {
final ArgumentCaptor<MiningParameters> miningArg = final ArgumentCaptor<MiningParameters> miningArg =
ArgumentCaptor.forClass(MiningParameters.class); ArgumentCaptor.forClass(MiningParameters.class);
verify(mockControllerBuilder) verify(mockControllerBuilder).miningParameters(miningArg.capture());
.build(any(), any(), any(), anyBoolean(), miningArg.capture(), anyBoolean(), any()); verify(mockControllerBuilder).build();
assertThat(commandOutput.toString()).isEmpty(); assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(miningArg.getValue().isMiningEnabled()).isTrue(); assertThat(miningArg.getValue().isMiningEnabled()).isTrue();
@ -967,8 +747,9 @@ public class PantheonCommandTest extends CommandTestAbstract {
final ArgumentCaptor<MiningParameters> miningArg = final ArgumentCaptor<MiningParameters> miningArg =
ArgumentCaptor.forClass(MiningParameters.class); ArgumentCaptor.forClass(MiningParameters.class);
verify(mockControllerBuilder) verify(mockControllerBuilder).miningParameters(miningArg.capture());
.build(any(), any(), any(), anyBoolean(), miningArg.capture(), anyBoolean(), any()); verify(mockControllerBuilder).build();
assertThat(commandOutput.toString()).isEmpty(); assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(miningArg.getValue().getCoinbase()).isEqualTo(Optional.of(requestedCoinbase)); assertThat(miningArg.getValue().getCoinbase()).isEqualTo(Optional.of(requestedCoinbase));
@ -980,7 +761,10 @@ public class PantheonCommandTest extends CommandTestAbstract {
@Test @Test
public void devModeOptionMustBeUsed() throws Exception { public void devModeOptionMustBeUsed() throws Exception {
parseCommand("--dev-mode"); parseCommand("--dev-mode");
verify(mockControllerBuilder).build(any(), any(), any(), anyBoolean(), any(), eq(true), any());
verify(mockControllerBuilder).devMode(eq(true));
verify(mockControllerBuilder).build();
assertThat(commandOutput.toString()).isEmpty(); assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty();
} }
@ -991,8 +775,10 @@ public class PantheonCommandTest extends CommandTestAbstract {
final ArgumentCaptor<EthNetworkConfig> networkArg = final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class); ArgumentCaptor.forClass(EthNetworkConfig.class);
verify(mockControllerBuilder)
.build(any(), any(), networkArg.capture(), anyBoolean(), any(), anyBoolean(), any()); verify(mockControllerBuilder).ethNetworkConfig(networkArg.capture());
verify(mockControllerBuilder).build();
assertThat(commandOutput.toString()).isEmpty(); assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.rinkeby()); assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.rinkeby());
@ -1013,8 +799,10 @@ public class PantheonCommandTest extends CommandTestAbstract {
final ArgumentCaptor<EthNetworkConfig> networkArg = final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class); ArgumentCaptor.forClass(EthNetworkConfig.class);
verify(mockControllerBuilder)
.build(any(), any(), networkArg.capture(), anyBoolean(), any(), anyBoolean(), any()); verify(mockControllerBuilder).ethNetworkConfig(networkArg.capture());
verify(mockControllerBuilder).build();
assertThat(commandOutput.toString()).isEmpty(); assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(networkArg.getValue().getGenesisConfig()).isEqualTo("genesis_config"); assertThat(networkArg.getValue().getGenesisConfig()).isEqualTo("genesis_config");

Loading…
Cancel
Save