[tor-commits] [bridgedb] branch main updated: Remove bridge fingerprint from sortedKeys as well as map

gitolite role git at cupani.torproject.org
Tue Mar 7 09:34:32 UTC 2023


This is an automated email from the git hooks/post-receive script.

meskio pushed a commit to branch main
in repository bridgedb.

The following commit(s) were added to refs/heads/main by this push:
     new ce9f631  Remove bridge fingerprint from sortedKeys as well as map
ce9f631 is described below

commit ce9f6318b00989e7c6834f1fbce4d86fd9156aa9
Author: Cecylia Bocovich <cohosh at torproject.org>
AuthorDate: Fri Feb 17 14:24:44 2023 -0500

    Remove bridge fingerprint from sortedKeys as well as map
---
 bridgedb/bridgerings.py           |  2 ++
 bridgedb/test/test_bridgerings.py | 14 ++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/bridgedb/bridgerings.py b/bridgedb/bridgerings.py
index ebbaa9b..73f8702 100644
--- a/bridgedb/bridgerings.py
+++ b/bridgedb/bridgerings.py
@@ -187,6 +187,8 @@ class BridgeRing(object):
         pos = self.hmac(bridge.identity)
         if pos in self.bridges:
             del self.bridges[pos]
+        if pos in self.sortedKeys:
+            self.sortedKeys.remove(pos)
 
     def insert(self, bridge):
         """Add a **bridge** to this hashring.
diff --git a/bridgedb/test/test_bridgerings.py b/bridgedb/test/test_bridgerings.py
index 7c899ab..c8391ff 100644
--- a/bridgedb/test/test_bridgerings.py
+++ b/bridgedb/test/test_bridgerings.py
@@ -87,6 +87,20 @@ class BridgeRingTests(unittest.TestCase):
 
         self.assertGreaterEqual(len(bridges), 1)
 
+    def test_remove(self):
+        """Remove should remove the bridge from the map and sortedKeys"""
+        bridges = copy.deepcopy(util.generateFakeBridges())
+
+        [self.ring.insert(bridge) for bridge in bridges]
+        pos0 = self.ring.hmac(bridges[0].identity)
+        pos1 = self.ring.hmac(bridges[1].identity)
+
+        self.ring.remove(bridges[0])
+        self.assertIn(pos1, self.ring.sortedKeys)
+        self.assertNotIn(pos0, self.ring.sortedKeys)
+        self.assertIn(pos1, self.ring.bridges)
+        self.assertNotIn(pos0, self.ring.bridges)
+
     def test_clear(self):
         """Clear should get rid of all the inserted bridges."""
         self.addRandomBridges()

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list