[bridgedb/develop] Remove most "splitter"s — they're just crappy consistent hashrings.

isis at torproject.org isis at torproject.org
Thu Jun 25 07:10:54 UTC 2015


commit d83438d24104c5834cd0230a757b17a8e1941edb
Author: Isis Lovecruft <isis at torproject.org>
Date:   Tue Apr 14 09:23:40 2015 +0000

    Remove most "splitter"s — they're just crappy consistent hashrings.
---
 lib/bridgedb/Bridges.py           |    2 +-
 lib/bridgedb/Dist.py              |   60 ++++++++++++++--------------
 lib/bridgedb/Main.py              |   66 +++++++++++++++---------------
 lib/bridgedb/test/legacy_Tests.py |    4 +-
 lib/bridgedb/test/test_Main.py    |   80 ++++++++++++++++++-------------------
 lib/bridgedb/test/test_bridges.py |   24 +++++------
 6 files changed, 118 insertions(+), 118 deletions(-)

diff --git a/lib/bridgedb/Bridges.py b/lib/bridgedb/Bridges.py
index c727c9a..b06ffc4 100644
--- a/lib/bridgedb/Bridges.py
+++ b/lib/bridgedb/Bridges.py
@@ -569,7 +569,7 @@ class FilteredBridgeSplitter(BridgeHolder):
             return
 
         index = 0
-        logging.debug("Inserting %s into splitter"
+        logging.debug("Inserting %s into hashring"
                       % (logSafely(bridge.fingerprint)))
         for old_bridge in self.bridges[:]:
             if bridge.fingerprint == old_bridge.fingerprint:
diff --git a/lib/bridgedb/Dist.py b/lib/bridgedb/Dist.py
index 445d2d8..44cb526 100644
--- a/lib/bridgedb/Dist.py
+++ b/lib/bridgedb/Dist.py
@@ -81,14 +81,14 @@ class Distributor(object):
         >>> ipDist = Dist.IPBasedDistributor(5, 'fake-hmac-key')
         >>> ipDist.setDistributorName('HTTPS Distributor')
         >>> ipDist.prepopulateRings()
-        >>> hashrings = ipDist.splitter.filterRings
+        >>> hashrings = ipDist.hashring.filterRings
         >>> firstSubring = hashrings.items()[0][1][1]
         >>> assert firstSubring.name
 
         :param str name: A name for this distributor.
         """
         self.name = name
-        self.splitter.distributorName = name
+        self.hashring.distributorName = name
 
 
 class IPBasedDistributor(Distributor):
@@ -98,8 +98,8 @@ class IPBasedDistributor(Distributor):
     :type proxies: :class:`~bridgedb.proxies.ProxySet`
     :ivar proxies: All known proxies, which we treat differently. See
         :param:`proxies`.
-    :type splitter: :class:`bridgedb.Bridges.FixedBridgeSplitter`
-    :ivar splitter: A hashring that assigns bridges to subrings with fixed
+    :type hashring: :class:`bridgedb.Bridges.FixedBridgeSplitter`
+    :ivar hashring: A hashring that assigns bridges to subrings with fixed
         proportions. Used to assign bridges into the subrings of this
         distributor.
     """
@@ -150,9 +150,9 @@ class IPBasedDistributor(Distributor):
 
         self._clientToPositionHMAC = getHMACFunc(key3, hex=False)
         self._subnetToSubringHMAC = getHMACFunc(key4, hex=True)
-        self.splitter = FilteredBridgeSplitter(key2, self.ringCacheSize)
+        self.hashring = FilteredBridgeSplitter(key2, self.ringCacheSize)
         logging.debug("Added %s to HTTPS distributor." %
-                      self.splitter.__class__.__name__)
+                      self.hashring.__class__.__name__)
 
         self.setDistributorName('HTTPS')
 
@@ -311,16 +311,16 @@ class IPBasedDistributor(Distributor):
                 # distributor's proxies:
                 if subring == self.proxySubring:
                     ring.setName('{0} Proxy Ring'.format(self.name))
-                self.splitter.addRing(ring, filters,
+                self.hashring.addRing(ring, filters,
                                       filterBridgesByRules(filters),
-                                      populate_from=self.splitter.bridges)
+                                      populate_from=self.hashring.bridges)
 
     def insert(self, bridge):
         """Assign a bridge to this distributor."""
