aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristopher Baines <cb15g11@soton.ac.uk>2014-04-09 21:51:06 +0100
committerChristopher Baines <cb15g11@soton.ac.uk>2014-04-09 21:51:06 +0100
commitd753b9994986c4a19d60bfe6c49609eb13d7ca7c (patch)
treebb8c9c7ff1ab3ba73b32527a814f7898c09ba567 /lib
parentca371c8c818ff4c829337db876fdbe3df325d9a8 (diff)
downloadchutney-d753b9994986c4a19d60bfe6c49609eb13d7ca7c.tar
chutney-d753b9994986c4a19d60bfe6c49609eb13d7ca7c.tar.gz
Better tests
Diffstat (limited to 'lib')
-rw-r--r--lib/chutney/Testing.py57
-rw-r--r--lib/chutney/TorNet.py13
2 files changed, 31 insertions, 39 deletions
diff --git a/lib/chutney/Testing.py b/lib/chutney/Testing.py
index 396b949..369d260 100644
--- a/lib/chutney/Testing.py
+++ b/lib/chutney/Testing.py
@@ -49,29 +49,6 @@ def track_introduction_points(node):
node_intro_events[nodenum].put(("added", fingerprint))
- """prefix = "rend_services_introduce(): Giving up on "
- if logevent.message.startswith(prefix) or "Giving up on" in logevent.message:
- fingerprint = logevent.message[len(prefix):].split(" ")[0][1:41]
-
- for_deletion = []
-
- for circuit, fp in node_intro_circuits[nodenum].iteritems():
- #log("circuit " + str(circuit) + " fp " + str(fp))
- if fingerprint == fp:
- for_deletion.append(circuit)
-
- if len(for_deletion) == 0:
- logging.info("got log message " + logevent.message + " but not deleting an introduction point")
-
- for circuit in for_deletion:
- fingerprint = node_intro_circuits[nodenum][circuit]
-
- removed_intro_node = nodes_by_fingerprint[fingerprint]
-
- logging.info("%s: removed %s (%s)" % (nodenick, removed_intro_node._env["nick"], fingerprint))
-
- node_intro_events[nodenum].put(("removed", fingerprint))
- del node_intro_circuits[nodenum][circuit]"""
prefix = "rend_services_introduce(): Circuit to "
if logevent.message.startswith(prefix) and "disapeared" in logevent.message:
fingerprint = logevent.message[len(prefix):].split(" ")[0][1:41]
@@ -217,20 +194,26 @@ def check_same_intro_points():
for introduction_points in node_intro_circuits.values():
intro_sets.append(set(introduction_points.values()))
- if intro_sets[0].issubset(intro_sets[1]) and intro_sets[1].issubset(intro_sets[0]):
- logging.info("Same introduction points")
- for fingerprint in node_intro_circuits.values()[0].values():
- node = nodes_by_fingerprint[fingerprint]
- logging.info(" - " + node._env["nick"] + "(" + fingerprint + ")")
+ if len(intro_sets) == 1:
+ logging.info("Only one node, so trivially the same introduction points")
return True
- else:
- logging.info("Not the same introduction points")
- for num, circuits in node_intro_circuits.items():
- logging.info("node %i" % num)
- for fingerprint in sorted(circuits.values()):
- node = nodes_by_fingerprint[fingerprint]
- logging.info(" - " + node._env["nick"] + "(" + fingerprint + ")")
- return False
+
+ for i in range(len(intro_sets) - 1):
+ if not (intro_sets[i].issubset(intro_sets[i + 1]) and
+ intro_sets[i + 1].issubset(intro_sets[i])):
+ logging.info("Not the same introduction points")
+ for num, circuits in node_intro_circuits.items():
+ logging.info("node %i" % num)
+ for fingerprint in sorted(circuits.values()):
+ node = nodes_by_fingerprint[fingerprint]
+ logging.info(" - " + node._env["nick"] + "(" + fingerprint + ")")
+ return False
+
+ logging.info("Same introduction points")
+ for fingerprint in node_intro_circuits.values()[0].values():
+ node = nodes_by_fingerprint[fingerprint]
+ logging.info(" - " + node._env["nick"] + "(" + fingerprint + ")")
+ return True
def create_hidden_service(nodes):
hs_nodes = []
@@ -250,7 +233,7 @@ def create_hidden_service(nodes):
return str(self.siteNum)
base_port = 10080
- for i in range(2):
+ for i in range(nodes):
port = base_port + i
diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py
index 82a5fc0..1c626ba 100644
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@ -624,7 +624,17 @@ class Network(list):
"""A network of Tor nodes, plus functions to manipulate them
"""
def __init__(self, defaultEnviron=_BASE_ENVIRON):
+ """if name:
+ environ = chutney.Templating.Environ(parent=defaultEnviron)
+
+ print("Using name %s" % name)
+
+ environ["net_base_dir"] = os.path.join(environ["net_base_dir"], name)
+
+ self._dfltEnv = environ
+ else:"""
self._dfltEnv = defaultEnviron
+
self._nextnodenum = 0
def get(self, tag):
@@ -754,8 +764,7 @@ def usage(network):
" ".join(x for x in dir(network) if not x.startswith("_")))])
def runConfigFile(verb, f):
- _GLOBALS = dict(_BASE_ENVIRON=_BASE_ENVIRON,
- Node=Node,
+ _GLOBALS = dict(Node=Node,
EventType=stem.control.EventType,
time=time,
thread=thread,