Search in sources :

Example 26 with Node

use of org.ethereum.net.rlpx.Node in project rskj by rsksmart.

the class NodeManagerTest method getNodesPeerDiscoveryEnable.

@Test
public void getNodesPeerDiscoveryEnable() {
    List<Node> activePeers = new ArrayList<>();
    activePeers.add(new Node(Hex.decode(NODE_ID_2), "127.0.0.2", 8081));
    List<Node> bootNodes = new ArrayList<>();
    bootNodes.add(new Node(Hex.decode(NODE_ID_3), "127.0.0.3", 8083));
    Mockito.when(config.peerActive()).thenReturn(activePeers);
    Mockito.when(peerExplorer.getNodes()).thenReturn(bootNodes);
    Mockito.when(config.isPeerDiscoveryEnabled()).thenReturn(true);
    nodeManager.init();
    Set<String> nodesInUse = new HashSet<>();
    List<NodeHandler> availableNodes = nodeManager.getNodes(nodesInUse);
    Assert.assertEquals(2, availableNodes.size());
}
Also used : Node(org.ethereum.net.rlpx.Node) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Node (org.ethereum.net.rlpx.Node)26 Test (org.junit.Test)16 NodeDistanceTable (co.rsk.net.discovery.table.NodeDistanceTable)11 ECKey (org.ethereum.crypto.ECKey)11 ArrayList (java.util.ArrayList)9 InetSocketAddress (java.net.InetSocketAddress)8 Channel (io.netty.channel.Channel)6 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)5 NodeID (co.rsk.net.NodeID)3 OperationResult (co.rsk.net.discovery.table.OperationResult)2 SecureRandom (java.security.SecureRandom)2 HashSet (java.util.HashSet)2 PeerExplorer (co.rsk.net.discovery.PeerExplorer)1 co.rsk.net.discovery.message (co.rsk.net.discovery.message)1 PeerDiscoveryRequestBuilder (co.rsk.net.discovery.table.PeerDiscoveryRequestBuilder)1 IpUtils (co.rsk.util.IpUtils)1 java.util (java.util)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Lock (java.util.concurrent.locks.Lock)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1