def test_dsr_backward_no_retransmit(self): node_a = DsrNode(node_id="1", location=self.location_a) node_b = DsrNode(node_id="2", location=self.location_b) node_c = DsrNode(node_id="3", location=self.location_c) new_events_and_messages = node_b.run_node_backward(query_id=10, origin_id=node_a.id, previous_node=node_c, destiny_id=node_c, next_node=node_a, route=[]) self.assertFalse(new_events_and_messages['messages'])
def test_dsr_forward_reach_end(self): node_a = DsrNode(node_id="1", location=self.location_a, protocol_manager=self.protocol_manager) node_b = DsrNode(node_id="2", location=self.location_b, protocol_manager=self.protocol_manager) node_c = DsrNode(node_id="3", location=self.location_c, protocol_manager=self.protocol_manager) new_events_and_messages = node_a.run_node_backward(query_id=10, origin_id=node_a.id, previous_node=node_b, destiny_id=node_c.id, next_node=node_a, route=[]) self.assertFalse(new_events_and_messages['messages']) #And check that the simulator events that represents that the route was found is launched new_simulator_events = new_events_and_messages['simulator'] self.assertTrue(new_simulator_events) self.assert_(isinstance(new_simulator_events[0], RouteFoundEvent))
def test_dsr_backward_retransmit(self): node_a = DsrNode(node_id="1", location=self.location_a, protocol_manager=self.protocol_manager) node_b = DsrNode(node_id="2", location=self.location_b, protocol_manager=self.protocol_manager) node_c = DsrNode(node_id="3", location=self.location_c, protocol_manager=self.protocol_manager) node_b.responded_queries[(node_a.id, 10)] = node_a new_events_and_messages = node_b.run_node_backward(query_id=10, origin_id=node_a.id, previous_node=node_c, destiny_id=node_c.id, next_node=node_b, route=[]) new_message = new_events_and_messages['messages'] self.assertTrue(new_message) self.assertTrue(new_message[0].function_to_call.im_func is DsrNode.run_node_backward.im_func) self.assertFalse(new_message[0].function_to_call.im_func is DsrNode.run_node_forward.im_func) self.assertEquals(new_message[0].sender, node_b) self.assertEquals(new_message[0].emit_location, self.location_b)