From ff578fccf801d18a71d8665d6d98d892a3d9ba0d Mon Sep 17 00:00:00 2001 From: meejah Date: Fri, 12 Feb 2021 00:50:05 -0700 Subject: [PATCH] fix more tests (that examine internals) --- .../test/test_transit_server.py | 16 +++++++++------- src/wormhole_transit_relay/transit_server.py | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/wormhole_transit_relay/test/test_transit_server.py b/src/wormhole_transit_relay/test/test_transit_server.py index a3b7a90..a4f2f94 100644 --- a/src/wormhole_transit_relay/test/test_transit_server.py +++ b/src/wormhole_transit_relay/test/test_transit_server.py @@ -13,9 +13,11 @@ def handshake(token, side=None): class _Transit: def count(self): - return sum([len(potentials) - for potentials - in self._transit_server._pending_requests.values()]) + return sum([ + len(potentials) + for potentials + in self._transit_server.pending_requests._requests.values() + ]) def test_blur_size(self): blur = transit_server.blur_size @@ -50,7 +52,7 @@ class _Transit: self.assertEqual(self.count(), 0) # the token should be removed too - self.assertEqual(len(self._transit_server._pending_requests), 0) + self.assertEqual(len(self._transit_server.pending_requests._requests), 0) def test_both_unsided(self): p1 = self.new_protocol() @@ -186,8 +188,8 @@ class _Transit: p3.send(handshake(token1, side=side2)) self.flush() self.assertEqual(self.count(), 0) - self.assertEqual(len(self._transit_server._pending_requests), 0) - self.assertEqual(len(self._transit_server._active_connections), 2) + self.assertEqual(len(self._transit_server.pending_requests._requests), 0) + self.assertEqual(len(self._transit_server.active_connections._connections), 2) # That will trigger a disconnect on exactly one of (p1 or p2). # The other connection should still be connected self.assertEqual(sum([int(t.connected) for t in [p1, p2]]), 1) @@ -441,7 +443,7 @@ class Usage(ServerBase, unittest.TestCase): p2.send(handshake(token1, side=side2)) self.flush() - self.assertEqual(len(self._transit_server._pending_requests), 0) + self.assertEqual(len(self._transit_server.pending_requests._requests), 0) self.assertEqual(len(self._usage), 2, self._usage) self.assertEqual(self._usage[1]["mood"], "redundant") diff --git a/src/wormhole_transit_relay/transit_server.py b/src/wormhole_transit_relay/transit_server.py index 1727610..fba84be 100644 --- a/src/wormhole_transit_relay/transit_server.py +++ b/src/wormhole_transit_relay/transit_server.py @@ -270,8 +270,8 @@ class Transit(protocol.ServerFactory): self._db = get_db(usage_db) self._rebooted = time.time() # we don't track TransitConnections until they submit a token - self._pending_requests = defaultdict(set) # token -> set((side, TransitConnection)) - self._active_connections = set() # TransitConnection +## self._pending_requests = defaultdict(set) # token -> set((side, TransitConnection)) +## self._active_connections = set() # TransitConnection def transitFinished(self, tc, token, side, description): if token in self._pending_requests: