diff --git a/docs/package_list.md b/docs/package_list.md index 8f4278bc35..16d55d764c 100644 --- a/docs/package_list.md +++ b/docs/package_list.md @@ -21,7 +21,7 @@ | connection/valory/p2p_libp2p_mailbox/0.1.0 | `bafybeiecclc65ogngs3piaxpwhiyl77mlpqun5ejlyv4kamwzrrh746guq` | | connection/fetchai/local/0.20.0 | `bafybeiema4rnxi54luhzbrccb27pfrwlohemka45eqf4nidgmtkwwmxeyi` | | connection/valory/http_client/0.23.0 | `bafybeihi772xgzpqeipp3fhmvpct4y6e6tpjp4sogwqrnf3wqspgeilg4u` | -| connection/valory/test_libp2p/0.1.0 | `bafybeial7uzniyiuwpe4h2emzipaheuqzpsyr5hnwthpk7m4rb267wzwpa` | +| connection/valory/test_libp2p/0.1.0 | `bafybeigoeurcepbax7jju6def3ebshctelivsc7fwjevnwpi2hlmqxxn3u` | | skill/fetchai/echo/0.19.0 | `bafybeicoawiackcbgqo3na3e56tpdc62atag4yxknur77py37caqq4mmya` | | skill/fetchai/error_test_skill/0.1.0 | `bafybeihsbtlpe7h6fsvoxban5rilkmwviwkokul5cqym6atoolirontiyu` | | skill/fetchai/gym/0.20.0 | `bafybeie7y2fsxfuhsqxqcaluo5exskmrm5q3a6e2hfcskcuvzvxjjhijh4` | diff --git a/packages/packages.json b/packages/packages.json index 6d48448ae6..91768d33db 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -21,7 +21,7 @@ "connection/valory/p2p_libp2p_mailbox/0.1.0": "bafybeiecclc65ogngs3piaxpwhiyl77mlpqun5ejlyv4kamwzrrh746guq", "connection/fetchai/local/0.20.0": "bafybeiema4rnxi54luhzbrccb27pfrwlohemka45eqf4nidgmtkwwmxeyi", "connection/valory/http_client/0.23.0": "bafybeihi772xgzpqeipp3fhmvpct4y6e6tpjp4sogwqrnf3wqspgeilg4u", - "connection/valory/test_libp2p/0.1.0": "bafybeiefuha46oyekz255vjq2szjxv563hfjiner44v7u3g55yatuqzcly", + "connection/valory/test_libp2p/0.1.0": "bafybeigoeurcepbax7jju6def3ebshctelivsc7fwjevnwpi2hlmqxxn3u", "skill/fetchai/echo/0.19.0": "bafybeicoawiackcbgqo3na3e56tpdc62atag4yxknur77py37caqq4mmya", "skill/fetchai/error_test_skill/0.1.0": "bafybeihsbtlpe7h6fsvoxban5rilkmwviwkokul5cqym6atoolirontiyu", "skill/fetchai/gym/0.20.0": "bafybeie7y2fsxfuhsqxqcaluo5exskmrm5q3a6e2hfcskcuvzvxjjhijh4", diff --git a/packages/valory/connections/test_libp2p/connection.yaml b/packages/valory/connections/test_libp2p/connection.yaml index 077c7c772e..be1dd16b33 100644 --- a/packages/valory/connections/test_libp2p/connection.yaml +++ b/packages/valory/connections/test_libp2p/connection.yaml @@ -26,11 +26,11 @@ fingerprint: tests/test_p2p_libp2p_client/__init__.py: bafybeihjzl7ireo5rbnxcdbghbncykgcgcbh26m4mjjofsseeflauuf6sy tests/test_p2p_libp2p_client/test_aea_cli.py: bafybeie5yaezltj4xydnqghltt7f2t4vicdts5rm6bz4fdpt4kkkd42cyu tests/test_p2p_libp2p_client/test_communication.py: bafybeiceec5zsd2u37t56oiajijgwx7frpo3wzu4qdfd3lcq3lcldyqszq - tests/test_p2p_libp2p_client/test_errors.py: bafybeidk7g4tucudqfafwgio7hpdgsz4gexh5lwvdrnpttnd6lt3ak4t7u + tests/test_p2p_libp2p_client/test_errors.py: bafybeihopjaixftexdru35rxf75tr45itr6ygoao2ajxax3jvq6mcopw6m tests/test_p2p_libp2p_mailbox/__init__.py: bafybeiad64wftnugaahubhqc6bcqzg7om4435dzojdv7oeq4zdmn7kxzui tests/test_p2p_libp2p_mailbox/test_aea_cli.py: bafybeievjaiacpvcpabemtrmmeejbf4cbkrqzhu2ekxzyfyeg42ityxn5q tests/test_p2p_libp2p_mailbox/test_communication.py: bafybeiaiwlqxuzp34nu33s5pz6sudvwmdi3h2ckfa4mmwyvd6wqn2elo4m - tests/test_p2p_libp2p_mailbox/test_errors.py: bafybeiampgm6dxpo4tqiyhyhpwr5d3kdsq5x5vwl323oauhdzmsnprf4bi + tests/test_p2p_libp2p_mailbox/test_errors.py: bafybeie2t3zjjjjbyfd3lno2f6p4fa6jdttq2gluwfe5mmny5g6r5zp2oi tests/test_p2p_libp2p_mailbox/test_mailbox_service.py: bafybeibp3bkwkrw57qahvuysjdlumywtlk3te5gsvusgrvhsc75k7rrk4u fingerprint_ignore_patterns: [] connections: diff --git a/packages/valory/connections/test_libp2p/tests/test_p2p_libp2p_client/test_errors.py b/packages/valory/connections/test_libp2p/tests/test_p2p_libp2p_client/test_errors.py index 6b8f1340b4..68b92f08f1 100644 --- a/packages/valory/connections/test_libp2p/tests/test_p2p_libp2p_client/test_errors.py +++ b/packages/valory/connections/test_libp2p/tests/test_p2p_libp2p_client/test_errors.py @@ -109,9 +109,8 @@ async def test_reconnect_on_send_fail(self): ) as connect_mock, patch.object( self.connection, "_ensure_valid_envelope_for_external_comms" ): - with pytest.raises(Exception, match="oops"): - await self.connection._send_envelope_with_node_client(Mock()) - connect_mock.assert_called() + await self.connection._send_envelope_with_node_client(Mock()) + connect_mock.assert_called() @pytest.mark.asyncio diff --git a/packages/valory/connections/test_libp2p/tests/test_p2p_libp2p_mailbox/test_errors.py b/packages/valory/connections/test_libp2p/tests/test_p2p_libp2p_mailbox/test_errors.py index a15442b147..9c90e2b234 100644 --- a/packages/valory/connections/test_libp2p/tests/test_p2p_libp2p_mailbox/test_errors.py +++ b/packages/valory/connections/test_libp2p/tests/test_p2p_libp2p_mailbox/test_errors.py @@ -19,8 +19,7 @@ # ------------------------------------------------------------------------------ """This test module contains negative tests for Libp2p tcp client connection.""" - -# pylint: skip-file +from unittest.mock import Mock, patch import pytest @@ -31,6 +30,9 @@ BaseP2PLibp2pTest, _make_libp2p_mailbox_connection, ) +from packages.valory.connections.test_libp2p.tests.test_p2p_libp2p_client.test_errors import ( + DONE_FUTURE, +) from packages.valory.connections.test_libp2p.tests.test_p2p_libp2p_client.test_errors import ( TestLibp2pClientConnectionFailureConnectionSetup as BaseFailureConnectionSetup, ) @@ -39,6 +41,9 @@ ) +# pylint: skip-file + + @pytest.mark.asyncio class TestLibp2pMailboxConnectionFailureNodeNotConnected(BaseFailureNodeNotConnected): """Test that connection fails when node not running""" @@ -48,6 +53,21 @@ class TestLibp2pMailboxConnectionFailureNodeNotConnected(BaseFailureNodeNotConne # overwrite, no mailbox equivalent of P2PLibp2pClientConnection (TCPSocketChannelClient) test_connect_attempts = None + @pytest.mark.asyncio + async def test_reconnect_on_send_fail(self): + """Test reconnect on send fails.""" + + self.connection._node_client = Mock() + self.connection._node_client.send_envelope.side_effect = Exception("oops") + with patch.object( + self.connection, "_perform_connection_to_node", return_value=DONE_FUTURE + ) as connect_mock, patch.object( + self.connection, "_ensure_valid_envelope_for_external_comms" + ): + with pytest.raises(Exception, match="oops"): + await self.connection._send_envelope_with_node_client(Mock()) + connect_mock.assert_called() + class TestLibp2pMailboxConnectionFailureConnectionSetup(BaseFailureConnectionSetup): """Test that connection fails when setup incorrectly"""