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));
}
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();
}
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));
}
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();
}
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();
}
Aggregations