From 0ff21ea7d55e607da7bcdbcc91659c4700e84253 Mon Sep 17 00:00:00 2001 From: meejah Date: Sun, 28 Jan 2018 21:49:05 -0700 Subject: [PATCH] all tests pass. wooo --- src/allmydata/introducer/__init__.py | 5 +++- src/allmydata/introducer/server.py | 19 +++++++------- src/allmydata/test/test_system.py | 32 +++++++++++------------ src/allmydata/test/web/test_introducer.py | 8 +++--- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/allmydata/introducer/__init__.py b/src/allmydata/introducer/__init__.py index 255555ca5..3b12e2275 100644 --- a/src/allmydata/introducer/__init__.py +++ b/src/allmydata/introducer/__init__.py @@ -2,8 +2,11 @@ # This is for compatibilty with old .tac files, which reference # allmydata.introducer.IntroducerNode +from allmydata.introducer.server import create_introducer +# apparently need to support "old .tac files" that may have this name burned in +# don't use this in new code from allmydata.introducer.server import _IntroducerNode as IntroducerNode # hush pyflakes -_unused = [IntroducerNode] +_unused = [create_introducer, IntroducerNode] del _unused diff --git a/src/allmydata/introducer/server.py b/src/allmydata/introducer/server.py index d019543c6..6b93a1841 100644 --- a/src/allmydata/introducer/server.py +++ b/src/allmydata/introducer/server.py @@ -65,17 +65,16 @@ def create_introducer(basedir=u"."): control_tub = create_control_tub() - return defer.succeed( - _IntroducerNode( - config, - main_tub, - control_tub, - i2p_provider, - tor_provider, - basedir, - tub_is_listening=is_listening, - ) + node = _IntroducerNode( + config, + main_tub, + control_tub, + i2p_provider, + tor_provider, + basedir, + tub_is_listening=is_listening, ) + return defer.succeed(node) class _IntroducerNode(node.Node): diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index f84d69e0f..f46f9e104 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -557,18 +557,14 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin): f = open(os.path.join(iv_dir, "private", "node.pem"), "w") f.write(SYSTEM_TEST_CERTS[0]) f.close() - return create_introducer(basedir=iv_dir) -# ======= -# iv = yield create_introducer(basedir=iv_dir) -# print("introducer {}".format(iv)) -# self.introducer = self.add_service(iv) -# self._get_introducer_web() -# if use_stats_gatherer: -# yield self._set_up_stats_gatherer(None) -# yield self._set_up_nodes_2(None) -# if use_stats_gatherer: -# yield self._grab_stats(None) -# >>>>>>> more working test + iv = yield create_introducer(basedir=iv_dir) + self.introducer = self.add_service(iv) + self._get_introducer_web() + if use_stats_gatherer: + yield self._set_up_stats_gatherer(None) + yield self._set_up_nodes_2(None) + if use_stats_gatherer: + yield self._grab_stats(None) def _get_introducer_web(self): with open(os.path.join(self.getdir("introducer"), "node.url"), "r") as f: @@ -749,8 +745,10 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin): # behavior, see if this is really the problem, see if we can do # better than blindly waiting for a second. d.addCallback(self.stall, 1.0) + + @defer.inlineCallbacks def _stopped(res): - new_c = client.create_client(self.getdir("client%d" % num)) + new_c = yield client.create_client(self.getdir("client%d" % num)) self.clients[num] = new_c new_c.set_default_mutable_keysize(TEST_RSA_KEY_SIZE) self.add_service(new_c) @@ -763,6 +761,7 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin): d.addCallback(_maybe_get_webport) return d + @defer.inlineCallbacks def add_extra_node(self, client_num, helper_furl=None, add_to_sparent=False): # usually this node is *not* parented to our self.sparent, so we can @@ -777,7 +776,7 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin): config += "helper.furl = %s\n" % helper_furl fileutil.write(os.path.join(basedir, 'tahoe.cfg'), config) - c = client.create_client(basedir) + c = yield client.create_client(basedir) self.clients.append(c) c.set_default_mutable_keysize(TEST_RSA_KEY_SIZE) self.numclients += 1 @@ -785,9 +784,8 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin): c.setServiceParent(self.sparent) else: c.startService() - d = self.wait_for_connections() - d.addCallback(lambda res: c) - return d + res = yield self.wait_for_connections() + defer.returnValue(c) def _check_connections(self): for i, c in enumerate(self.clients): diff --git a/src/allmydata/test/web/test_introducer.py b/src/allmydata/test/web/test_introducer.py index 2efe17fcd..40823ea76 100644 --- a/src/allmydata/test/web/test_introducer.py +++ b/src/allmydata/test/web/test_introducer.py @@ -1,7 +1,9 @@ +from os.path import join from twisted.trial import unittest from foolscap.api import fireEventually, flushEventualQueue from twisted.internet import defer -from allmydata.introducer import IntroducerNode +from allmydata.introducer import create_introducer +from allmydata.util import fileutil from allmydata import node from .common import FAVICON_MARKUP from ..common_web import do_http @@ -28,9 +30,7 @@ class IntroducerWeb(unittest.TestCase): node.create_node_dir(basedir, "testing") from allmydata.node import config_from_string - self.node = IntroducerNode( - config_from_string(config, "introducer.port", basedir), - ) + self.node = yield create_introducer(basedir) self.ws = self.node.getServiceNamed("webish") yield fireEventually(None)