[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r15147: try harder to keep bridges distinct. (bridgedb/trunk/lib/bridgedb)



Author: nickm
Date: 2008-06-11 18:42:16 -0400 (Wed, 11 Jun 2008)
New Revision: 15147

Modified:
   bridgedb/trunk/lib/bridgedb/Bridges.py
   bridgedb/trunk/lib/bridgedb/Tests.py
Log:
try harder to keep bridges distinct.

Modified: bridgedb/trunk/lib/bridgedb/Bridges.py
===================================================================
--- bridgedb/trunk/lib/bridgedb/Bridges.py	2008-06-11 22:36:20 UTC (rev 15146)
+++ bridgedb/trunk/lib/bridgedb/Bridges.py	2008-06-11 22:42:16 UTC (rev 15147)
@@ -315,7 +315,7 @@
 
         keys = forced[:]
         for k in self._getBridgeKeysAt(pos, N):
-            if k not in forced:
+            if k not in keys:
                 keys.append(k)
         keys = keys[:N]
         keys.sort()

Modified: bridgedb/trunk/lib/bridgedb/Tests.py
===================================================================
--- bridgedb/trunk/lib/bridgedb/Tests.py	2008-06-11 22:36:20 UTC (rev 15146)
+++ bridgedb/trunk/lib/bridgedb/Tests.py	2008-06-11 22:42:16 UTC (rev 15147)
@@ -69,13 +69,17 @@
             d.insert(fakeBridge(443))
         for _ in range(256):
             d.insert(fakeBridge())
-        for _ in xrange(16):
+        for _ in xrange(32):
             i = randomIP()
-            n = d.getBridgesForIP(i, "x", 2)
+            n = d.getBridgesForIP(i, "x", 5)
             count = 0
+            fps = {}
             for b in n:
+                fps[b.getID()] = 1
                 if b.orport == 443:
                     count += 1
+            self.assertEquals(len(fps), len(n))
+            self.assertEquals(len(fps), 5)
             self.assertTrue(count >= 1)
 
 def testSuite():