use of org.aion.p2p.INode in project aion by aionnetwork.
the class NodeMgrTest method testAllocate.
@Test(timeout = 30_000)
public void testAllocate() {
INode node = nMgr.allocNode(ip2, 1);
assertNotNull(node);
assertFalse(node.getIfFromBootList());
nMgr.seedIpAdd(ip2);
node = nMgr.allocNode(ip2, 1);
assertNotNull(node);
assertTrue(node.getIfFromBootList());
}
use of org.aion.p2p.INode in project aion by aionnetwork.
the class NodeMgrTest method testTimeoutInbound.
@Test
public void testTimeoutInbound() {
INode node = nMgr.allocNode(ip2, 1);
addNodetoInbound(node, UUID.fromString(nodeId1));
nMgr.timeoutCheck(System.currentTimeMillis() + NodeMgr.TIMEOUT_INBOUND_NODES + 1);
assertNull(nMgr.getInboundNode(channel.hashCode()));
}
use of org.aion.p2p.INode in project aion by aionnetwork.
the class NodeMgrTest method testBan.
@Test(timeout = 30_000)
public void testBan() {
INode node = nMgr.allocNode(ip2, 1);
node.setChannel(channel);
node.setId(nodeId2.getBytes(StandardCharsets.UTF_8));
nMgr.addInboundNode(node);
assertEquals(0, nMgr.activeNodesSize());
nMgr.movePeerToActive(channel.hashCode(), "inbound");
assertEquals(1, nMgr.activeNodesSize());
assertTrue(node.getPeerMetric().notBan());
nMgr.ban(node.getIdHash());
assertFalse(node.getPeerMetric().notBan());
}
use of org.aion.p2p.INode in project aion by aionnetwork.
the class NodeMgrTest method testShutDown.
@Test(timeout = 30_000)
public void testShutDown() {
INode node = nMgr.allocNode(ip2, 1);
addNodetoOutbound(node, UUID.randomUUID());
node = nMgr.allocNode(ip1, 1);
addNodetoOutbound(node, UUID.randomUUID());
nMgr.movePeerToActive(node.getIdHash(), "outbound");
node = nMgr.allocNode("1.1.1.1", 1);
addNodetoInbound(node, UUID.randomUUID());
assertEquals(1, nMgr.activeNodesSize());
nMgr.shutdown();
assertTrue(nMgr.getActiveNodesMap().isEmpty());
}
use of org.aion.p2p.INode in project aion by aionnetwork.
the class NodeMgrTest method testMovePeerToActiveFromInbound.
@Test
public void testMovePeerToActiveFromInbound() {
INode node = nMgr.allocNode(ip2, 1);
node.setChannel(channel);
nMgr.movePeerToActive(node.getChannel().hashCode(), "inbound");
assertTrue(nMgr.getActiveNodesMap().isEmpty());
nMgr.addInboundNode(node);
// wrong type & key
nMgr.movePeerToActive(node.getChannel().hashCode(), "outbound");
assertTrue(nMgr.getActiveNodesMap().isEmpty());
// move from inbound
nMgr.movePeerToActive(node.getChannel().hashCode(), "inbound");
assertEquals(1, nMgr.getActiveNodesMap().size());
// move same node again
nMgr.movePeerToActive(node.getChannel().hashCode(), "inbound");
assertEquals(1, nMgr.getActiveNodesMap().size());
}
Aggregations