Search in sources :

Example 1 with NodeManager

use of org.ethereum.net.NodeManager in project rskj by rsksmart.

the class ChannelManagerImplTest method blockAddressIsNotAvailable.

@Test
public void blockAddressIsNotAvailable() {
    TestSystemProperties config = mock(TestSystemProperties.class);
    when(config.maxConnectionsAllowed()).thenReturn(1);
    when(config.networkCIDR()).thenReturn(32);
    SyncPool syncPool = mock(SyncPool.class);
    ChannelManagerImpl channelManager = new ChannelManagerImpl(config, syncPool);
    String remoteId = "remoteId";
    NodeManager nodeManager = new NodeManager(null, config);
    Channel peer = spy(new Channel(null, null, nodeManager, null, null, null, remoteId));
    peer.setInetSocketAddress(new InetSocketAddress("127.0.0.1", 5554));
    peer.setNode(new NodeID(HashUtil.randomPeerId()).getID());
    when(peer.isProtocolsInitialized()).thenReturn(true);
    when(peer.isActive()).thenReturn(true);
    when(peer.isUsingNewProtocol()).thenReturn(true);
    Channel otherPeer = new Channel(null, null, nodeManager, null, null, null, remoteId);
    otherPeer.setInetSocketAddress(new InetSocketAddress("127.0.0.1", 5554));
    channelManager.add(peer);
    channelManager.tryProcessNewPeers();
    Assert.assertFalse(channelManager.isAddressBlockAvailable(otherPeer.getInetSocketAddress().getAddress()));
}
Also used : NodeManager(org.ethereum.net.NodeManager) SyncPool(org.ethereum.sync.SyncPool) InetSocketAddress(java.net.InetSocketAddress) NodeID(co.rsk.net.NodeID) TestSystemProperties(co.rsk.config.TestSystemProperties) Test(org.junit.Test)

Aggregations

TestSystemProperties (co.rsk.config.TestSystemProperties)1 NodeID (co.rsk.net.NodeID)1 InetSocketAddress (java.net.InetSocketAddress)1 NodeManager (org.ethereum.net.NodeManager)1 SyncPool (org.ethereum.sync.SyncPool)1 Test (org.junit.Test)1