def test(self): # 1 Ensure topology is formed correctly without ROUTER24. self.nodes[LEADER].start() self.simulator.go(5) self.assertEqual(self.nodes[LEADER].get_state(), 'leader') for i in range(2, 24): self.nodes[i].start() self.simulator.go(5) self.assertEqual(self.nodes[i].get_state(), 'router') # This method flushes the message queue so calling this method again # will return only the newly logged messages. dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER1) # 2 ROUTER24: Attach to network. # All reference testbed devices have been configured with downgrade threshold as 32 except DUT_ROUTER1, # so we don't need to ensure ROUTER24 has a better link quality on # posix. self.nodes[ROUTER24].start() self.simulator.go(5) self.assertEqual(self.nodes[ROUTER24].get_state(), 'router') # 3 DUT_ROUTER1: self.simulator.go(10) self.assertEqual(self.nodes[DUT_ROUTER1].get_state(), 'child') # Verify it sent a Parent Request and Child ID Request. dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER1) dut_messages.next_mle_message(mle.CommandType.PARENT_REQUEST) dut_messages.next_mle_message(mle.CommandType.CHILD_ID_REQUEST) # Verify it sent an Address Release Message to the Leader when it # attached as a child. msg = dut_messages.next_coap_message('0.02') command.check_address_release(msg, self.nodes[LEADER]) # 4 & 5 router1_rloc = self.nodes[DUT_ROUTER1].get_ip6_address( config.ADDRESS_TYPE.RLOC ) self.assertTrue(self.nodes[LEADER].ping(router1_rloc))
def test(self): # 1 Ensure topology is formed correctly without ROUTER24. self.nodes[LEADER].start() self.simulator.go(5) self.assertEqual(self.nodes[LEADER].get_state(), 'leader') for i in range(2, 24): self.nodes[i].start() self.simulator.go(5) self.assertEqual(self.nodes[i].get_state(), 'router') # This method flushes the message queue so calling this method again will return only the newly logged messages. dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER1) # 2 ROUTER24: Attach to network. # All reference testbed devices have been configured with downgrade threshold as 32 except DUT_ROUTER1, # so we don't need to ensure ROUTER24 has a better link quality on posix. self.nodes[ROUTER24].start() self.simulator.go(5) self.assertEqual(self.nodes[ROUTER24].get_state(), 'router') # 3 DUT_ROUTER1: self.simulator.go(10) self.assertEqual(self.nodes[DUT_ROUTER1].get_state(), 'child') # Verify it sent a Parent Request and Child ID Request. dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER1) dut_messages.next_mle_message(mle.CommandType.PARENT_REQUEST) dut_messages.next_mle_message(mle.CommandType.CHILD_ID_REQUEST) # Verify it sent an Address Release Message to the Leader when it attached as a child. msg = dut_messages.next_coap_message('0.02') command.check_address_release(msg, self.nodes[LEADER]) # 4 & 5 router1_rloc = self.nodes[DUT_ROUTER1].get_ip6_address(config.ADDRESS_TYPE.RLOC) self.assertTrue(self.nodes[LEADER].ping(router1_rloc))