use of org.hyperledger.besu.plugin.data.EnodeURL in project besu by hyperledger.
the class EnodeURLImplTest method builder_listeningDisabled.
@Test
public void builder_listeningDisabled() {
final EnodeURL enodeURL = EnodeURLImpl.builder().nodeId(VALID_NODE_ID).ipAddress(IPV4_ADDRESS).discoveryPort(P2P_PORT).disableListening().build();
assertThat(enodeURL.getNodeId().toUnprefixedHexString()).isEqualTo(VALID_NODE_ID);
assertThat(enodeURL.getIpAsString()).isEqualTo(IPV4_ADDRESS);
assertThat(enodeURL.getListeningPortOrZero()).isEqualTo(0);
assertThat(enodeURL.getDiscoveryPortOrZero()).isEqualTo(P2P_PORT);
assertThat(enodeURL.isListening()).isFalse();
assertThat(enodeURL.isRunningDiscovery()).isTrue();
}
use of org.hyperledger.besu.plugin.data.EnodeURL in project besu by hyperledger.
the class EnodeURLImplTest method builder_listeningAndDiscoveryDisabled.
@Test
public void builder_listeningAndDiscoveryDisabled() {
final EnodeURL enodeURL = EnodeURLImpl.builder().nodeId(VALID_NODE_ID).ipAddress(IPV4_ADDRESS).disableDiscovery().disableListening().build();
assertThat(enodeURL.getNodeId().toUnprefixedHexString()).isEqualTo(VALID_NODE_ID);
assertThat(enodeURL.getIpAsString()).isEqualTo(IPV4_ADDRESS);
assertThat(enodeURL.getListeningPortOrZero()).isEqualTo(0);
assertThat(enodeURL.getDiscoveryPortOrZero()).isEqualTo(0);
assertThat(enodeURL.isListening()).isFalse();
assertThat(enodeURL.isRunningDiscovery()).isFalse();
}
use of org.hyperledger.besu.plugin.data.EnodeURL in project besu by hyperledger.
the class EnodeURLImplTest method build_withNonMatchingDiscoveryAndListeningPorts.
@Test
public void build_withNonMatchingDiscoveryAndListeningPorts() {
final EnodeURL enode = EnodeURLImpl.builder().nodeId(VALID_NODE_ID).ipAddress(IPV4_ADDRESS).listeningPort(P2P_PORT).discoveryPort(Optional.of(DISCOVERY_PORT)).build();
assertThat(enode.getListeningPortOrZero()).isEqualTo(P2P_PORT);
assertThat(enode.getDiscoveryPortOrZero()).isEqualTo(DISCOVERY_PORT);
}
use of org.hyperledger.besu.plugin.data.EnodeURL in project besu by hyperledger.
the class EnodeURLImplTest method fromString_withIPV6InCompactFormShouldBuildExpectedEnodeURLObject.
@Test
public void fromString_withIPV6InCompactFormShouldBuildExpectedEnodeURLObject() {
final EnodeURL expectedEnodeURL = EnodeURLImpl.builder().nodeId(VALID_NODE_ID).ipAddress(IPV6_COMPACT_ADDRESS).listeningPort(P2P_PORT).discoveryPort(Optional.of(DISCOVERY_PORT)).build();
final String enodeURLString = "enode://" + VALID_NODE_ID + "@" + IPV6_COMPACT_ADDRESS + ":" + P2P_PORT + "?" + DISCOVERY_QUERY;
final EnodeURL enodeURL = EnodeURLImpl.fromString(enodeURLString);
assertThat(enodeURL).isEqualTo(expectedEnodeURL);
assertThat(enodeURL.toString()).isEqualTo(enodeURLString);
}
use of org.hyperledger.besu.plugin.data.EnodeURL in project besu by hyperledger.
the class StaticNodesParserTest method anEmptyCacheIsCreatedIfTheFileDoesNotExist.
@Test
public void anEmptyCacheIsCreatedIfTheFileDoesNotExist() throws IOException {
final Path path = Paths.get("./arbirtraryFilename.txt");
final Set<EnodeURL> enodes = StaticNodesParser.fromPath(path, EnodeDnsConfiguration.DEFAULT_CONFIG);
assertThat(enodes.size()).isZero();
}
Aggregations