internal static void ManyNodes(out RoutingTable routingTable, out List<NodeId> nodes) { // Generate our local id byte[] id = new byte[20]; id[19] = 7; nodes = new List<NodeId>(); RoutingTable table = new RoutingTable(new Node(new NodeId(id), new IPEndPoint(IPAddress.Any, 0))); for (int i = 0; i <= 30; i++) { if (i == 7) continue; id = new byte[20]; id[19] = (byte)i; nodes.Add(new NodeId(id)); table.Add(new Node(new NodeId(id), new IPEndPoint(IPAddress.Any, 0))); } nodes.Sort(delegate(NodeId left, NodeId right) { NodeId dLeft = left.Xor(table.LocalNode.Id); NodeId dRight = right.Xor(table.LocalNode.Id); return dLeft.CompareTo(dRight); }); nodes.RemoveAll(delegate(NodeId n) { return table.FindNode(n) == null; }); routingTable = table; }
public void Setup() { _id = new byte[20]; _id[1] = 128; _node = new Node(new NodeId(_id), new IPEndPoint(IPAddress.Any, 0)); _table = new RoutingTable(_node); _table.NodeAdded += delegate { _addedCount++; }; _table.Add(_node); //the local node is no more in routing table so add it to show test is still ok _addedCount = 0; }
public void Setup() { id = new byte[20]; id[1] = 128; n = new Node(new NodeId(id), new System.Net.IPEndPoint(IPAddress.Any, 0)); table = new RoutingTable(n); table.NodeAdded += delegate { addedCount++; }; table.Add(n);//the local node is no more in routing table so add it to show test is still ok addedCount = 0; }