Search in sources :

Example 46 with INode

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());
}
Also used : INode(org.aion.p2p.INode) Test(org.junit.Test)

Example 47 with INode

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());
}
Also used : INode(org.aion.p2p.INode) Test(org.junit.Test)

Example 48 with INode

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()));
}
Also used : INode(org.aion.p2p.INode) Test(org.junit.Test)

Example 49 with INode

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()));
}
Also used : INode(org.aion.p2p.INode) Test(org.junit.Test)

Example 50 with INode

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());
}
Also used : INode(org.aion.p2p.INode) Test(org.junit.Test)

Aggregations

INode (org.aion.p2p.INode)55 Test (org.junit.Test)30 BigInteger (java.math.BigInteger)11 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 Map (java.util.Map)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 ECKey (org.aion.crypto.ECKey)4 IP2pMgr (org.aion.p2p.IP2pMgr)4 Msg (org.aion.p2p.Msg)4 NetworkBestBlockCallback (org.aion.zero.impl.blockchain.AionImpl.NetworkBestBlockCallback)4 PendingTxCallback (org.aion.zero.impl.blockchain.AionImpl.PendingTxCallback)4 TransactionBroadcastCallback (org.aion.zero.impl.blockchain.AionImpl.TransactionBroadcastCallback)4 StandaloneBlockchain (org.aion.zero.impl.blockchain.StandaloneBlockchain)4 AionPendingStateImpl (org.aion.zero.impl.pendingState.AionPendingStateImpl)4 BlockHeader (org.aion.zero.impl.types.BlockHeader)4 IOException (java.io.IOException)3 ByteBuffer (java.nio.ByteBuffer)3 SelectionKey (java.nio.channels.SelectionKey)3 ServerSocketChannel (java.nio.channels.ServerSocketChannel)3