commit e75d41608d0cec23a4d1240d59f3fb5e2ea593d5
Author: Isis Lovecruft <i...@torproject.org>
Date:   Sun Apr 19 05:31:13 2015 +0000

    Rewrite testBasicDist() in legacy_Tests.
---
 lib/bridgedb/test/legacy_Tests.py |    8 --------
 lib/bridgedb/test/test_Dist.py    |   15 +++++++++++++++
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/lib/bridgedb/test/legacy_Tests.py 
b/lib/bridgedb/test/legacy_Tests.py
index c495412..fd6a739 100644
--- a/lib/bridgedb/test/legacy_Tests.py
+++ b/lib/bridgedb/test/legacy_Tests.py
@@ -185,14 +185,6 @@ class EmailBridgeDistTests(unittest.TestCase):
 
 class IPBridgeDistTests(unittest.TestCase):
 
-    def testBasicDist(self):
-        d = bridgedb.Dist.HTTPSDistributor(3, "Foo")
-        for _ in xrange(256):
-            d.insert(fakeBridge())
-        n = d.getBridges("1.2.3.4", "x")
-        n2 = d.getBridges("1.2.3.4", "x")
-        self.assertEquals(n, n2)
-
     def testDistWithProxies(self):
         d = bridgedb.Dist.HTTPSDistributor(3, "Foo", [RhymesWith255ProxySet()])
         for _ in xrange(256):
diff --git a/lib/bridgedb/test/test_Dist.py b/lib/bridgedb/test/test_Dist.py
index bc437ba..23a6492 100644
--- a/lib/bridgedb/test/test_Dist.py
+++ b/lib/bridgedb/test/test_Dist.py
@@ -243,6 +243,21 @@ class HTTPSDistributorTests(unittest.TestCase):
                 self.assertNotIn(b.fingerprint, blockedIR)
             self.assertGreater(len(bridges), 0)
 
+    def test_HTTPSDistributor_getBridges_same_bridges_to_same_client(self):
+        """The same client asking for bridges from the HTTPSDistributor
+        multiple times in a row should get the same bridges in response each
+        time.
+        """
+        dist = Dist.HTTPSDistributor(3, self.key)
+        [dist.insert(bridge) for bridge in self.bridges[:250]]
+
+        bridgeRequest = self.randomClientRequest()
+        responses = {}
+        for i in range(5):
+            responses[i] = dist.getBridges(bridgeRequest, 1)
+        for i in range(4):
+            self.assertItemsEqual(responses[i], responses[i+1])
+
     def test_HTTPSDistributor_getBridges_ipv4_ipv6(self):
         """Asking for bridge addresses which are simultaneously IPv4 and IPv6
         (in that order) should return IPv4 bridges.



_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to