[tor-commits] [chutney/master] Make TrafficTester create sources and sinks
teor at torproject.org
teor at torproject.org
Thu Jun 20 07:45:41 UTC 2019
commit 58c5a3c69dde2f057e82fb64aa4932acbcdd0840
Author: Nick Mathewson <nickm at torproject.org>
Date: Fri May 10 11:24:50 2019 -0400
Make TrafficTester create sources and sinks
We'd like to be able to change the client and responder behavior,
but we need to keep both parts synchronized as we do so.
---
lib/chutney/Traffic.py | 13 ++++++++++---
scripts/chutney_tests/verify.py | 4 ++--
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/lib/chutney/Traffic.py b/lib/chutney/Traffic.py
index 7ef3b2f..de21d60 100755
--- a/lib/chutney/Traffic.py
+++ b/lib/chutney/Traffic.py
@@ -125,8 +125,7 @@ class Listener(asyncore.dispatcher):
newsock, endpoint = pair
debug("new client from %s:%s (fd=%d)" %
(endpoint[0], endpoint[1], newsock.fileno()))
- handler = Sink(newsock, self.tt)
- self.tt.add(handler)
+ self.tt.add_responder(newsock)
def fileno(self):
return self.socket.fileno()
@@ -320,6 +319,14 @@ class TrafficTester(object):
for name in item.get_test_names():
self.tests.add(name)
+ def add_client(self, server, proxy=None):
+ source = Source(self, server, proxy)
+ self.add(source)
+
+ def add_responder(self, socket):
+ sink = Sink(socket, self)
+ self.add(sink)
+
def success(self, name):
"""Declare that a single test has passed."""
self.tests.success(name)
@@ -355,7 +362,7 @@ def main():
tt = TrafficTester(bind_to, DATA)
# Don't use a proxy for self-testing, so that we avoid tor entirely
- tt.add(Source(tt, bind_to))
+ tt.add_client(bind_to)
success = tt.run()
if success:
diff --git a/scripts/chutney_tests/verify.py b/scripts/chutney_tests/verify.py
index 43100d6..e97ff52 100644
--- a/scripts/chutney_tests/verify.py
+++ b/scripts/chutney_tests/verify.py
@@ -155,7 +155,7 @@ def _configure_exits(tt, bind_to, tmpdata, reps, client_list, exit_list,
'localhost', op._env['socksport']))
for _ in range(connection_count):
proxy = ('localhost', int(op._env['socksport']))
- tt.add(chutney.Traffic.Source(tt, bind_to, proxy))
+ tt.add_client(bind_to, proxy)
return exit_path_node_count
@@ -187,7 +187,7 @@ def _configure_hs(tt, tmpdata, reps, client_list, hs_list, HS_PORT,
'localhost', client._env['socksport']))
for _ in range(connection_count):
proxy = ('localhost', int(client._env['socksport']))
- tt.add(chutney.Traffic.Source(tt, hs_bind_to, proxy))
+ tt.add_client(hs_bind_to, proxy)
return hs_path_node_count
More information about the tor-commits
mailing list