Search in sources :

Example 96 with EnodeURL

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();
}
Also used : EnodeURL(org.hyperledger.besu.plugin.data.EnodeURL) Test(org.junit.Test)

Example 97 with EnodeURL

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();
}
Also used : EnodeURL(org.hyperledger.besu.plugin.data.EnodeURL) Test(org.junit.Test)

Example 98 with EnodeURL

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);
}
Also used : EnodeURL(org.hyperledger.besu.plugin.data.EnodeURL) Test(org.junit.Test)

Example 99 with EnodeURL

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);
}
Also used : EnodeURL(org.hyperledger.besu.plugin.data.EnodeURL) Test(org.junit.Test)

Example 100 with EnodeURL

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();
}
Also used : Path(java.nio.file.Path) EnodeURL(org.hyperledger.besu.plugin.data.EnodeURL) Test(org.junit.Test)

Aggregations

EnodeURL (org.hyperledger.besu.plugin.data.EnodeURL)109 Test (org.junit.Test)83 Bytes (org.apache.tuweni.bytes.Bytes)26 PeerConnection (org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection)22 DefaultPeer (org.hyperledger.besu.ethereum.p2p.peers.DefaultPeer)17 Peer (org.hyperledger.besu.ethereum.p2p.peers.Peer)17 NodeKey (org.hyperledger.besu.crypto.NodeKey)14 Path (java.nio.file.Path)12 CompletableFuture (java.util.concurrent.CompletableFuture)12 Optional (java.util.Optional)11 List (java.util.List)10 Collectors (java.util.stream.Collectors)10 URL (java.net.URL)9 EnodeURLImpl (org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl)9 DisconnectReason (org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.DisconnectReason)9 File (java.io.File)8 Collections (java.util.Collections)8 LocalPermissioningConfiguration (org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration)8 ArrayList (java.util.ArrayList)7 EthNetworkConfig (org.hyperledger.besu.cli.config.EthNetworkConfig)7