Esempio n. 1
0
    def test_dsr_not_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)

        new_events_and_messages = node_b.run_node_forward(query_id=10, origin_id=node_a.id, previous_node=node_a, destiny_id=node_c.id)
        new_message = new_events_and_messages['messages']
        self.assert_(new_message)

        new_events_and_messages = node_b.run_node_forward(query_id=10, origin_id=node_a.id, previous_node=node_c, destiny_id=node_c.id)
        self.assertFalse(new_events_and_messages['messages'])
Esempio n. 2
0
    def test_dsr_forward_origin(self):
        node_a = DsrNode(node_id="1", location=self.location_a, protocol_manager=self.protocol_manager)
        node_c = DsrNode(node_id="2", location=self.location_c, protocol_manager=self.protocol_manager)

        new_events_and_messages = node_a.run_node_forward(query_id=10, origin_id=node_a.id, previous_node=None, destiny_id=node_c)
        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_forward.im_func)
        self.assertFalse(new_message[0].function_to_call.im_func is DsrNode.run_node_backward.im_func)
        self.assertEquals(new_message[0].sender, node_a)
        self.assertEquals(new_message[0].emit_location, self.location_a)