@ -17,6 +17,7 @@ import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat ;
import static org.junit.Assume.assumeFalse ;
import static org.junit.Assume.assumeTrue ;
import static org.mockito.ArgumentMatchers.any ;
import static org.mockito.ArgumentMatchers.eq ;
import static org.mockito.ArgumentMatchers.isNotNull ;
import static org.mockito.Mockito.atLeast ;
@ -70,6 +71,7 @@ import java.util.Arrays;
import java.util.Collections ;
import java.util.HashSet ;
import java.util.List ;
import java.util.Map ;
import java.util.Optional ;
import java.util.stream.Collectors ;
import java.util.stream.Stream ;
@ -168,7 +170,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
verify ( mockRunnerBuilder ) . ethNetworkConfig ( ethNetworkArg . capture ( ) ) ;
verify ( mockRunnerBuilder ) . build ( ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( ethNetworkArg . capture ( ) ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( ethNetworkArg . capture ( ) , any ( ) ) ;
final ArgumentCaptor < MiningParameters > miningArg =
ArgumentCaptor . forClass ( MiningParameters . class ) ;
verify ( mockControllerBuilder ) . synchronizerConfiguration ( syncConfigurationCaptor . capture ( ) ) ;
@ -333,7 +335,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
. setBootNodes ( nodes )
. build ( ) ;
verify ( mockControllerBuilder ) . dataDirectory ( eq ( Paths . get ( "/opt/pantheon" ) . toAbsolutePath ( ) ) ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( eq ( networkConfig ) ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( eq ( networkConfig ) , any ( ) ) ;
verify ( mockControllerBuilder ) . synchronizerConfiguration ( syncConfigurationCaptor . capture ( ) ) ;
assertThat ( syncConfigurationCaptor . getValue ( ) . getSyncMode ( ) ) . isEqualTo ( SyncMode . FAST ) ;
@ -891,7 +893,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
parseCommand ( "--genesis-file" , genesisFile . toString ( ) ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) , any ( ) ) ;
verify ( mockControllerBuilder ) . build ( ) ;
assertThat ( networkArg . getValue ( ) . getGenesisConfig ( ) )
@ -927,7 +929,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
final ArgumentCaptor < EthNetworkConfig > networkArg =
ArgumentCaptor . forClass ( EthNetworkConfig . class ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) , any ( ) ) ;
verify ( mockControllerBuilder ) . build ( ) ;
assertThat ( networkArg . getValue ( ) . getGenesisConfig ( ) )
@ -950,7 +952,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
final ArgumentCaptor < EthNetworkConfig > networkArg =
ArgumentCaptor . forClass ( EthNetworkConfig . class ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) , any ( ) ) ;
verify ( mockControllerBuilder ) . build ( ) ;
assertThat ( networkArg . getValue ( ) . getGenesisConfig ( ) )
@ -963,6 +965,22 @@ public class PantheonCommandTest extends CommandTestAbstract {
assertThat ( commandErrorOutput . toString ( ) ) . isEmpty ( ) ;
}
@Test
@SuppressWarnings ( "unchecked" )
public void overrideGenesisConfigFileChange ( ) throws Exception {
final ArgumentCaptor < Map < String , String > > overrides = ArgumentCaptor . forClass ( Map . class ) ;
parseCommand ( "--network=dev" , "--override-genesis-config=chainId=8675309" ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( any ( ) , overrides . capture ( ) ) ;
verify ( mockControllerBuilder ) . build ( ) ;
assertThat ( overrides . getValue ( ) ) . containsOnlyKeys ( "chainId" ) ;
assertThat ( overrides . getValue ( ) ) . containsEntry ( "chainId" , "8675309" ) ;
assertThat ( commandOutput . toString ( ) ) . isEmpty ( ) ;
assertThat ( commandErrorOutput . toString ( ) ) . isEmpty ( ) ;
}
@Test
public void predefinedNetworkIdsMustBeEqualToChainIds ( ) {
// check the network id against the one in mainnet genesis config
@ -2344,7 +2362,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
final ArgumentCaptor < EthNetworkConfig > networkArg =
ArgumentCaptor . forClass ( EthNetworkConfig . class ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) , any ( ) ) ;
verify ( mockControllerBuilder ) . build ( ) ;
assertThat ( networkArg . getValue ( ) ) . isEqualTo ( EthNetworkConfig . getNetworkConfig ( DEV ) ) ;
@ -2360,7 +2378,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
final ArgumentCaptor < EthNetworkConfig > networkArg =
ArgumentCaptor . forClass ( EthNetworkConfig . class ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) , any ( ) ) ;
verify ( mockControllerBuilder ) . build ( ) ;
assertThat ( networkArg . getValue ( ) ) . isEqualTo ( EthNetworkConfig . getNetworkConfig ( RINKEBY ) ) ;
@ -2376,7 +2394,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
final ArgumentCaptor < EthNetworkConfig > networkArg =
ArgumentCaptor . forClass ( EthNetworkConfig . class ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) , any ( ) ) ;
verify ( mockControllerBuilder ) . build ( ) ;
assertThat ( networkArg . getValue ( ) ) . isEqualTo ( EthNetworkConfig . getNetworkConfig ( ROPSTEN ) ) ;
@ -2392,7 +2410,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
final ArgumentCaptor < EthNetworkConfig > networkArg =
ArgumentCaptor . forClass ( EthNetworkConfig . class ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) , any ( ) ) ;
verify ( mockControllerBuilder ) . build ( ) ;
assertThat ( networkArg . getValue ( ) ) . isEqualTo ( EthNetworkConfig . getNetworkConfig ( GOERLI ) ) ;
@ -2433,7 +2451,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
final ArgumentCaptor < EthNetworkConfig > networkArg =
ArgumentCaptor . forClass ( EthNetworkConfig . class ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) ) ;
verify ( mockControllerBuilderFactory ) . fromEthNetworkConfig ( networkArg . capture ( ) , any ( ) ) ;
verify ( mockControllerBuilder ) . build ( ) ;
assertThat ( networkArg . getValue ( ) . getBootNodes ( ) )