-        self.splitter.insert(bridge)
+        self.hashring.insert(bridge)
 
     def _buildHashringFilters(self, previousFilters, subring):
-        f = filterAssignBridgesToRing(self.splitter.hmac, self.totalSubrings, subring)
+        f = filterAssignBridgesToRing(self.hashring.hmac, self.totalSubrings, subring)
         previousFilters.append(f)
         return frozenset(previousFilters)
 
@@ -343,8 +343,8 @@ class IPBasedDistributor(Distributor):
         logging.info("Attempting to return %d bridges to client %s..."
                      % (N, bridgeRequest.client))
 
-        if not len(self.splitter):
-            logging.warn("Bailing! Splitter has zero bridges!")
+        if not len(self.hashring):
+            logging.warn("Bailing! Hashring has zero bridges!")
             return []
 
         usingProxy = False
@@ -373,16 +373,16 @@ class IPBasedDistributor(Distributor):
         logging.debug("Bridge filters: %s" % ' '.join([x.func_name for x in filters]))
 
         # Check wheth we have a cached copy of the hashring:
-        if filters in self.splitter.filterRings.keys():
+        if filters in self.hashring.filterRings.keys():
             logging.debug("Cache hit %s" % filters)
-            _, ring = self.splitter.filterRings[filters]
+            _, ring = self.hashring.filterRings[filters]
         # Otherwise, construct a new hashring and populate it:
         else:
             logging.debug("Cache miss %s" % filters)
             key1 = getHMAC(self.key, "Order-Bridges-In-Ring-%d" % subring)
             ring = bridgedb.Bridges.BridgeRing(key1, self.answerParameters)
-            self.splitter.addRing(ring, filters, filterBridgesByRules(filters),
-                                  populate_from=self.splitter.bridges)
+            self.hashring.addRing(ring, filters, filterBridgesByRules(filters),
+                                  populate_from=self.hashring.bridges)
 
         # Determine the appropriate number of bridges to give to the client:
         returnNum = getNumBridgesPerAnswer(ring, max_bridges_per_answer=N)
@@ -391,18 +391,18 @@ class IPBasedDistributor(Distributor):
         return answer
 
     def __len__(self):
-        return len(self.splitter)
+        return len(self.hashring)
 
     def dumpAssignments(self, f, description=""):
-        self.splitter.dumpAssignments(f, description)
+        self.hashring.dumpAssignments(f, description)
 
 
 class EmailBasedDistributor(Distributor):
     """Object that hands out bridges based on the email address of an incoming
     request and the current time period.
 
-    :type splitter: :class:`~bridgedb.Bridges.BridgeRing`
-    :ivar splitter: A hashring to hold all the bridges we hand out.
+    :type hashring: :class:`~bridgedb.Bridges.BridgeRing`
+    :ivar hashring: A hashring to hold all the bridges we hand out.
     """
 
     def __init__(self, key, domainmap, domainrules,
@@ -434,14 +434,14 @@ class EmailBasedDistributor(Distributor):
         self.answerParameters = answerParameters
 
         #XXX cache options not implemented
-        self.splitter = bridgedb.Bridges.FilteredBridgeSplitter(
+        self.hashring = bridgedb.Bridges.FilteredBridgeSplitter(
             key2, max_cached_rings=5)
 
         self.setDistributorName('Email')
 
     def insert(self, bridge):
         """Assign a bridge to this distributor."""
-        self.splitter.insert(bridge)
+        self.hashring.insert(bridge)
 
     def getBridges(self, bridgeRequest, interval, N=1):
         """Return a list of bridges to give to a user.
@@ -500,9 +500,9 @@ class EmailBasedDistributor(Distributor):
 
             ring = None
             ruleset = frozenset(bridgeRequest.filters)
-            if ruleset in self.splitter.filterRings.keys():
+            if ruleset in self.hashring.filterRings.keys():
                 logging.debug("Cache hit %s" % ruleset)
-                _, ring = self.splitter.filterRings[ruleset]
+                _, ring = self.hashring.filterRings[ruleset]
             else:
                 # cache miss, add new ring
                 logging.debug("Cache miss %s" % ruleset)
@@ -510,9 +510,9 @@ class EmailBasedDistributor(Distributor):
                 # add new ring
                 key1 = getHMAC(self.key, "Order-Bridges-In-Ring")
                 ring = bridgedb.Bridges.BridgeRing(key1, self.answerParameters)
-                self.splitter.addRing(ring, ruleset,
+                self.hashring.addRing(ring, ruleset,
                                       filterBridgesByRules(ruleset),
-                                      populate_from=self.splitter.bridges)
+                                      populate_from=self.hashring.bridges)
 
             numBridgesToReturn = getNumBridgesPerAnswer(ring,
                                                         max_bridges_per_answer=N)
@@ -524,7 +524,7 @@ class EmailBasedDistributor(Distributor):
         return result
 
     def __len__(self):
-        return len(self.splitter)
+        return len(self.hashring)
 
     def cleanDatabase(self):
         with bridgedb.Storage.getDB() as db:
@@ -538,7 +538,7 @@ class EmailBasedDistributor(Distributor):
                 db.commit()
 
     def dumpAssignments(self, f, description=""):
-        self.splitter.dumpAssignments(f, description)
+        self.hashring.dumpAssignments(f, description)
 
     def prepopulateRings(self):
         # populate all rings (for dumping assignments and testing)
@@ -546,6 +546,6 @@ class EmailBasedDistributor(Distributor):
             ruleset = frozenset([filterFn])
             key1 = getHMAC(self.key, "Order-Bridges-In-Ring")
             ring = bridgedb.Bridges.BridgeRing(key1, self.answerParameters)
-            self.splitter.addRing(ring, ruleset,
+            self.hashring.addRing(ring, ruleset,
                                   filterBridgesByRules([filterFn]),
-                                  populate_from=self.splitter.bridges)
+                                  populate_from=self.hashring.bridges)
diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index d2fd2da..53189fd 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -39,19 +39,19 @@ from bridgedb import Dist
 from bridgedb.Stability import updateBridgeHistory
 
 
-def load(state, splitter, clear=False):
-    """Read and parse all descriptors, and load into a bridge splitter.
+def load(state, hashring, clear=False):
+    """Read and parse all descriptors, and load into a bridge hashring.
 
     Read all the appropriate bridge files from the saved
     :class:`~bridgedb.persistent.State`, parse and validate them, and then
-    store them into our ``state.splitter`` instance. The ``state`` will be
+    store them into our ``state.hashring`` instance. The ``state`` will be
     saved again at the end of this function.
 
-    :type splitter: :class:`BridgeSplitter <bridgedb.Bridges.BridgeHolder>`
-    :param splitter: A class which provides a mechanism for HMACing
+    :type hashring: :class:`BridgeSplitter <bridgedb.Bridges.BridgeHolder>`
+    :param hashring: A class which provides a mechanism for HMACing
         Bridges in order to assign them to hashrings.
     :param boolean clear: If True, clear all previous bridges from the
-        splitter before parsing for new ones.
+        hashring before parsing for new ones.
     """
     if not state:
         logging.fatal("bridgedb.Main.load() could not retrieve state!")
@@ -59,7 +59,7 @@ def load(state, splitter, clear=False):
 
     if clear:
         logging.info("Clearing old bridges...")
-        splitter.clear()
+        hashring.clear()
 
     logging.info("Loading bridges...")
 
@@ -137,7 +137,7 @@ def load(state, splitter, clear=False):
                          % router.fingerprint)
 
     inserted = 0
-    logging.info("Inserting %d bridges into splitter..." % len(bridges))
+    logging.info("Inserting %d bridges into hashring..." % len(bridges))
     for fingerprint, bridge in bridges.items():
         # Skip insertion of bridges which are geolocated to be in one of the
         # NO_DISTRIBUTION_COUNTRIES, a.k.a. the countries we don't distribute
@@ -148,9 +148,9 @@ def load(state, splitter, clear=False):
         else:
             # If the bridge is not running, then it is skipped during the
             # insertion process.
-            splitter.insert(bridge)
+            hashring.insert(bridge)
             inserted += 1
-    logging.info("Done inserting %d bridges into splitter." % inserted)
+    logging.info("Done inserting %d bridges into hashring." % inserted)
 
     if state.COLLECT_TIMESTAMPS:
         reactor.callInThread(updateBridgeHistory, bridges, timestamps)
@@ -180,7 +180,7 @@ def _handleSIGUSR1(*args):
 
 def replaceBridgeRings(current, replacement):
     """Replace the current thing with the new one"""
-    current.splitter = replacement.splitter
+    current.hashring = replacement.hashring
 
 def createBridgeRings(cfg, proxyList, key):
     """Create the bridge distributors defined by the config file
@@ -192,15 +192,15 @@ def createBridgeRings(cfg, proxyList, key):
     :type proxyList: :class:`~bridgedb.proxy.ProxySet`
     :param proxyList: The container for the IP addresses of any currently
                       known open proxies.
-    :param bytes key: Splitter master key
+    :param bytes key: Hashring master key
     :rtype: tuple
-    :returns: A BridgeSplitter splitter, an IPBasedDistributor or None,
+    :returns: A BridgeSplitter hashring, an IPBasedDistributor or None,
               and an EmailBasedDistributor or None.
     """
     # Create a BridgeSplitter to assign the bridges to the different
     # distributors.
-    splitter = Bridges.BridgeSplitter(crypto.getHMAC(key, "Splitter-Key"))
-    logging.debug("Created splitter: %r" % splitter)
+    hashring = Bridges.BridgeSplitter(crypto.getHMAC(key, "Hashring-Key"))
+    logging.debug("Created hashring: %r" % hashring)
 
     # Create ring parameters.
     ringParams = Bridges.BridgeRingParameters(needPorts=cfg.FORCE_PORTS,
@@ -215,7 +215,7 @@ def createBridgeRings(cfg, proxyList, key):
             crypto.getHMAC(key, "HTTPS-IP-Dist-Key"),
             proxyList,
             answerParameters=ringParams)
-        splitter.addRing(ipDistributor, "https", cfg.HTTPS_SHARE)
+        hashring.addRing(ipDistributor, "https", cfg.HTTPS_SHARE)
 
     # As appropriate, create an email-based distributor.
     if cfg.EMAIL_DIST and cfg.EMAIL_SHARE:
@@ -226,19 +226,19 @@ def createBridgeRings(cfg, proxyList, key):
             cfg.EMAIL_DOMAIN_RULES.copy(),
             answerParameters=ringParams,
             whitelist=cfg.EMAIL_WHITELIST.copy())
-        splitter.addRing(emailDistributor, "email", cfg.EMAIL_SHARE)
+        hashring.addRing(emailDistributor, "email", cfg.EMAIL_SHARE)
 
-    # As appropriate, tell the splitter to leave some bridges unallocated.
+    # As appropriate, tell the hashring to leave some bridges unallocated.
     if cfg.RESERVED_SHARE:
-        splitter.addRing(Bridges.UnallocatedHolder(),
+        hashring.addRing(Bridges.UnallocatedHolder(),
                          "unallocated",
                          cfg.RESERVED_SHARE)
 
-    # Add pseudo distributors to splitter
+    # Add pseudo distributors to hashring
     for pseudoRing in cfg.FILE_BUCKETS.keys():
-        splitter.addPseudoRing(pseudoRing)
+        hashring.addPseudoRing(pseudoRing)
 
-    return splitter, emailDistributor, ipDistributor
+    return hashring, emailDistributor, ipDistributor
 
 def run(options, reactor=reactor):
     """This is BridgeDB's main entry point and main runtime loop.
@@ -314,7 +314,7 @@ def run(options, reactor=reactor):
         State should be saved before calling this method, and will be saved
         again at the end of it.
 
-        The internal variables, ``cfg``, ``splitter``, ``proxyList``,
+        The internal variables, ``cfg``, ``hashring``, ``proxyList``,
         ``ipDistributor``, and ``emailDistributor`` are all taken from a
         :class:`~bridgedb.persistent.State` instance, which has been saved to
         a statefile with :meth:`bridgedb.persistent.State.save`.
@@ -323,8 +323,8 @@ def run(options, reactor=reactor):
         :ivar cfg: The current configuration, including any in-memory
             settings (i.e. settings whose values were not obtained from the
             config file, but were set via a function somewhere)
-        :type splitter: A :class:`bridgedb.Bridges.BridgeHolder`
-        :ivar splitter: A class which takes an HMAC key and splits bridges
+        :type hashring: A :class:`bridgedb.Bridges.BridgeHolder`
+        :ivar hashring: A class which takes an HMAC key and splits bridges
             into their hashring assignments.
         :type proxyList: :class:`~bridgedb.proxy.ProxySet`
         :ivar proxyList: The container for the IP addresses of any currently
@@ -357,21 +357,21 @@ def run(options, reactor=reactor):
             proxy.loadProxiesFromFile(proxyfile, state.proxies, removeStale=True)
 
         logging.info("Reparsing bridge descriptors...")
-        (splitter,
+        (hashring,
          emailDistributorTmp,
          ipDistributorTmp) = createBridgeRings(cfg, state.proxies, key)
-        logging.info("Bridges loaded: %d" % len(splitter))
+        logging.info("Bridges loaded: %d" % len(hashring))
 
         # Initialize our DB.
         bridgedb.Storage.initializeDBLock()
         bridgedb.Storage.setDBFilename(cfg.DB_FILE + ".sqlite")
-        load(state, splitter, clear=False)
+        load(state, hashring, clear=False)
 
         if emailDistributorTmp is not None:
             emailDistributorTmp.prepopulateRings() # create default rings
             logging.info("Bridges allotted for %s distribution: %d"
                          % (emailDistributorTmp.name,
-                            len(emailDistributorTmp.splitter)))
+                            len(emailDistributorTmp.hashring)))
         else:
             logging.warn("No email distributor created!")
 
@@ -380,15 +380,15 @@ def run(options, reactor=reactor):
 
             logging.info("Bridges allotted for %s distribution: %d"
                          % (ipDistributorTmp.name,
-                            len(ipDistributorTmp.splitter)))
+                            len(ipDistributorTmp.hashring)))
             logging.info("\tNum bridges:\tFilter set:")
 
             nSubrings  = 0
-            ipSubrings = ipDistributorTmp.splitter.filterRings
+            ipSubrings = ipDistributorTmp.hashring.filterRings
             for (ringname, (filterFn, subring)) in ipSubrings.items():
                 nSubrings += 1
                 filterSet = ' '.join(
-                    ipDistributorTmp.splitter.extractFilterNames(ringname))
+                    ipDistributorTmp.hashring.extractFilterNames(ringname))
                 logging.info("\t%2d bridges\t%s" % (len(subring), filterSet))
 
             logging.info("Total subrings for %s: %d"
@@ -403,7 +403,7 @@ def run(options, reactor=reactor):
             fh = open(state.ASSIGNMENTS_FILE, 'a')
             fh.write("bridge-pool-assignment %s\n" %
                      time.strftime("%Y-%m-%d %H:%M:%S"))
-            splitter.dumpAssignments(fh)
+            hashring.dumpAssignments(fh)
             fh.flush()
             fh.close()
         except IOError:
diff --git a/lib/bridgedb/test/legacy_Tests.py b/lib/bridgedb/test/legacy_Tests.py
index 7d7d236..dc91c9b 100644
--- a/lib/bridgedb/test/legacy_Tests.py
+++ b/lib/bridgedb/test/legacy_Tests.py
@@ -311,7 +311,7 @@ class IPBridgeDistTests(unittest.TestCase):
             d.insert(fakeBridge6(or_addresses=True))
             d.insert(fakeBridge(or_addresses=True))
 
-        for b in d.splitter.bridges:
+        for b in d.hashring.bridges:
             # china blocks all :-(
             for pt in b.transports:
                 key = "%s:%s" % (pt.address, pt.port)
@@ -337,7 +337,7 @@ class IPBridgeDistTests(unittest.TestCase):
             d.insert(fakeBridge6(or_addresses=True, transports=True))
             d.insert(fakeBridge(or_addresses=True, transports=True))
 
-        for b in d.splitter.bridges:
+        for b in d.hashring.bridges:
             # china blocks some transports
             for pt in b.transports:
                 if random.choice(xrange(2)) > 0:
diff --git a/lib/bridgedb/test/test_Main.py b/lib/bridgedb/test/test_Main.py
index 43e008c..ec3fdd2 100644
--- a/lib/bridgedb/test/test_Main.py
+++ b/lib/bridgedb/test/test_Main.py
@@ -111,18 +111,18 @@ class MainTests(unittest.TestCase):
         return updatedPaths
 
     def _cbAssertFingerprints(self, d):
-        """Assert that there are some bridges in the splitter."""
-        self.assertGreater(len(self.splitter), 0)
+        """Assert that there are some bridges in the hashring."""
+        self.assertGreater(len(self.hashring), 0)
         return d
 
-    def _cbCallUpdateBridgeHistory(self, d, splitter):
-        """Fake some timestamps for the bridges in the splitter, and then call
+    def _cbCallUpdateBridgeHistory(self, d, hashring):
+        """Fake some timestamps for the bridges in the hashring, and then call
         Main.updateBridgeHistory().
         """
         def timestamp():
             return datetime.fromtimestamp(random.randint(1324285117, 1524285117))
 
-        bridges = splitter._bridges
+        bridges = hashring._bridges
         timestamps = {}
 
         for fingerprint, _ in bridges.items():
@@ -171,7 +171,7 @@ class MainTests(unittest.TestCase):
         self.key = base64.b64decode('TvPS1y36BFguBmSOvhChgtXB2Lt+BOw0mGfz9SZe12Y=')
 
         # Create a BridgeSplitter
-        self.splitter = MockBridgeHolder()
+        self.hashring = MockBridgeHolder()
 
         # Functions which some tests mock, which we'll need to re-replace
         # later in tearDown():
@@ -193,30 +193,30 @@ class MainTests(unittest.TestCase):
         # access the database:
         Main.updateBridgeHistory = mockUpdateBridgeHistory
 
-        # Get the bridges into the mocked splitter
-        d = deferToThread(Main.load, self.state, self.splitter)
+        # Get the bridges into the mocked hashring
+        d = deferToThread(Main.load, self.state, self.hashring)
         d.addCallback(self._cbAssertFingerprints)
         d.addErrback(self._eb_Failure)
-        d.addCallback(self._cbCallUpdateBridgeHistory, self.splitter)
+        d.addCallback(self._cbCallUpdateBridgeHistory, self.hashring)
         d.addErrback(self._eb_Failure)
         return d
 
     def test_Main_load(self):
         """Main.load() should run without error."""
-        d = deferToThread(Main.load, self.state, self.splitter)
+        d = deferToThread(Main.load, self.state, self.hashring)
         d.addCallback(self._cbAssertFingerprints)
         d.addErrback(self._eb_Failure)
         return d
 
     def test_Main_load_no_state(self):
         """Main.load() should raise SystemExit without a state object."""
-        self.assertRaises(SystemExit, Main.load, None, self.splitter)
+        self.assertRaises(SystemExit, Main.load, None, self.hashring)
 
     def test_Main_load_clear(self):
         """When called with clear=True, load() should run and clear the
         hashrings.
         """
-        d = deferToThread(Main.load, self.state, self.splitter, clear=True)
+        d = deferToThread(Main.load, self.state, self.hashring, clear=True)
         d.addCallback(self._cbAssertFingerprints)
         d.addErrback(self._eb_Failure)
         return d
@@ -234,14 +234,14 @@ class MainTests(unittest.TestCase):
         # The reactor is deferring this to a thread, so the test execution
         # here isn't actually covering the Storage.updateBridgeHistory()
         # function:
-        Main.load(state, self.splitter)
+        Main.load(state, self.hashring)
 
     def test_Main_load_malformed_networkstatus(self):
         """When called with a networkstatus file with an invalid descriptor,
         Main.load() should raise a ValueError.
         """
         self._appendToFile(self.state.STATUS_FILE, NETWORKSTATUS_MALFORMED)
-        self.assertRaises(ValueError, Main.load, self.state, self.splitter)
+        self.assertRaises(ValueError, Main.load, self.state, self.hashring)
 
     def test_Main_reloadFn(self):
         """Main._reloadFn() should return True."""
@@ -255,79 +255,79 @@ class MainTests(unittest.TestCase):
 
     def test_Main_createBridgeRings(self):
         """Main.createBridgeRings() should add three hashrings to the
-        splitter.
+        hashring.
         """
         proxyList = None
-        (splitter, emailDist, httpsDist) = Main.createBridgeRings(self.config,
+        (hashring, emailDist, httpsDist) = Main.createBridgeRings(self.config,
                                                                   proxyList,
                                                                   self.key)
         # Should have an IPBasedDistributor ring, an EmailDistributor ring,
         # and an UnallocatedHolder ring:
-        self.assertEqual(len(splitter.ringsByName.keys()), 3)
+        self.assertEqual(len(hashring.ringsByName.keys()), 3)
 
     def test_Main_createBridgeRings_with_proxyList(self):
         """Main.createBridgeRings() should add three hashrings to the
-        splitter and add the proxyList to the IPBasedDistibutor.
+        hashring and add the proxyList to the IPBasedDistibutor.
         """
         exitRelays = ['1.1.1.1', '2.2.2.2', '3.3.3.3']
         proxyList = Main.proxy.ProxySet()
         proxyList.addExitRelays(exitRelays)
-        (splitter, emailDist, httpsDist) = Main.createBridgeRings(self.config,
+        (hashring, emailDist, httpsDist) = Main.createBridgeRings(self.config,
                                                                   proxyList,
                                                                   self.key)
         # Should have an IPBasedDistributor ring, an EmailDistributor ring,
         # and an UnallocatedHolder ring:
-        self.assertEqual(len(splitter.ringsByName.keys()), 3)
+        self.assertEqual(len(hashring.ringsByName.keys()), 3)
         self.assertGreater(len(httpsDist.proxies), 0)
         self.assertItemsEqual(exitRelays, httpsDist.proxies)
 
     def test_Main_createBridgeRings_no_https_dist(self):
         """When HTTPS_DIST=False, Main.createBridgeRings() should add only
-        two hashrings to the splitter.
+        two hashrings to the hashring.
         """
         proxyList = Main.proxy.ProxySet()
         config = self.config
         config.HTTPS_DIST = False
-        (splitter, emailDist, httpsDist) = Main.createBridgeRings(config,
+        (hashring, emailDist, httpsDist) = Main.createBridgeRings(config,
                                                                   proxyList,
                                                                   self.key)
         # Should have an EmailDistributor ring, and an UnallocatedHolder ring:
-        self.assertEqual(len(splitter.ringsByName.keys()), 2)
-        self.assertNotIn('https', splitter.rings)
-        self.assertNotIn(httpsDist, splitter.ringsByName.values())
+        self.assertEqual(len(hashring.ringsByName.keys()), 2)
+        self.assertNotIn('https', hashring.rings)
+        self.assertNotIn(httpsDist, hashring.ringsByName.values())
 
     def test_Main_createBridgeRings_no_email_dist(self):
         """When EMAIL_DIST=False, Main.createBridgeRings() should add only
-        two hashrings to the splitter.
+        two hashrings to the hashring.
         """
         proxyList = Main.proxy.ProxySet()
         config = self.config
         config.EMAIL_DIST = False
-        (splitter, emailDist, httpsDist) = Main.createBridgeRings(config,
+        (hashring, emailDist, httpsDist) = Main.createBridgeRings(config,
                                                                proxyList,
                                                                self.key)
         # Should have an IPBasedDistributor ring, and an UnallocatedHolder ring:
-        self.assertEqual(len(splitter.ringsByName.keys()), 2)
-        self.assertNotIn('email', splitter.rings)
-        self.assertNotIn(emailDist, splitter.ringsByName.values())
+        self.assertEqual(len(hashring.ringsByName.keys()), 2)
+        self.assertNotIn('email', hashring.rings)
+        self.assertNotIn(emailDist, hashring.ringsByName.values())
 
     def test_Main_createBridgeRings_no_reserved_share(self):
         """When RESERVED_SHARE=0, Main.createBridgeRings() should add only
-        two hashrings to the splitter.
+        two hashrings to the hashring.
         """
         proxyList = Main.proxy.ProxySet()
         config = self.config
         config.RESERVED_SHARE = 0
-        (splitter, emailDist, httpsDist) = Main.createBridgeRings(config,
+        (hashring, emailDist, httpsDist) = Main.createBridgeRings(config,
                                                                   proxyList,
                                                                   self.key)
         # Should have an IPBasedDistributor ring, and an EmailDistributor ring:
-        self.assertEqual(len(splitter.ringsByName.keys()), 2)
-        self.assertNotIn('unallocated', splitter.rings)
+        self.assertEqual(len(hashring.ringsByName.keys()), 2)
+        self.assertNotIn('unallocated', hashring.rings)
 
     def test_Main_createBridgeRings_two_file_buckets(self):
         """When FILE_BUCKETS has two filenames in it, Main.createBridgeRings()
-        should add three hashrings to the splitter, then add two
+        should add three hashrings to the hashring, then add two
         "pseudo-rings".
         """
         proxyList = Main.proxy.ProxySet()
@@ -336,17 +336,17 @@ class MainTests(unittest.TestCase):
             'bridges-for-support-desk': 10,
             'bridges-for-ooni-tests': 10,
         }
-        (splitter, emailDist, httpsDist) = Main.createBridgeRings(config,
+        (hashring, emailDist, httpsDist) = Main.createBridgeRings(config,
                                                                   proxyList,
                                                                   self.key)
         # Should have an IPBasedDistributor ring, an EmailDistributor, and an
         # UnallocatedHolder ring:
-        self.assertEqual(len(splitter.ringsByName.keys()), 3)
+        self.assertEqual(len(hashring.ringsByName.keys()), 3)
 
         # Should have two pseudoRings:
-        self.assertEqual(len(splitter.pseudoRings), 2)
-        self.assertIn('pseudo_bridges-for-support-desk', splitter.pseudoRings)
-        self.assertIn('pseudo_bridges-for-ooni-tests', splitter.pseudoRings)
+        self.assertEqual(len(hashring.pseudoRings), 2)
+        self.assertIn('pseudo_bridges-for-support-desk', hashring.pseudoRings)
+        self.assertIn('pseudo_bridges-for-ooni-tests', hashring.pseudoRings)
 
     def test_Main_run(self):
         """Main.run() should run and then finally raise SystemExit."""
diff --git a/lib/bridgedb/test/test_bridges.py b/lib/bridgedb/test/test_bridges.py
index 88b858e..e48e20a 100644
--- a/lib/bridgedb/test/test_bridges.py
+++ b/lib/bridgedb/test/test_bridges.py
@@ -167,7 +167,7 @@ class BridgeIntegrationTests(unittest.TestCase):
     test_getConfigLine_vanilla_withoutFingerprint   test_integration_getConfigLine_vanilla_withoutFingerprint
     test_getConfigLine_vanilla_withFingerprint      test_integration_getConfigLine_vanilla_withFingerprint
     test_getConfigLine_scramblesuit_withFingeprint  test_integration_getConfigLine_scramblesuit_withFingerprint
-    test_splitterBridgeInsertion                    test_integration_splitterBridgeInsertion
+    test_splitterBridgeInsertion                    test_integration_hashringBridgeInsertion
     ==============================================  ========================
     ..
     """
@@ -318,9 +318,9 @@ class BridgeIntegrationTests(unittest.TestCase):
                          % (self.fingerprint, ptArgsList),
                          bridgeLine)
 
-    def test_integration_splitterBridgeInsertion(self):
+    def test_integration_hashringBridgeInsertion(self):
         key = "Testing-Bridges-To-Rings"
-        splitter = FilteredBridgeSplitter(key)
+        hashring = FilteredBridgeSplitter(key)
 
         bridge1 = bridges.Bridge('unamed1', '1.2.3.5', 9100,
                                  'a1cc8dfef1fa11af9c40af1054df9daf45250550')
@@ -335,18 +335,18 @@ class BridgeIntegrationTests(unittest.TestCase):
                                  'b1cc8dfef1fa11af9c40af1054df9daf45250552')
         bridge4.setStatus(running = True)
 
-        self.failUnlessEqual(len(splitter), 0)
-        splitter.insert(bridge1)
-        splitter.insert(bridge2)
-        splitter.insert(bridge3)
+        self.failUnlessEqual(len(hashring), 0)
+        hashring.insert(bridge1)
+        hashring.insert(bridge2)
+        hashring.insert(bridge3)
         # Check that all were inserted
-        self.failUnlessEqual(len(splitter), 3)
-        splitter.insert(bridge1)
+        self.failUnlessEqual(len(hashring), 3)
+        hashring.insert(bridge1)
         # Check that the same bridge is not inserted twice
-        self.failUnlessEqual(len(splitter), 3)
-        splitter.insert(bridge4)
+        self.failUnlessEqual(len(hashring), 3)
+        hashring.insert(bridge4)
         # Check that identical bridges are not inserted twice
-        self.failUnlessEqual(len(splitter), 3)
+        self.failUnlessEqual(len(hashring), 3)
 
 
 class FlagsTests(unittest.TestCase):





More information about the tor-commits mailing list