def test_skill_id_positive(self): """Test skill_id property positive result""" obj = SkillContext("agent_context") obj._skill = mock.Mock() obj._skill.config = mock.Mock() obj._skill.config.public_id = "public_id" obj.skill_id
def setup(self) -> None: """Set test cae instance.""" agent_name = "MyAgent" builder = AEABuilder() builder.set_name(agent_name) builder.add_private_key(DEFAULT_LEDGER, COSMOS_PRIVATE_KEY_PATH) self.handler_called = 0 def handler_func(*args, **kwargs): self.handler_called += 1 skill_context = SkillContext() handler_cls = make_handler_cls_from_funcion(handler_func) behaviour_cls = make_behaviour_cls_from_funcion(handler_func) self.handler = handler_cls(name="handler1", skill_context=skill_context) self.behaviour = behaviour_cls(name="behaviour1", skill_context=skill_context) test_skill = Skill( SkillConfig(name="test_skill", author="fetchai"), skill_context=skill_context, handlers={"handler": self.handler}, behaviours={"behaviour": self.behaviour}, ) skill_context._skill = test_skill # weird hack builder.add_component_instance(test_skill) self.aea = builder.build() self.aea_tool = AeaTool(self.aea)
def test_behaviours_positive(self, *mocks): """Test behaviours property positive result""" obj = SkillContext("agent_context") with self.assertRaises(AssertionError): obj.behaviours obj._skill = mock.Mock() obj._skill.behaviours = {} obj.behaviours
def test_handlers_positive(self, *mocks): """Test handlers property positive result""" obj = SkillContext("agent_context") with self.assertRaises(ValueError): obj.handlers obj._skill = mock.Mock() obj._skill.handlers = {} obj.handlers
def test_task_manager_positive(self): """Test task_manager property positive result""" agent_context = mock.Mock() agent_context.task_manager = "task_manager" obj = SkillContext(agent_context) with self.assertRaises(AssertionError): obj.task_manager obj._skill = mock.Mock() obj.task_manager
def prepare(self, function: Callable) -> None: """Prepare aea_tool for testing. :param function: function be called on react handle or/and Behaviour.act :return: None """ agent_name = "MyAgent" builder = AEABuilder() builder.set_name(agent_name) builder.add_private_key(FetchAICrypto.identifier, FETCHAI_PRIVATE_KEY_PATH) self.function_finished = False def handler_func(*args, **kwargs): function() self.function_finished = True skill_context = SkillContext() handler_cls = make_handler_cls_from_funcion(handler_func) behaviour_cls = make_behaviour_cls_from_funcion(handler_func) test_skill = Skill( SkillConfig(name="test_skill", author="fetchai"), skill_context=skill_context, handlers={ "handler1": handler_cls(name="handler1", skill_context=skill_context) }, behaviours={ "behaviour1": behaviour_cls(name="behaviour1", skill_context=skill_context) }, ) skill_context._skill = test_skill # weird hack builder._add_component_to_resources(test_skill) aea = builder.build() self.aea_tool = AeaTool(aea) self.aea_tool.put_inbox(AeaTool.dummy_envelope())
def _builder(self, agent_name="agent1", act_func=None) -> AEABuilder: """Build an aea instance.""" builder = AEABuilder() builder.set_name(agent_name) builder.add_private_key(FetchAICrypto.identifier, FETCHAI_PRIVATE_KEY_PATH) skill_context = SkillContext() act_func = act_func or (lambda self: self) behaviour_cls = make_behaviour_cls_from_funcion(act_func) behaviour = behaviour_cls(name="behaviour", skill_context=skill_context) test_skill = Skill( SkillConfig(name="test_skill", author="fetchai"), skill_context=skill_context, behaviours={"behaviour": behaviour}, ) skill_context._skill = test_skill # weird hack builder.add_component_instance(test_skill) builder.set_runtime_mode("async") return builder
def prepare(self, function: Callable) -> None: """Prepare aea_tool for testing. :param function: function be called on react handle or/and Behaviour.act :return: None """ agent_name = "MyAgent" builder = AEABuilder() builder.set_name(agent_name) builder.add_private_key(DEFAULT_LEDGER, FETCHAI_PRIVATE_KEY_PATH) self.function_finished = False def handler_func(*args, **kwargs): function() self.function_finished = True skill_context = SkillContext() handler_cls = make_handler_cls_from_funcion(handler_func) behaviour_cls = make_behaviour_cls_from_funcion(handler_func) self.behaviour = behaviour_cls(name="behaviour1", skill_context=skill_context) test_skill = Skill( SkillConfig(name="test_skill", author="fetchai"), skill_context=skill_context, handlers={ "handler1": handler_cls(name="handler1", skill_context=skill_context) }, behaviours={"behaviour1": self.behaviour}, ) skill_context._skill = test_skill # weird hack builder.add_component_instance(test_skill) aea = builder.build() self.aea_tool = AeaTool(aea) self.envelope = AeaTool.dummy_envelope() self.aea_tool.aea.runtime.main_loop._setup()
def test_generated_protocol_end_to_end(self): """Test that a generated protocol could be used in exchanging messages between two agents.""" agent_name_1 = "my_aea_1" agent_name_2 = "my_aea_2" builder_1 = AEABuilder() builder_1.set_name(agent_name_1) builder_1.add_private_key(DEFAULT_LEDGER, self.private_key_path_1) builder_1.set_default_ledger(DEFAULT_LEDGER) builder_1.set_default_connection(PublicId.from_str("fetchai/oef:0.7.0")) builder_1.add_protocol( Path(ROOT_DIR, "packages", "fetchai", "protocols", "fipa") ) builder_1.add_protocol( Path(ROOT_DIR, "packages", "fetchai", "protocols", "oef_search") ) builder_1.add_component( ComponentType.PROTOCOL, Path(PATH_TO_T_PROTOCOL), skip_consistency_check=True, ) builder_1.add_connection( Path(ROOT_DIR, "packages", "fetchai", "connections", "oef") ) builder_2 = AEABuilder() builder_2.set_name(agent_name_2) builder_2.add_private_key(DEFAULT_LEDGER, self.private_key_path_2) builder_2.set_default_ledger(DEFAULT_LEDGER) builder_2.add_protocol( Path(ROOT_DIR, "packages", "fetchai", "protocols", "fipa") ) builder_2.add_protocol( Path(ROOT_DIR, "packages", "fetchai", "protocols", "oef_search") ) builder_2.set_default_connection(PublicId.from_str("fetchai/oef:0.7.0")) builder_2.add_component( ComponentType.PROTOCOL, Path(PATH_TO_T_PROTOCOL), skip_consistency_check=True, ) builder_2.add_connection( Path(ROOT_DIR, "packages", "fetchai", "connections", "oef") ) # create AEAs aea_1 = builder_1.build(connection_ids=[PublicId.from_str("fetchai/oef:0.7.0")]) aea_2 = builder_2.build(connection_ids=[PublicId.from_str("fetchai/oef:0.7.0")]) # dialogues dialogue_label_1 = DialogueLabel( (str(1), ""), aea_2.identity.address, aea_1.identity.address ) aea_1_dialogue = TProtocolDialogue( dialogue_label_1, aea_1.identity.address, TProtocolDialogue.Role.ROLE_1 ) dialogue_label_2 = DialogueLabel( (str(1), str(1)), aea_1.identity.address, aea_1.identity.address ) aea_2_dialogue = TProtocolDialogue( dialogue_label_2, aea_2.identity.address, TProtocolDialogue.Role.ROLE_2 ) # message 1 message_1 = TProtocolMessage( message_id=1, dialogue_reference=(str(1), ""), target=0, performative=TProtocolMessage.Performative.PERFORMATIVE_PT, content_bytes=b"some bytes", content_int=42, content_float=42.7, content_bool=True, content_str="some string", ) message_1.counterparty = aea_2.identity.address message_1.is_incoming = False # message 2 message_2 = TProtocolMessage( message_id=2, dialogue_reference=(str(1), str(1)), target=1, performative=TProtocolMessage.Performative.PERFORMATIVE_PT, content_bytes=b"some other bytes", content_int=43, content_float=43.7, content_bool=False, content_str="some other string", ) message_2.counterparty = aea_1.identity.address message_2.is_incoming = False # add handlers to AEA resources skill_context_1 = SkillContext(aea_1.context) skill_1 = Skill(SkillConfig("fake_skill", "fetchai", "0.1.0"), skill_context_1) skill_context_1._skill = skill_1 agent_1_handler = Agent1Handler( skill_context=skill_context_1, name="fake_handler_1", dialogue=aea_1_dialogue, ) aea_1.resources._handler_registry.register( ( PublicId.from_str("fetchai/fake_skill:0.1.0"), TProtocolMessage.protocol_id, ), agent_1_handler, ) skill_context_2 = SkillContext(aea_2.context) skill_2 = Skill(SkillConfig("fake_skill", "fetchai", "0.1.0"), skill_context_2) skill_context_2._skill = skill_2 agent_2_handler = Agent2Handler( message=message_2, dialogue=aea_2_dialogue, skill_context=skill_context_2, name="fake_handler_2", ) aea_2.resources._handler_registry.register( ( PublicId.from_str("fetchai/fake_skill:0.1.0"), TProtocolMessage.protocol_id, ), agent_2_handler, ) # Start threads t_1 = Thread(target=aea_1.start) t_2 = Thread(target=aea_2.start) try: t_1.start() t_2.start() time.sleep(1.0) aea_1_dialogue.update(message_1) aea_1.outbox.put_message(message_1) time.sleep(5.0) assert ( agent_2_handler.handled_message.message_id == message_1.message_id ), "Message from Agent 1 to 2: message ids do not match" assert ( agent_2_handler.handled_message.dialogue_reference == message_1.dialogue_reference ), "Message from Agent 1 to 2: dialogue references do not match" assert ( agent_2_handler.handled_message.dialogue_reference[0] == message_1.dialogue_reference[0] ), "Message from Agent 1 to 2: dialogue reference[0]s do not match" assert ( agent_2_handler.handled_message.dialogue_reference[1] == message_1.dialogue_reference[1] ), "Message from Agent 1 to 2: dialogue reference[1]s do not match" assert ( agent_2_handler.handled_message.target == message_1.target ), "Message from Agent 1 to 2: targets do not match" assert ( agent_2_handler.handled_message.performative == message_1.performative ), "Message from Agent 1 to 2: performatives do not match" assert ( agent_2_handler.handled_message.content_bytes == message_1.content_bytes ), "Message from Agent 1 to 2: content_bytes do not match" assert ( agent_2_handler.handled_message.content_int == message_1.content_int ), "Message from Agent 1 to 2: content_int do not match" # assert ( # agent_2_handler.handled_message.content_float == message_1.content_float # ), "Message from Agent 1 to 2: content_float do not match" assert ( agent_2_handler.handled_message.content_bool == message_1.content_bool ), "Message from Agent 1 to 2: content_bool do not match" assert ( agent_2_handler.handled_message.content_str == message_1.content_str ), "Message from Agent 1 to 2: content_str do not match" assert ( agent_1_handler.handled_message.message_id == message_2.message_id ), "Message from Agent 1 to 2: dialogue references do not match" assert ( agent_1_handler.handled_message.dialogue_reference == message_2.dialogue_reference ), "Message from Agent 2 to 1: dialogue references do not match" assert ( agent_1_handler.handled_message.dialogue_reference[0] == message_2.dialogue_reference[0] ), "Message from Agent 2 to 1: dialogue reference[0]s do not match" assert ( agent_1_handler.handled_message.dialogue_reference[1] == message_2.dialogue_reference[1] ), "Message from Agent 2 to 1: dialogue reference[1]s do not match" assert ( agent_1_handler.handled_message.target == message_2.target ), "Message from Agent 2 to 1: targets do not match" assert ( agent_1_handler.handled_message.performative == message_2.performative ), "Message from Agent 2 to 1: performatives do not match" assert ( agent_1_handler.handled_message.content_bytes == message_2.content_bytes ), "Message from Agent 2 to 1: content_bytes do not match" assert ( agent_1_handler.handled_message.content_int == message_2.content_int ), "Message from Agent 2 to 1: content_int do not match" # assert ( # agent_1_handler.handled_message.content_float == message_2.content_float # ), "Message from Agent 2 to 1: content_float do not match" assert ( agent_1_handler.handled_message.content_bool == message_2.content_bool ), "Message from Agent 2 to 1: content_bool do not match" assert ( agent_1_handler.handled_message.content_str == message_2.content_str ), "Message from Agent 2 to 1: content_str do not match" time.sleep(2.0) finally: aea_1.stop() aea_2.stop() t_1.join() t_2.join()
def test_generated_protocol_end_to_end(self): """Test that a generated protocol could be used in exchanging messages between two agents.""" agent_name_1 = "my_aea_1" agent_name_2 = "my_aea_2" builder_1 = AEABuilder() builder_1.set_name(agent_name_1) builder_1.add_private_key(DEFAULT_LEDGER, self.private_key_path_1) builder_1.set_default_ledger(DEFAULT_LEDGER) builder_1.set_default_connection(OEF_CONNECTION_PUBLIC_ID) builder_1.add_protocol( Path(ROOT_DIR, "packages", "fetchai", "protocols", "fipa") ) builder_1.add_protocol( Path(ROOT_DIR, "packages", "fetchai", "protocols", "oef_search") ) builder_1.add_component( ComponentType.PROTOCOL, Path(PATH_TO_T_PROTOCOL), skip_consistency_check=True, ) builder_1.add_connection( Path(ROOT_DIR, "packages", "fetchai", "connections", "oef") ) builder_2 = AEABuilder() builder_2.set_name(agent_name_2) builder_2.add_private_key(DEFAULT_LEDGER, self.private_key_path_2) builder_2.set_default_ledger(DEFAULT_LEDGER) builder_2.add_protocol( Path(ROOT_DIR, "packages", "fetchai", "protocols", "fipa") ) builder_2.add_protocol( Path(ROOT_DIR, "packages", "fetchai", "protocols", "oef_search") ) builder_2.set_default_connection(OEF_CONNECTION_PUBLIC_ID) builder_2.add_component( ComponentType.PROTOCOL, Path(PATH_TO_T_PROTOCOL), skip_consistency_check=True, ) builder_2.add_connection( Path(ROOT_DIR, "packages", "fetchai", "connections", "oef") ) # create AEAs aea_1 = builder_1.build(connection_ids=[OEF_CONNECTION_PUBLIC_ID]) aea_2 = builder_2.build(connection_ids=[OEF_CONNECTION_PUBLIC_ID]) # dialogues def role_from_first_message_1( message: Message, receiver_address: Address ) -> BaseDialogue.Role: """Infer the role of the agent from an incoming/outgoing first message :param message: an incoming/outgoing first message :param receiver_address: the address of the receiving agent :return: The role of the agent """ return TProtocolDialogue.Role.ROLE_1 agent_1_dialogues = TProtocolDialogues( self_address=aea_1.identity.address, role_from_first_message=role_from_first_message_1, ) def role_from_first_message_1( message: Message, receiver_address: Address ) -> BaseDialogue.Role: """Infer the role of the agent from an incoming/outgoing first message :param message: an incoming/outgoing first message :param receiver_address: the address of the receiving agent :return: The role of the agent """ return TProtocolDialogue.Role.ROLE_2 agent_2_dialogues = TProtocolDialogues( self_address=aea_2.identity.address, role_from_first_message=role_from_first_message_1, ) # messages message_1, aea_1_dialogue = agent_1_dialogues.create( counterparty=aea_2.identity.address, performative=TProtocolMessage.Performative.PERFORMATIVE_PT, content_bytes=b"some bytes", content_int=42, content_float=42.7, content_bool=True, content_str="some string", ) message_1 = cast(TProtocolMessage, message_1) message_2, aea_2_dialogue = agent_2_dialogues.create( counterparty=aea_1.identity.address, performative=TProtocolMessage.Performative.PERFORMATIVE_PT, content_bytes=b"some other bytes", content_int=43, content_float=43.7, content_bool=False, content_str="some other string", ) message_2 = cast(TProtocolMessage, message_2) # add handlers to AEA resources skill_context_1 = SkillContext(aea_1.context) skill_1 = Skill(SkillConfig("fake_skill", "fetchai", "0.1.0"), skill_context_1) skill_context_1._skill = skill_1 agent_1_handler = Agent1Handler( skill_context=skill_context_1, name="fake_handler_1", dialogues=agent_1_dialogues, ) aea_1.resources._handler_registry.register( ( PublicId.from_str("fetchai/fake_skill:0.1.0"), TProtocolMessage.protocol_id, ), agent_1_handler, ) skill_context_2 = SkillContext(aea_2.context) skill_2 = Skill(SkillConfig("fake_skill", "fetchai", "0.1.0"), skill_context_2) skill_context_2._skill = skill_2 agent_2_handler = Agent2Handler( message=message_2, dialogues=agent_2_dialogues, skill_context=skill_context_2, name="fake_handler_2", ) aea_2.resources._handler_registry.register( ( PublicId.from_str("fetchai/fake_skill:0.1.0"), TProtocolMessage.protocol_id, ), agent_2_handler, ) # Start threads t_1 = Thread(target=aea_1.start) t_2 = Thread(target=aea_2.start) try: t_1.start() t_2.start() time.sleep(1.0) aea_1.outbox.put_message(message_1) time.sleep(5.0) assert ( agent_2_handler.handled_message.message_id == message_1.message_id ), "Message from Agent 1 to 2: message ids do not match" assert ( agent_2_handler.handled_message.dialogue_reference == message_1.dialogue_reference ), "Message from Agent 1 to 2: dialogue references do not match" assert ( agent_2_handler.handled_message.dialogue_reference[0] == message_1.dialogue_reference[0] ), "Message from Agent 1 to 2: dialogue reference[0]s do not match" assert ( agent_2_handler.handled_message.dialogue_reference[1] == message_1.dialogue_reference[1] ), "Message from Agent 1 to 2: dialogue reference[1]s do not match" assert ( agent_2_handler.handled_message.target == message_1.target ), "Message from Agent 1 to 2: targets do not match" assert ( agent_2_handler.handled_message.performative == message_1.performative ), "Message from Agent 1 to 2: performatives do not match" assert ( agent_2_handler.handled_message.content_bytes == message_1.content_bytes ), "Message from Agent 1 to 2: content_bytes do not match" assert ( agent_2_handler.handled_message.content_int == message_1.content_int ), "Message from Agent 1 to 2: content_int do not match" # assert ( # agent_2_handler.handled_message.content_float == message_1.content_float # noqa: E800 # ), "Message from Agent 1 to 2: content_float do not match" assert ( agent_2_handler.handled_message.content_bool == message_1.content_bool ), "Message from Agent 1 to 2: content_bool do not match" assert ( agent_2_handler.handled_message.content_str == message_1.content_str ), "Message from Agent 1 to 2: content_str do not match" assert ( agent_1_handler.handled_message.message_id == message_2.message_id ), "Message from Agent 1 to 2: dialogue references do not match" assert ( agent_1_handler.handled_message.dialogue_reference == message_2.dialogue_reference ), "Message from Agent 2 to 1: dialogue references do not match" assert ( agent_1_handler.handled_message.dialogue_reference[0] == message_2.dialogue_reference[0] ), "Message from Agent 2 to 1: dialogue reference[0]s do not match" assert ( agent_1_handler.handled_message.dialogue_reference[1] == message_2.dialogue_reference[1] ), "Message from Agent 2 to 1: dialogue reference[1]s do not match" assert ( agent_1_handler.handled_message.target == message_2.target ), "Message from Agent 2 to 1: targets do not match" assert ( agent_1_handler.handled_message.performative == message_2.performative ), "Message from Agent 2 to 1: performatives do not match" assert ( agent_1_handler.handled_message.content_bytes == message_2.content_bytes ), "Message from Agent 2 to 1: content_bytes do not match" assert ( agent_1_handler.handled_message.content_int == message_2.content_int ), "Message from Agent 2 to 1: content_int do not match" # assert ( # agent_1_handler.handled_message.content_float == message_2.content_float # noqa: E800 # ), "Message from Agent 2 to 1: content_float do not match" assert ( agent_1_handler.handled_message.content_bool == message_2.content_bool ), "Message from Agent 2 to 1: content_bool do not match" assert ( agent_1_handler.handled_message.content_str == message_2.content_str ), "Message from Agent 2 to 1: content_str do not match" time.sleep(2.0) finally: aea_1.stop() aea_2.stop() t_1.join() t_2.join()
def test_generated_protocol_end_to_end(self): """Test that a generated protocol could be used in exchanging messages between two agents.""" agent_name_1 = "my_aea_1" agent_name_2 = "my_aea_2" builder_1 = AEABuilder() builder_1.set_name(agent_name_1) builder_1.add_private_key(FetchAICrypto.identifier, self.private_key_path_1) builder_1.set_default_ledger(FetchAICrypto.identifier) builder_1.set_default_connection( PublicId.from_str("fetchai/oef:0.3.0")) builder_1.add_protocol( Path(ROOT_DIR, "packages", "fetchai", "protocols", "fipa")) builder_1.add_protocol( Path(ROOT_DIR, "packages", "fetchai", "protocols", "oef_search")) builder_1.add_component( ComponentType.PROTOCOL, Path(ROOT_DIR, "tests", "data", "generator", "t_protocol"), skip_consistency_check=True, ) builder_1.add_connection( Path(ROOT_DIR, "packages", "fetchai", "connections", "oef")) builder_2 = AEABuilder() builder_2.set_name(agent_name_2) builder_2.add_private_key(FetchAICrypto.identifier, self.private_key_path_2) builder_2.set_default_ledger(FetchAICrypto.identifier) builder_2.add_protocol( Path(ROOT_DIR, "packages", "fetchai", "protocols", "fipa")) builder_2.add_protocol( Path(ROOT_DIR, "packages", "fetchai", "protocols", "oef_search")) builder_2.set_default_connection( PublicId.from_str("fetchai/oef:0.3.0")) builder_2.add_component( ComponentType.PROTOCOL, Path(ROOT_DIR, "tests", "data", "generator", "t_protocol"), skip_consistency_check=True, ) builder_2.add_connection( Path(ROOT_DIR, "packages", "fetchai", "connections", "oef")) # create AEAs aea_1 = builder_1.build( connection_ids=[PublicId.from_str("fetchai/oef:0.3.0")]) aea_2 = builder_2.build( connection_ids=[PublicId.from_str("fetchai/oef:0.3.0")]) # message 1 message = TProtocolMessage( message_id=1, dialogue_reference=(str(0), ""), target=0, performative=TProtocolMessage.Performative.PERFORMATIVE_PT, content_bytes=b"some bytes", content_int=42, content_float=42.7, content_bool=True, content_str="some string", ) encoded_message_in_bytes = TProtocolSerializer().encode(message) envelope = Envelope( to=aea_2.identity.address, sender=aea_1.identity.address, protocol_id=TProtocolMessage.protocol_id, message=encoded_message_in_bytes, ) # message 2 message_2 = TProtocolMessage( message_id=2, dialogue_reference=(str(0), ""), target=1, performative=TProtocolMessage.Performative.PERFORMATIVE_PT, content_bytes=b"some other bytes", content_int=43, content_float=43.7, content_bool=False, content_str="some other string", ) encoded_message_2_in_bytes = TProtocolSerializer().encode(message_2) # add handlers to AEA resources] skill_context_1 = SkillContext(aea_1.context) skill_1 = Skill(SkillConfig("fake_skill", "fetchai", "0.1.0"), skill_context_1) skill_context_1._skill = skill_1 agent_1_handler = Agent1Handler(skill_context=skill_context_1, name="fake_handler_1") aea_1.resources._handler_registry.register( ( PublicId.from_str("fetchai/fake_skill:0.1.0"), TProtocolMessage.protocol_id, ), agent_1_handler, ) skill_context_2 = SkillContext(aea_2.context) skill_2 = Skill(SkillConfig("fake_skill", "fetchai", "0.1.0"), skill_context_2) skill_context_2._skill = skill_2 agent_2_handler = Agent2Handler( encoded_messsage=encoded_message_2_in_bytes, skill_context=skill_context_2, name="fake_handler_2", ) aea_2.resources._handler_registry.register( ( PublicId.from_str("fetchai/fake_skill:0.1.0"), TProtocolMessage.protocol_id, ), agent_2_handler, ) # Start threads t_1 = Thread(target=aea_1.start) t_2 = Thread(target=aea_2.start) try: t_1.start() t_2.start() time.sleep(1.0) aea_1.outbox.put(envelope) time.sleep(5.0) assert (agent_2_handler.handled_message.message_id == message.message_id ), "Message from Agent 1 to 2: message ids do not match" assert ( agent_2_handler.handled_message.dialogue_reference == message.dialogue_reference ), "Message from Agent 1 to 2: dialogue references do not match" assert ( agent_2_handler.handled_message.dialogue_reference[0] == message.dialogue_reference[0] ), "Message from Agent 1 to 2: dialogue reference[0]s do not match" assert ( agent_2_handler.handled_message.dialogue_reference[1] == message.dialogue_reference[1] ), "Message from Agent 1 to 2: dialogue reference[1]s do not match" assert (agent_2_handler.handled_message.target == message.target ), "Message from Agent 1 to 2: targets do not match" assert (agent_2_handler.handled_message.performative == message.performative ), "Message from Agent 1 to 2: performatives do not match" assert (agent_2_handler.handled_message.content_bytes == message.content_bytes ), "Message from Agent 1 to 2: content_bytes do not match" assert (agent_2_handler.handled_message.content_int == message.content_int ), "Message from Agent 1 to 2: content_int do not match" # floats do not seem to lose some precision when serialised then deserialised using protobuf # assert agent_2_handler.handled_message.content_float == message.content_float, "Message from Agent 1 to 2: content_float do not match" assert (agent_2_handler.handled_message.content_bool == message.content_bool ), "Message from Agent 1 to 2: content_bool do not match" assert (agent_2_handler.handled_message.content_str == message.content_str ), "Message from Agent 1 to 2: content_str do not match" assert ( agent_1_handler.handled_message.message_id == message_2.message_id ), "Message from Agent 1 to 2: dialogue references do not match" assert ( agent_1_handler.handled_message.dialogue_reference == message_2.dialogue_reference ), "Message from Agent 2 to 1: dialogue references do not match" assert ( agent_1_handler.handled_message.dialogue_reference[0] == message_2.dialogue_reference[0] ), "Message from Agent 2 to 1: dialogue reference[0]s do not match" assert ( agent_1_handler.handled_message.dialogue_reference[1] == message_2.dialogue_reference[1] ), "Message from Agent 2 to 1: dialogue reference[1]s do not match" assert (agent_1_handler.handled_message.target == message_2.target ), "Message from Agent 2 to 1: targets do not match" assert (agent_1_handler.handled_message.performative == message_2.performative ), "Message from Agent 2 to 1: performatives do not match" assert (agent_1_handler.handled_message.content_bytes == message_2.content_bytes ), "Message from Agent 2 to 1: content_bytes do not match" assert (agent_1_handler.handled_message.content_int == message_2.content_int ), "Message from Agent 2 to 1: content_int do not match" # floats do not seem to lose some precision when serialised then deserialised using protobuf # assert agent_1_handler.handled_message.content_float == message_2.content_float, "Message from Agent 2 to 1: content_float do not match" assert (agent_1_handler.handled_message.content_bool == message_2.content_bool ), "Message from Agent 2 to 1: content_bool do not match" assert (agent_1_handler.handled_message.content_str == message_2.content_str ), "Message from Agent 2 to 1: content_str do not match" time.sleep(2.0) finally: aea_1.stop() aea_2.stop() t_1.join() t_2.join()