[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/develop] Add a unit test that verifies we don't add duplicate bridges
commit 13fc557b8e4bd094457ca954129dceaa4445d744
Author: Matthew Finkel <Matthew.Finkel@xxxxxxxxx>
Date: Tue Mar 4 13:03:48 2014 +0000
Add a unit test that verifies we don't add duplicate bridges
Previously we did not check that a bridge was already in a splitter,
this resulted in adding bridges with (almost) identical information
and #9264.
---
lib/bridgedb/test/test_Bridges.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/lib/bridgedb/test/test_Bridges.py b/lib/bridgedb/test/test_Bridges.py
index 4e0b27e..421b308 100644
--- a/lib/bridgedb/test/test_Bridges.py
+++ b/lib/bridgedb/test/test_Bridges.py
@@ -109,3 +109,33 @@ class BridgeClassTest(unittest.TestCase):
digests = Bridges.getExtraInfoDigests(StringIO(test))
self.failUnlessIn(digest, digests)
self.failUnlessEqual(content, digests[digest].read())
+
+ def test_splitterBridgeInsertion(self):
+ key = "Testing-Bridges-To-Rings"
+ splitter = Bridges.FilteredBridgeSplitter(key)
+
+ bridge1 = Bridges.Bridge('unamed1', '1.2.3.5', 9100,
+ 'a1cc8dfef1fa11af9c40af1054df9daf45250550')
+ bridge1.setStatus(running = True)
+ bridge2 = Bridges.Bridge('unamed2', '1.2.3.4', 8080,
+ 'a1cc8dfef1fa11af9c40af1054df9daf45250551')
+ bridge2.setStatus(running = True)
+ bridge3 = Bridges.Bridge('unamed3', '5.2.3.4', 8080,
+ 'b1cc8dfef1fa11af9c40af1054df9daf45250552')
+ bridge3.setStatus(running = True)
+ bridge4 = Bridges.Bridge('unamed3', '5.2.3.4', 8080,
+ 'b1cc8dfef1fa11af9c40af1054df9daf45250552')
+ bridge4.setStatus(running = True)
+
+ self.failUnlessEqual(len(splitter), 0)
+ splitter.insert(bridge1)
+ splitter.insert(bridge2)
+ splitter.insert(bridge3)
+ # Check that all were inserted
+ self.failUnlessEqual(len(splitter), 3)
+ splitter.insert(bridge1)
+ # Check that the same bridge is not inserted twice
+ self.failUnlessEqual(len(splitter), 3)
+ splitter.insert(bridge4)
+ # Check that identical bridges are not inserted twice
+ self.failUnlessEqual(len(splitter), 3)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits