-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into #17-substreams
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/test/java/com/limechain/network/kad/KademliaServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.limechain.network.kad; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
|
||
import static com.limechain.network.kad.KademliaService.dnsNodeToIp4; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class KademliaServiceTest { | ||
|
||
/** | ||
* Test might throw UnknownHostException and fail if domain is no longer accessible | ||
* | ||
* @throws UnknownHostException | ||
*/ | ||
@Test | ||
public void dnsNodeToIp4_TransformDnsNode() throws UnknownHostException { | ||
//CHECKSTYLE.OFF | ||
String bootNode = "/dns/p2p.0.polkadot.network/tcp/30333/p2p/12D3KooWHsvEicXjWWraktbZ4MQBizuyADQtuEGr3NbDvtm5rFA5"; | ||
InetAddress address = InetAddress.getByName("p2p.0.polkadot.network"); | ||
String expected = "/ip4/" + address.getHostAddress() + "/tcp/30333/p2p/12D3KooWHsvEicXjWWraktbZ4MQBizuyADQtuEGr3NbDvtm5rFA5"; | ||
//CHECKSTYLE.ON | ||
|
||
assertEquals(expected, dnsNodeToIp4(bootNode)); | ||
} | ||
|
||
@Test | ||
public void dnsNodeToIp4_UnchangedAddress_ifInvalidDomain() { | ||
String bootNode2 = "/dns/invalid.domain.limechain/tcp/12345"; | ||
|
||
assertEquals(bootNode2, dnsNodeToIp4(bootNode2)); | ||
} | ||
|
||
@Test | ||
public void dnsNodeToIp4_UnchangedAddress_IfNotDns() { | ||
String bootNode3 = "/ip4/192.168.1.1/tcp/12345"; | ||
|
||
assertEquals(bootNode3, dnsNodeToIp4(bootNode3)); | ||
} | ||
} |