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()));
}
Aggregations