test_node: improve coverage of advertised_ip_addresses a bit
authorBrian Warner <warner@allmydata.com>
Tue, 30 Sep 2008 06:08:16 +0000 (23:08 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 30 Sep 2008 06:08:16 +0000 (23:08 -0700)
src/allmydata/test/test_node.py

index 5e8182afe55050a141308077f2aafa7a388c4da3..fad0e15f7f5ce04ae06be60ed582be8266250934 100644 (file)
@@ -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