@ -26,7 +26,6 @@ import static org.hyperledger.besu.cli.config.NetworkName.MORDOR;
import static org.hyperledger.besu.cli.config.NetworkName.RINKEBY ;
import static org.hyperledger.besu.cli.config.NetworkName.ROPSTEN ;
import static org.hyperledger.besu.cli.util.CommandLineUtils.DEPENDENCY_WARNING_MSG ;
import static org.hyperledger.besu.cli.util.CommandLineUtils.MULTI_DEPENDENCY_WARNING_MSG ;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.ETH ;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.NET ;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.PERM ;
@ -77,7 +76,6 @@ import org.hyperledger.besu.metrics.StandardMetricCategory;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration ;
import org.hyperledger.besu.nat.NatMethod ;
import org.hyperledger.besu.plugin.data.EnodeURL ;
import org.hyperledger.besu.util.StringUtils ;
import org.hyperledger.besu.util.number.Fraction ;
import org.hyperledger.besu.util.number.Percentage ;
@ -135,9 +133,9 @@ public class BesuCommandTest extends CommandTestAbstract {
( new JsonObject ( ) )
. put (
"config" ,
new JsonObject ( ) . put ( "isq uorum" , true ) . put ( "chainId" , GENESIS_CONFIG_TEST_CHAINID ) ) ;
new JsonObject ( ) . put ( "isQ uorum" , true ) . put ( "chainId" , GENESIS_CONFIG_TEST_CHAINID ) ) ;
private static final JsonObject INVALID_GENESIS_QUORUM_INTEROP_ENABLED_MAINNET =
( new JsonObject ( ) ) . put ( "config" , new JsonObject ( ) . put ( "isq uorum" , true ) ) ;
( new JsonObject ( ) ) . put ( "config" , new JsonObject ( ) . put ( "isQ uorum" , true ) ) ;
private static final JsonObject INVALID_GENESIS_EC_CURVE =
( new JsonObject ( ) ) . put ( "config" , new JsonObject ( ) . put ( "ecCurve" , "abcd" ) ) ;
private static final JsonObject VALID_GENESIS_EC_CURVE =
@ -1619,7 +1617,8 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test
public void launcherOptionIsParsedCorrectly ( ) {
TestBesuCommand besuCommand = parseCommand ( "--Xlauncher" , "true" , "--Xlauncher-force" , "true" ) ;
final TestBesuCommand besuCommand =
parseCommand ( "--Xlauncher" , "true" , "--Xlauncher-force" , "true" ) ;
assertThat ( besuCommand . getLauncherOptions ( ) . isLauncherMode ( ) ) . isTrue ( ) ;
assertThat ( besuCommand . getEnodeDnsConfiguration ( ) . updateEnabled ( ) ) . isFalse ( ) ;
@ -1975,7 +1974,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test
public void rpcHttpMaxActiveConnectionsPropertyMustBeUsed ( ) {
int maxConnections = 99 ;
final int maxConnections = 99 ;
parseCommand ( "--rpc-http-max-active-connections" , String . valueOf ( maxConnections ) ) ;
verify ( mockRunnerBuilder ) . jsonRpcConfiguration ( jsonRpcConfigArgumentCaptor . capture ( ) ) ;
@ -1990,7 +1989,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test
public void rpcWsMaxActiveConnectionsPropertyMustBeUsed ( ) {
int maxConnections = 99 ;
final int maxConnections = 99 ;
parseCommand ( "--rpc-ws-max-active-connections" , String . valueOf ( maxConnections ) ) ;
verify ( mockRunnerBuilder ) . webSocketConfiguration ( wsRpcConfigArgumentCaptor . capture ( ) ) ;
@ -3005,14 +3004,14 @@ public class BesuCommandTest extends CommandTestAbstract {
parseCommand ( "--min-gas-price" , "0" ) ;
verifyMultiOptionsConstraintLoggerCall (
List . of ( "--miner-enabled" , "--goquorum-compatibility-enabled" ) , "--min-gas-price ") ;
"--min-gas-price ignored because none of --miner-enabled or isQuorum (in genesis file) was defined. ") ;
assertThat ( commandOutput . toString ( ) ) . isEmpty ( ) ;
assertThat ( commandErrorOutput . toString ( ) ) . isEmpty ( ) ;
}
@Test
public void miningParametersAreCaptured ( ) throws Exception {
public void miningParametersAreCaptured ( ) {
final Address requestedCoinbase = Address . fromHexString ( "0000011111222223333344444" ) ;
final String extraDataString =
"0x1122334455667788990011223344556677889900112233445566778899001122" ;
@ -3337,9 +3336,7 @@ public class BesuCommandTest extends CommandTestAbstract {
parseCommand ( "--privacy-url" , ENCLAVE_URI , "--privacy-public-key-file" , file . toString ( ) ) ;
verifyMultiOptionsConstraintLoggerCall (
List . of ( "--privacy-enabled" , "--goquorum-compatibility-enabled" ) ,
"--privacy-url" ,
"--privacy-public-key-file" ) ;
"--privacy-url and/or --privacy-public-key-file ignored because none of --privacy-enabled or isQuorum (in genesis file) was defined." ) ;
assertThat ( commandOutput . toString ( ) ) . isEmpty ( ) ;
assertThat ( commandErrorOutput . toString ( ) ) . isEmpty ( ) ;
@ -3553,25 +3550,10 @@ public class BesuCommandTest extends CommandTestAbstract {
* < p > Here we check the calls to logger and not the result of the log line as we don ' t test the
* logger itself but the fact that we call it .
*
* @param dependentOptions the string representing the list of dependent options names
* @param mainOptions the main option names
* @param stringToLog the string that is logged
* /
private void verifyMultiOptionsConstraintLoggerCall (
final List < String > mainOptions , final String . . . dependentOptions ) {
verify ( mockLogger , atLeast ( 1 ) )
. warn (
stringArgumentCaptor . capture ( ) ,
stringArgumentCaptor . capture ( ) ,
stringArgumentCaptor . capture ( ) ) ;
assertThat ( stringArgumentCaptor . getAllValues ( ) . get ( 0 ) ) . isEqualTo ( MULTI_DEPENDENCY_WARNING_MSG ) ;
for ( final String option : dependentOptions ) {
assertThat ( stringArgumentCaptor . getAllValues ( ) . get ( 1 ) ) . contains ( option ) ;
}
final String joinedOptions =
StringUtils . joiningWithLastDelimiter ( ", " , " or " ) . apply ( mainOptions ) ;
assertThat ( stringArgumentCaptor . getAllValues ( ) . get ( 2 ) ) . isEqualTo ( joinedOptions ) ;
private void verifyMultiOptionsConstraintLoggerCall ( final String stringToLog ) {
verify ( mockLogger , atLeast ( 1 ) ) . warn ( stringToLog ) ;
}
@Test
@ -3595,29 +3577,13 @@ public class BesuCommandTest extends CommandTestAbstract {
final Path genesisFile =
createFakeGenesisFile ( VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID ) ;
parseCommand (
"--goquorum-compatibility-enabled" ,
"--privacy-enabled" ,
"--genesis-file" ,
genesisFile . toString ( ) ,
"--min-gas-price" ,
"0" ) ;
"--privacy-enabled" , "--genesis-file" , genesisFile . toString ( ) , "--min-gas-price" , "0" ) ;
assertThat ( commandErrorOutput . toString ( ) )
. contains ( "GoQuorum mode cannot be enabled with privacy." ) ;
assertThat ( commandOutput . toString ( ) ) . isEmpty ( ) ;
}
@Test
public void goQuorumGenesisFileWithoutGoQuorumCompatibilityMustError ( ) throws IOException {
final Path genesisFile =
createFakeGenesisFile ( VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID ) ;
parseCommand ( "--genesis-file" , genesisFile . toString ( ) ) ;
assertThat ( commandErrorOutput . toString ( ) )
. contains ( "Cannot use GoQuorum genesis file without GoQuorum privacy enabled" ) ;
assertThat ( commandOutput . toString ( ) ) . isEmpty ( ) ;
}
@Rule public TemporaryFolder testFolder = new TemporaryFolder ( ) ;
@Test
@ -4152,10 +4118,9 @@ public class BesuCommandTest extends CommandTestAbstract {
}
@Test
public void quorumInteropDisabled DoesNotEnforceZeroGasPrice ( ) throws IOException {
public void quorumInteropNotDefinedInGenesis DoesNotEnforceZeroGasPrice ( ) throws IOException {
final Path genesisFile = createFakeGenesisFile ( GENESIS_VALID_JSON ) ;
parseCommand (
"--goquorum-compatibility-enabled=false" , "--genesis-file" , genesisFile . toString ( ) ) ;
parseCommand ( "--genesis-file" , genesisFile . toString ( ) ) ;
assertThat ( commandErrorOutput . toString ( ) ) . isEmpty ( ) ;
}
@ -4163,25 +4128,20 @@ public class BesuCommandTest extends CommandTestAbstract {
public void quorumInteropEnabledFailsWithoutGasPriceSet ( ) throws IOException {
final Path genesisFile =
createFakeGenesisFile ( VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID ) ;
parseCommand ( "--goquorum-compatibility-enabled" , "--g enesis-file" , genesisFile . toString ( ) ) ;
parseCommand ( "--genesis-file" , genesisFile . toString ( ) ) ;
assertThat ( commandErrorOutput . toString ( ) )
. contains (
"--min-gas-price must be set to zero if GoQuorum compatibility is enabled in the genesis config ." ) ;
"--min-gas-price must be set to zero if isQuorum mode is enabled in the genesis file ." ) ;
}
@Test
public void quorumInteropEnabledFailsWithoutGasPriceSetToZero ( ) throws IOException {
final Path genesisFile =
createFakeGenesisFile ( VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID ) ;
parseCommand (
"--goquorum-compatibility-enabled" ,
"--genesis-file" ,
genesisFile . toString ( ) ,
"--min-gas-price" ,
"1" ) ;
parseCommand ( "--genesis-file" , genesisFile . toString ( ) , "--min-gas-price" , "1" ) ;
assertThat ( commandErrorOutput . toString ( ) )
. contains (
"--min-gas-price must be set to zero if GoQuorum compatibility is enabled in the genesis config ." ) ;
"--min-gas-price must be set to zero if isQuorum mode is enabled in the genesis file." ) ;
}
@Test
@ -4189,7 +4149,6 @@ public class BesuCommandTest extends CommandTestAbstract {
final Path genesisFile =
createFakeGenesisFile ( VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID ) ;
parseCommand (
"--goquorum-compatibility-enabled" ,
"--genesis-file" ,
genesisFile . toString ( ) ,
"--min-gas-price" ,
@ -4204,7 +4163,6 @@ public class BesuCommandTest extends CommandTestAbstract {
final Path genesisFile =
createFakeGenesisFile ( VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID ) ;
parseCommand (
"--goquorum-compatibility-enabled" ,
"--genesis-file" ,
genesisFile . toString ( ) ,
"--min-gas-price" ,
@ -4212,57 +4170,31 @@ public class BesuCommandTest extends CommandTestAbstract {
"--privacy-public-key-file" ,
"ThisFileDoesNotExist" ) ;
assertThat ( commandErrorOutput . toString ( ) )
. contains (
"--privacy-public-key-file must be set when --goquorum-compatibility-enabled is set to true." ) ;
. contains ( "--privacy-public-key-file must be set if isQuorum is set in the genesis file." ) ;
}
@Test
public void quorumInteropEnabledFailsIfEnclaveKeyFileIsNotSet ( ) throws IOException {
final Path genesisFile =
createFakeGenesisFile ( VALID_GENESIS_QUORUM_INTEROP_ENABLED_WITH_CHAINID ) ;
parseCommand (
"--goquorum-compatibility-enabled" ,
"--genesis-file" ,
genesisFile . toString ( ) ,
"--min-gas-price" ,
"0" ) ;
assertThat ( commandErrorOutput . toString ( ) )
. contains (
"--privacy-public-key-file must be set when --goquorum-compatibility-enabled is set to true." ) ;
}
@Test
public void quorumInteropEnabledFailsIfGenesisFileNotSet ( ) {
parseCommand ( "--goquorum-compatibility-enabled" ) ;
parseCommand ( "--genesis-file" , genesisFile . toString ( ) , "--min-gas-price" , "0" ) ;
assertThat ( commandErrorOutput . toString ( ) )
. contains ( "--genesis-file must be specified if GoQuorum compatibility mode is enabled ." ) ;
. contains ( "--privacy-public-key-file must be set if isQuorum is set in the genesis file." ) ;
}
@Test
public void quorumInteropEnabledFailsWithMainnetDefaultNetwork ( ) throws IOException {
final Path genesisFile = createFakeGenesisFile ( INVALID_GENESIS_QUORUM_INTEROP_ENABLED_MAINNET ) ;
parseCommand (
"--goquorum-compatibility-enabled" ,
"--genesis-file" ,
genesisFile . toString ( ) ,
"--min-gas-price" ,
"0" ) ;
assertThat ( commandErrorOutput . toString ( ) )
. contains ( "GoQuorum compatibility mode (enabled) cannot be used on Mainnet" ) ;
parseCommand ( "--genesis-file" , genesisFile . toString ( ) , "--min-gas-price" , "0" ) ;
assertThat ( commandErrorOutput . toString ( ) ) . contains ( "isQuorum mode cannot be used on Mainnet." ) ;
}
@Test
public void quorumInteropEnabledFailsWithMainnetChainId ( ) throws IOException {
final Path genesisFile =
createFakeGenesisFile ( INVALID_GENESIS_QUORUM_INTEROP_ENABLED_MAINNET . put ( "chainId" , "1" ) ) ;
parseCommand (
"--goquorum-compatibility-enabled" ,
"--genesis-file" ,
genesisFile . toString ( ) ,
"--min-gas-price" ,
"0" ) ;
assertThat ( commandErrorOutput . toString ( ) )
. contains ( "GoQuorum compatibility mode (enabled) cannot be used on Mainnet" ) ;
parseCommand ( "--genesis-file" , genesisFile . toString ( ) , "--min-gas-price" , "0" ) ;
assertThat ( commandErrorOutput . toString ( ) ) . contains ( "isQuorum mode cannot be used on Mainnet." ) ;
}
@Test