@ -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" ) ;