From 78d58875a8423c493ceb856f7565fd53328a4732 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Mon, 29 Sep 2008 23:08:16 -0700 Subject: [PATCH] test_node: improve coverage of advertised_ip_addresses a bit --- src/allmydata/test/test_node.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/allmydata/test/test_node.py b/src/allmydata/test/test_node.py index 5e8182af..fad0e15f 100644 --- a/src/allmydata/test/test_node.py +++ b/src/allmydata/test/test_node.py @@ -46,6 +46,35 @@ class TestCase(unittest.TestCase, testutil.SignalMixin): d.addCallback(_check_addresses) return d + def test_advertised_ip_addresses2(self): + basedir = "test_node/test_advertised_ip_addresses2" + fileutil.make_dirs(basedir) + + n = TestNode(basedir) + n.setServiceParent(self.parent) + d = n.when_tub_ready() + # this lets the 'port' file get written + d.addCallback(lambda res: n.disownServiceParent()) + def _new_node(res): + f = open(os.path.join(basedir, 'advertised_ip_addresses'),'w') + f.write('1.2.3.4\n') + f.write("6.7.8.9\n") + f.close() + n2 = self.node = TestNode(basedir) + n2.setServiceParent(self.parent) + return n2.when_tub_ready() + d.addCallback(_new_node) + + def _check_addresses(ignored_result): + portfile = os.path.join(basedir, self.node.PORTNUMFILE) + port = int(open(portfile, "r").read().strip()) + furl = self.node.tub.registerReference(n) + self.failUnless(("1.2.3.4:%d" % port) in furl, furl) + self.failUnless(("6.7.8.9:%d" % port) in furl, furl) + + d.addCallback(_check_addresses) + return d + def test_timestamp(self): # this modified logger doesn't seem to get used during the tests, # probably because we don't modify the LogObserver that trial -- 2.45.2