def test(self):
    self.nodes[LEADER].start()
    self.simulator.go(5)
    self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
    self.nodes[ROUTER1].start()
    self.nodes[DUT_ROUTER2].start()
    self.nodes[ROUTER3].start()
    self.nodes[MED1].start()
    self.simulator.go(5)
    self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
    self.assertEqual(self.nodes[DUT_ROUTER2].get_state(), 'router')
    self.assertEqual(self.nodes[ROUTER3].get_state(), 'router')
    self.assertEqual(self.nodes[MED1].get_state(), 'child')
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    router3_mleid = self.nodes[ROUTER3].get_ip6_address(config.ADDRESS_TYPE.ML_EID)
    self.assertTrue(self.nodes[MED1].ping(router3_mleid))
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    msg = dut_messages.next_coap_message('0.02', '/a/aq')
    command.check_address_query(msg, self.nodes[DUT_ROUTER2], config.REALM_LOCAL_ALL_ROUTERS_ADDRESS)
    self.simulator.go(5)
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    med1_mleid = self.nodes[MED1].get_ip6_address(config.ADDRESS_TYPE.ML_EID)
    self.assertTrue(self.nodes[ROUTER1].ping(med1_mleid))
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    msg = dut_messages.next_coap_message('0.02', '/a/an')
    command.check_address_notification(msg, self.nodes[DUT_ROUTER2], self.nodes[ROUTER1])
    self.simulator.go(5)
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    self.assertTrue(self.nodes[MED1].ping(router3_mleid))
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    msg = dut_messages.next_coap_message('0.02', '/a/aq', False)
    assert (msg is None), 'The Address Query Request is not expected.'
    self.nodes[ROUTER3].stop()
    self.simulator.go(580)
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    self.assertFalse(self.nodes[MED1].ping(router3_mleid))
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    msg = dut_messages.next_coap_message('0.02', '/a/aq')
    command.check_address_query(msg, self.nodes[DUT_ROUTER2], config.REALM_LOCAL_ALL_ROUTERS_ADDRESS)
    self.nodes[MED1].stop()
    self.simulator.go(MED1_TIMEOUT)
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    self.assertFalse(self.nodes[ROUTER1].ping(med1_mleid))
    self.assertFalse(self.nodes[ROUTER1].ping(med1_mleid))
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    msg = dut_messages.next_coap_message('0.02', '/a/an', False)
    assert (msg is None), 'The Address Notification is not expected.'
def test(self):
    self.nodes[LEADER].start()
    self.simulator.go(5)
    self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
    self.nodes[ROUTER1].start()
    self.nodes[DUT_ROUTER2].start()
    self.nodes[ROUTER3].start()
    self.nodes[MED1].start()
    self.simulator.go(5)
    self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
    self.assertEqual(self.nodes[DUT_ROUTER2].get_state(), 'router')
    self.assertEqual(self.nodes[ROUTER3].get_state(), 'router')
    self.assertEqual(self.nodes[MED1].get_state(), 'child')
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    router3_mleid = self.nodes[ROUTER3].get_ip6_address(config.ADDRESS_TYPE.ML_EID)
    self.assertTrue(self.nodes[MED1].ping(router3_mleid))
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    msg = dut_messages.next_coap_message('0.02', '/a/aq')
    command.check_address_query(msg, self.nodes[DUT_ROUTER2], config.REALM_LOCAL_ALL_ROUTERS_ADDRESS)
    self.simulator.go(5)
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    med1_mleid = self.nodes[MED1].get_ip6_address(config.ADDRESS_TYPE.ML_EID)
    self.assertTrue(self.nodes[ROUTER1].ping(med1_mleid))
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    msg = dut_messages.next_coap_message('0.02', '/a/an')
    command.check_address_notification(msg, self.nodes[DUT_ROUTER2], self.nodes[ROUTER1])
    self.simulator.go(5)
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    self.assertTrue(self.nodes[MED1].ping(router3_mleid))
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    msg = dut_messages.next_coap_message('0.02', '/a/aq', False)
    assert (msg is None), 'The Address Query Request is not expected.'
    self.nodes[ROUTER3].stop()
    self.simulator.go(580)
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    self.assertFalse(self.nodes[MED1].ping(router3_mleid))
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    msg = dut_messages.next_coap_message('0.02', '/a/aq')
    command.check_address_query(msg, self.nodes[DUT_ROUTER2], config.REALM_LOCAL_ALL_ROUTERS_ADDRESS)
    self.nodes[MED1].stop()
    self.simulator.go(MED1_TIMEOUT)
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    self.assertFalse(self.nodes[ROUTER1].ping(med1_mleid))
    self.assertFalse(self.nodes[ROUTER1].ping(med1_mleid))
    dut_messages = self.simulator.get_messages_sent_by(DUT_ROUTER2)
    msg = dut_messages.next_coap_message('0.02', '/a/an', False)
    assert (msg is None), 'The Address Notification is not expected.'