#NEWLINE# def test_nodesFound( self ) : #NEWLINE# #INDENT# self . _connecting_to_connected ( ) #NEWLINE# self . wire_protocol [ self . addr1 ] = self . con #NEWLINE# self . wire_protocol [ self . addr2 ] = self . con #NEWLINE# self . wire_protocol [ self . addr3 ] = self . con #NEWLINE# self . protocol . router . addContact ( self . node1 ) #NEWLINE# self . protocol . router . addContact ( self . node2 ) #NEWLINE# self . protocol . router . addContact ( self . node3 ) #NEWLINE# node = Node ( digest ( 's' ) ) #NEWLINE# nearest = self . protocol . router . findNeighbors ( node ) #NEWLINE# spider = NodeSpiderCrawl ( self . protocol , node , nearest , 20 , 3 ) #NEWLINE# response = ( True , ( self . node1 . getProto ( ) . SerializeToString ( ) , self . node2 . getProto ( ) . SerializeToString ( ) , self . node3 . getProto ( ) . SerializeToString ( ) ) ) #NEWLINE# responses = { #NEWLINE# #INDENT# self . node1 . id : response , #NEWLINE# #UNINDENT# } #NEWLINE# spider . _nodesFound ( responses ) #NEWLINE# self . clock . advance ( constants . PACKET_TIMEOUT ) #NEWLINE# connection . REACTOR . runUntilCurrent ( ) #NEWLINE# self . assertEqual ( len ( self . proto_mock . send_datagram . call_args_list ) , 4 ) #NEWLINE# response = ( True , ( self . node1 . getProto ( ) . SerializeToString ( ) , self . node2 . getProto ( ) . SerializeToString ( ) , self . node3 . getProto ( ) . SerializeToString ( ) ) ) #NEWLINE# responses = { #NEWLINE# #INDENT# self . node1 . id : response , #NEWLINE# #UNINDENT# } #NEWLINE# nodes = spider . _nodesFound ( responses ) #NEWLINE# node_protos = [ ] #NEWLINE# for n in nodes : #NEWLINE# #INDENT# node_protos . append ( n . getProto ( ) ) #NEWLINE# #UNINDENT# self . assertTrue ( ( self . node1 . getProto ( ) in node_protos ) ) #NEWLINE# self . assertTrue ( ( self . node2 . getProto ( ) in node_protos ) ) #NEWLINE# self . assertTrue ( ( self . node3 . getProto ( ) in node_protos ) ) #NEWLINE# response = ( False , ( self . node1 . getProto ( ) . SerializeToString ( ) , self . node2 . getProto ( ) . SerializeToString ( ) , self . node3 . getProto ( ) . SerializeToString ( ) ) ) #NEWLINE# responses = { #NEWLINE# #INDENT# self . node1 . id : response , #NEWLINE# #UNINDENT# } #NEWLINE# nodes = spider . _nodesFound ( responses ) #NEWLINE# node_protos = [ ] #NEWLINE# for n in nodes : #NEWLINE# #INDENT# node_protos . append ( n . getProto ( ) ) #NEWLINE# #UNINDENT# self . assertTrue ( ( self . node2 . getProto ( ) in node_protos ) ) #NEWLINE# self . assertTrue ( ( self . node3 . getProto ( ) in node_protos ) )