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")
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
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)
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
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