use of org.aion.p2p.INode in project aion by aionnetwork.
the class NodeMgrTest method testTempNode.
@Test(timeout = 10_000)
public void testTempNode() {
nMgr.addTempNode(node);
assertEquals(1, nMgr.tempNodesSize());
nMgr.addTempNode(node);
assertEquals(1, nMgr.tempNodesSize());
String nl = "p2p://" + nodeId1 + "@" + ip1 + ":" + port1;
INode node = Node.parseP2p(nl);
nMgr.addTempNode(node);
assertEquals(2, nMgr.tempNodesSize());
}
use of org.aion.p2p.INode in project aion by aionnetwork.
the class NodeMgrTest method testMoveSelfToActive.
@Test
public void testMoveSelfToActive() {
INode node = nMgr.allocNode(ip2, 1);
addNodetoOutbound(node, UUID.fromString(nodeId1));
when(p2p.isSelf(node)).thenReturn(true);
nMgr.movePeerToActive(node.getIdHash(), "outbound");
assertTrue(nMgr.getActiveNodesMap().isEmpty());
}
use of org.aion.p2p.INode in project aion by aionnetwork.
the class NodeMgrTest method testNotAtOutBoundList.
@Test(timeout = 30_000)
public void testNotAtOutBoundList() {
INode node = nMgr.allocNode(ip2, 1);
addNodetoOutbound(node, UUID.fromString(nodeId1));
assertFalse(nMgr.notAtOutboundList(node.getIdHash()));
node = nMgr.allocNode(ip1, 1);
assertTrue(nMgr.notAtOutboundList(node.getIdHash()));
}
use of org.aion.p2p.INode in project aion by aionnetwork.
the class NodeMgrTest method testTimeoutActive.
@Test
public void testTimeoutActive() {
INode node = nMgr.allocNode(ip2, 1);
addNodetoInbound(node, UUID.fromString(nodeId1));
nMgr.movePeerToActive(node.getChannel().hashCode(), "inbound");
INode activeNode = nMgr.getActiveNode(node.getIdHash());
assertNotNull(activeNode);
assertEquals(node, activeNode);
nMgr.timeoutCheck(System.currentTimeMillis() + NodeMgr.MIN_TIMEOUT_ACTIVE_NODES + 1);
assertNull(nMgr.getActiveNode(node.getIdHash()));
}
use of org.aion.p2p.INode in project aion by aionnetwork.
the class NodeMgrTest method testAddInOutBoundNode.
@Test(timeout = 30_000)
public void testAddInOutBoundNode() {
INode node = nMgr.allocNode(ip1, 1);
node.setChannel(channel);
node.setId(nodeId1.getBytes(StandardCharsets.UTF_8));
nMgr.addInboundNode(node);
INode iNode = nMgr.getInboundNode(channel.hashCode());
assertEquals(ip1, iNode.getIpStr());
nMgr.addOutboundNode(node);
INode oNode = nMgr.getOutboundNode(node.getIdHash());
assertEquals(ip1, oNode.getIpStr());
}
Aggregations