]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
now that foolscap-0.0.7 accepts connect-to-self, allow peers to know about themselves...
authorBrian Warner <warner@allmydata.com>
Tue, 16 Jan 2007 22:12:49 +0000 (15:12 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 16 Jan 2007 22:12:49 +0000 (15:12 -0700)
src/allmydata/client.py
src/allmydata/queen.py
src/allmydata/test/test_system.py

index 203961ec51b32b04542c188f6b4d08056abf0040..0fe2c7e67ee74419c525c8ed883e3a6ccc9750eb 100644 (file)
@@ -100,8 +100,6 @@ class Client(node.Node, Referenceable):
 
     def remote_add_peers(self, new_peers):
         for nodeid, pburl in new_peers:
-            if nodeid == self.nodeid:
-                continue
             self.log("adding peer %s" % idlib.b2a(nodeid))
             if nodeid in self.all_peers:
                 self.log("weird, I already had an entry for them")
index cb4596129ec54926cf1647bd12bb804542763eee..c49f384f0dda783af1c39160e93bbbcfd3ae1ef1 100644 (file)
@@ -32,12 +32,12 @@ class Roster(service.MultiService, Referenceable):
 
     def remote_hello(self, nodeid, node, pburl):
         log.msg("roster: contact from %s" % idlib.b2a(nodeid))
+        self.phonebook[nodeid] = pburl
+        self.connections[nodeid] = node
         eventually(self._educate_the_new_peer,
                    nodeid, node, list(self.phonebook.items()))
         eventually(self._announce_new_peer,
                    nodeid, pburl, list(self.connections.values()))
-        self.phonebook[nodeid] = pburl
-        self.connections[nodeid] = node
         node.notifyOnDisconnect(self._lost_node, nodeid)
         return self.gvd_root
 
index f3956146cb26007e440fafad61ed211759751b36..f2f531261d533ea4252b7f045e119d72a22c6d28 100644 (file)
@@ -81,7 +81,7 @@ class SystemTest(unittest.TestCase):
 
     def wait_for_connections(self, ignored=None):
         for c in self.clients:
-            if len(c.connections) != self.numclients - 1:
+            if len(c.connections) != self.numclients:
                 d = defer.Deferred()
                 d.addCallback(self.wait_for_connections)
                 reactor.callLater(0.05, d.callback, None)
@@ -92,17 +92,17 @@ class SystemTest(unittest.TestCase):
         d = self.set_up_nodes()
         d.addCallback(lambda res: self.add_extra_node(5))
         def _check(extra_node):
+            self.extra_node = extra_node
             for c in self.clients:
-                self.failUnlessEqual(len(c.connections), 5)
-            return extra_node
+                self.failUnlessEqual(len(c.connections), 6)
         d.addCallback(_check)
-        def _shutdown_extra_node(extra_node):
-            d1 = extra_node.stopService()
+        def _shutdown_extra_node(res):
+            d1 = self.extra_node.stopService()
             d2 = defer.Deferred()
-            reactor.callLater(self.DISCONNECT_DELAY, d2.callback, None)
-            d1.addCallback(lambda res: d2)
+            reactor.callLater(self.DISCONNECT_DELAY, d2.callback, res)
+            d1.addCallback(lambda ignored: d2)
             return d1
-        d.addCallback(_shutdown_extra_node)
+        d.addBoth(_shutdown_extra_node)
         return d
     test_connections.timeout = 20
 
@@ -161,7 +161,7 @@ class SystemTest(unittest.TestCase):
         base = self.webish_url
         d = getPage(base)
         def _got_welcome(page):
-            expected = "Connected Peers: <span>%d</span>" % (self.numclients-1)
+            expected = "Connected Peers: <span>%d</span>" % (self.numclients)
             self.failUnless(expected in page,
                             "I didn't see the right 'connected peers' message "
                             "in: %s" % page