Author: toad
Date: 2008-02-09 15:09:04 +0000 (Sat, 09 Feb 2008)
New Revision: 17759

Modified:
   trunk/freenet/src/freenet/node/simulator/RealNodeTest.java
   trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java
Log:
Use it here too

Modified: trunk/freenet/src/freenet/node/simulator/RealNodeTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeTest.java  2008-02-09 
15:04:46 UTC (rev 17758)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeTest.java  2008-02-09 
15:09:04 UTC (rev 17759)
@@ -93,5 +93,29 @@
                return Integer.toString(n.getDarknetPortNumber());
        }

-       
+    // FIXME factor out to some simulator utility class.
+       static void waitForAllConnected(Node[] nodes) throws 
InterruptedException {
+               while(true) {
+                       int countFullyConnected = 0;
+                       int totalPeers = 0;
+                       int totalConnections = 0;
+                       for(int i=0;i<nodes.length;i++) {
+                               int countConnected = 
nodes[i].peers.countConnectedDarknetPeers();
+                               int countTotal = 
nodes[i].peers.countValidPeers();
+                               totalPeers += countTotal;
+                               totalConnections += countConnected;
+                               if(countConnected == countTotal)
+                                       countFullyConnected++;
+                       }
+                       if(countFullyConnected == nodes.length) {
+                               System.err.println("All nodes fully connected");
+                               System.err.println();
+                               return;
+                       } else {
+                               System.err.println("Waiting for nodes to be 
fully connected: "+countFullyConnected+" / "+nodes.length+" 
("+totalConnections+" / "+totalPeers+" connections total)");
+                               Thread.sleep(1000);
+                       }
+               }
+       }
+
 }

Modified: trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java      
2008-02-09 15:04:46 UTC (rev 17758)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java      
2008-02-09 15:09:04 UTC (rev 17759)
@@ -43,7 +43,7 @@
  * This should be transformed into a Heavy Unit Test.
  * @author toad
  */
-public class RealNodeULPRTest {
+public class RealNodeULPRTest extends RealNodeTest {

        // Exit codes
        static final int EXIT_BASE = NodeInitException.EXIT_NODE_UPPER_LIMIT;
@@ -223,30 +223,5 @@
         System.exit(0);
     }

-    // FIXME factor out to some simulator utility class.
-       private static void waitForAllConnected(Node[] nodes) throws 
InterruptedException {
-               while(true) {
-                       int countFullyConnected = 0;
-                       int totalPeers = 0;
-                       int totalConnections = 0;
-                       for(int i=0;i<nodes.length;i++) {
-                               int countConnected = 
nodes[i].peers.countConnectedDarknetPeers();
-                               int countTotal = 
nodes[i].peers.countValidPeers();
-                               totalPeers += countTotal;
-                               totalConnections += countConnected;
-                               if(countConnected == countTotal)
-                                       countFullyConnected++;
-                       }
-                       if(countFullyConnected == nodes.length) {
-                               System.err.println("All nodes fully connected");
-                               System.err.println();
-                               return;
-                       } else {
-                               System.err.println("Waiting for nodes to be 
fully connected: "+countFullyConnected+" / "+nodes.length+" 
("+totalConnections+" / "+totalPeers+" connections total)");
-                               Thread.sleep(1000);
-                       }
-               }
-       }

-
 }


Reply via email to