Search in sources :

Example 1 with EthNetworkConfig

use of org.hyperledger.besu.cli.config.EthNetworkConfig in project besu by hyperledger.

the class BesuCommandTest method testGenesisPathMainnetEthConfig.

@Test
public void testGenesisPathMainnetEthConfig() throws Exception {
    final ArgumentCaptor<EthNetworkConfig> networkArg = ArgumentCaptor.forClass(EthNetworkConfig.class);
    parseCommand("--network", "mainnet");
    verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
    verify(mockControllerBuilder).build();
    final EthNetworkConfig config = networkArg.getValue();
    assertThat(config.getBootNodes()).isEqualTo(MAINNET_BOOTSTRAP_NODES);
    assertThat(config.getDnsDiscoveryUrl()).isEqualTo(MAINNET_DISCOVERY_URL);
    assertThat(config.getNetworkId()).isEqualTo(BigInteger.valueOf(1));
}
Also used : EthNetworkConfig(org.hyperledger.besu.cli.config.EthNetworkConfig) Test(org.junit.Test)

Example 2 with EthNetworkConfig

use of org.hyperledger.besu.cli.config.EthNetworkConfig in project besu by hyperledger.

the class BesuCommandTest method genesisPathOptionMustBeUsed.

@Test
public void genesisPathOptionMustBeUsed() throws Exception {
    final Path genesisFile = createFakeGenesisFile(GENESIS_VALID_JSON);
    final ArgumentCaptor<EthNetworkConfig> networkArg = ArgumentCaptor.forClass(EthNetworkConfig.class);
    parseCommand("--genesis-file", genesisFile.toString());
    verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
    verify(mockControllerBuilder).build();
    assertThat(networkArg.getValue().getGenesisConfig()).isEqualTo(encodeJsonGenesis(GENESIS_VALID_JSON));
    assertThat(commandOutput.toString(UTF_8)).isEmpty();
    assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
Also used : Path(java.nio.file.Path) EthNetworkConfig(org.hyperledger.besu.cli.config.EthNetworkConfig) Test(org.junit.Test)

Example 3 with EthNetworkConfig

use of org.hyperledger.besu.cli.config.EthNetworkConfig in project besu by hyperledger.

the class BesuCommandTest method testGenesisPathEthOptions.

@Test
public void testGenesisPathEthOptions() throws Exception {
    final Path genesisFile = createFakeGenesisFile(GENESIS_VALID_JSON);
    final ArgumentCaptor<EthNetworkConfig> networkArg = ArgumentCaptor.forClass(EthNetworkConfig.class);
    parseCommand("--genesis-file", genesisFile.toString());
    verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
    verify(mockControllerBuilder).build();
    final EthNetworkConfig config = networkArg.getValue();
    assertThat(config.getBootNodes()).isEmpty();
    assertThat(config.getDnsDiscoveryUrl()).isNull();
    assertThat(config.getNetworkId()).isEqualTo(BigInteger.valueOf(3141592));
}
Also used : Path(java.nio.file.Path) EthNetworkConfig(org.hyperledger.besu.cli.config.EthNetworkConfig) Test(org.junit.Test)

Example 4 with EthNetworkConfig

use of org.hyperledger.besu.cli.config.EthNetworkConfig in project besu by hyperledger.

the class BesuCommandTest method defaultNetworkIdForInvalidGenesisMustBeMainnetNetworkId.

@Test
public void defaultNetworkIdForInvalidGenesisMustBeMainnetNetworkId() throws Exception {
    final Path genesisFile = createFakeGenesisFile(GENESIS_INVALID_DATA);
    parseCommand("--genesis-file", genesisFile.toString());
    final ArgumentCaptor<EthNetworkConfig> networkArg = ArgumentCaptor.forClass(EthNetworkConfig.class);
    verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
    verify(mockControllerBuilder).build();
    assertThat(networkArg.getValue().getGenesisConfig()).isEqualTo(encodeJsonGenesis(GENESIS_INVALID_DATA));
    // assertThat(networkArg.getValue().getNetworkId())
    // .isEqualTo(EthNetworkConfig.getNetworkConfig(MAINNET).getNetworkId());
    assertThat(commandOutput.toString(UTF_8)).isEmpty();
    assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
Also used : Path(java.nio.file.Path) EthNetworkConfig(org.hyperledger.besu.cli.config.EthNetworkConfig) Test(org.junit.Test)

Example 5 with EthNetworkConfig

use of org.hyperledger.besu.cli.config.EthNetworkConfig in project besu by hyperledger.

the class BesuCommandTest method defaultNetworkIdAndBootnodesForCustomNetworkOptions.

@Test
public void defaultNetworkIdAndBootnodesForCustomNetworkOptions() throws Exception {
    final Path genesisFile = createFakeGenesisFile(GENESIS_VALID_JSON);
    parseCommand("--genesis-file", genesisFile.toString());
    final ArgumentCaptor<EthNetworkConfig> networkArg = ArgumentCaptor.forClass(EthNetworkConfig.class);
    verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
    verify(mockControllerBuilder).build();
    assertThat(networkArg.getValue().getGenesisConfig()).isEqualTo(encodeJsonGenesis(GENESIS_VALID_JSON));
    assertThat(networkArg.getValue().getBootNodes()).isEmpty();
    assertThat(networkArg.getValue().getNetworkId()).isEqualTo(GENESIS_CONFIG_TEST_CHAINID);
    assertThat(commandOutput.toString(UTF_8)).isEmpty();
    assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
Also used : Path(java.nio.file.Path) EthNetworkConfig(org.hyperledger.besu.cli.config.EthNetworkConfig) Test(org.junit.Test)

Aggregations

EthNetworkConfig (org.hyperledger.besu.cli.config.EthNetworkConfig)25 Test (org.junit.Test)22 Path (java.nio.file.Path)12 GraphQLConfiguration (org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration)10 JsonRpcConfiguration (org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration)8 WebSocketConfiguration (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration)7 EnodeURL (org.hyperledger.besu.plugin.data.EnodeURL)7 RpcEndpointServiceImpl (org.hyperledger.besu.services.RpcEndpointServiceImpl)7 InMemoryKeyValueStorageProvider (org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider)6 KeyValueStorageProvider (org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider)6 MockitoJUnitRunner (org.mockito.junit.MockitoJUnitRunner)6 ObservableMetricsSystem (org.hyperledger.besu.metrics.ObservableMetricsSystem)5 URL (java.net.URL)4 MergeMiningCoordinator (org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator)4 JsonRpcIpcConfiguration (org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration)4 SynchronizerConfiguration (org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration)4 MetricsConfiguration (org.hyperledger.besu.metrics.prometheus.MetricsConfiguration)4 File (java.io.File)3 GenesisConfigFile (org.hyperledger.besu.config.GenesisConfigFile)3 MiningParameters (org.hyperledger.besu.ethereum.core.MiningParameters)3