diff --git a/.gitleaksignore b/.gitleaksignore index 52e02d0..eab77d2 100644 --- a/.gitleaksignore +++ b/.gitleaksignore @@ -1,3 +1,4 @@ +62103cafc6b909a321cbf6139173c3a8580b94b9:packages/balancer/agents/autonomous_fund/aea-config.yaml:generic-api-key:120 8efa33c0e847f2d75bdca1b0cdf5fd134f6b322b:packages/balancer/skills/autonomous_fund_abci/skill.yaml:generic-api-key:81 c5417dfdd2c3aa5d1d7ab05e7ccbcf6d6c6487aa:packages/balancer/skills/pool_manager_abci/skill.yaml:generic-api-key:79 920341fcf1d179421c4afdbbbb4f9d23235023fd:packages/balancer/contracts/managed_pool_controller/tests/helpers/constants.py:generic-api-key:46 diff --git a/packages/balancer/agents/autonomous_fund/__init__.py b/packages/balancer/agents/autonomous_fund/__init__.py index 703259d..11457b2 100644 --- a/packages/balancer/agents/autonomous_fund/__init__.py +++ b/packages/balancer/agents/autonomous_fund/__init__.py @@ -18,3 +18,7 @@ # ------------------------------------------------------------------------------ """Package for balancer/autonomous_fund agent.""" +from pathlib import Path + + +PACKAGE_DIR = Path(__file__).parent diff --git a/packages/balancer/agents/autonomous_fund/aea-config.yaml b/packages/balancer/agents/autonomous_fund/aea-config.yaml index 15f7462..20881b7 100644 --- a/packages/balancer/agents/autonomous_fund/aea-config.yaml +++ b/packages/balancer/agents/autonomous_fund/aea-config.yaml @@ -5,12 +5,16 @@ license: Apache-2.0 description: '' aea_version: '>=1.19.0, <2.0.0' fingerprint: - __init__.py: bafybeialdpvrelsxfu7zh5r5s7tg3gpcz3kc33snhifzdlvjj6rssbzspa + __init__.py: bafybeibzqammkemm5yc5hqjzdnpmgr2aw3j7lwni64rc5c4sf7qsnv7ulu tests/__init__.py: bafybeicmv3jjcqcdnmubfmrgdgeyic3nkm77z4mutsyuo34hpddwupofre tests/helpers/__init__.py: bafybeiauwuw4a4wxqacqqkkk52ktps2qedadhypvh3ex7uqs7qaqrpygmy - tests/helpers/constants.py: bafybeiaxnzow6b6skwz2unt76n4qqz7vlp6sabyqhfqtijsivssh3l6dza - tests/helpers/docker.py: bafybeif6d6ku7ljgmcwfy6ogo7jm2x6mwxkwsp7gb4lbk3xijduui5humi - tests/helpers/fixtures.py: bafybeiayn2dvqkflpaeizlkyhhqk3gagenlqxo3h5etib7hjpv7jq7htiu + tests/helpers/constants.py: bafybeie2nmfhdlrmnrwp2225cxclkw3dd4cxu4uig7hrhtqyg5t7nvfpje + tests/helpers/data/json_server/data.json: bafybeidueptoi7g44hkdrzkyn326l44qhkbt4bsnidrvkn5y3pkgljmuzy + tests/helpers/docker.py: bafybeiaicurt4s7unh362l26wbmetxc7kgl6fwninwfgusrrbyiaozf3hy + tests/helpers/fixtures.py: bafybeiczpplahcqw7zxi76gnefs5jhnhdpxy4box53evmu6j75tw6assny + tests/test_agents/__init__.py: bafybeicmv3jjcqcdnmubfmrgdgeyic3nkm77z4mutsyuo34hpddwupofre + tests/test_agents/base.py: bafybeig7o56fgyhggurr5tmdfntdwrfh73dalxemlphgdrvfyo6klrjy7i + tests/test_agents/test_autonomous_fund.py: bafybeiap4dwh6o2u37njx6msg7rzbxp5enwqmrks5kwzzwzj6xtmjyjnja tests/test_contracts/__init__.py: bafybeiel4den34ewkgjdlze2gdw5veayz3xtnnii4tfznjltpq33nsssda tests/test_contracts/test_managed_pool_controller/__init__.py: bafybeid3fa64f4rskt4tf6hfjxqzid2o5dopuh2f53aegclg6fj5ylso5i tests/test_contracts/test_managed_pool_controller/test_contract.py: bafybeigp42gxwkeyb3vtmh4oi7kjc7nv2xx3vakyv5qpajqb3mhxxxxyce @@ -28,7 +32,7 @@ contracts: protocols: - open_aea/signing:1.0.0:bafybeiambqptflge33eemdhis2whik67hjplfnqwieoa6wblzlaf7vuo44 skills: -- balancer/autonomous_fund_abci:0.1.0:bafybeifx2x3g3dhlq3clq2irf5ciqsj2gadyyelfhop7mlfiwj2yx5xri4 +- balancer/autonomous_fund_abci:0.1.0:bafybeie5tls5ppxzuqfny2kdzvxqjy3zpa75ylcngjqnlnjccbfra5tafm - balancer/fear_and_greed_oracle_abci:0.1.0:bafybeicmttoiyfvh2usfyrsuog475rkxoszb3ymh6ue3lnsc3p6q4aky6q - balancer/pool_manager_abci:0.1.0:bafybeihb5jzxuf7piv44v6ovhxvg222uwf7ke3y6bjxl7jipszqd7ay2bm - valory/abstract_abci:0.1.0:bafybeigqbgoej3zhsz6e5ibdu5tewv6plh4yzxllguyftbymj5bp2zaxyq @@ -44,8 +48,27 @@ default_routing: {} connection_private_key_paths: {} private_key_paths: {} logging_config: - disable_existing_loggers: false version: 1 + disable_existing_loggers: false + formatters: + standard: + format: '[%(asctime)s] [%(levelname)s] %(message)s' + handlers: + logfile: + class: logging.FileHandler + formatter: standard + filename: ${LOG_FILE:str:log.txt} + level: INFO + console: + class: logging.StreamHandler + formatter: standard + stream: ext://sys.stdout + loggers: + aea: + handlers: + - logfile + - console + propagate: false dependencies: open-aea-ledger-ethereum: {} default_connection: null @@ -83,3 +106,76 @@ cert_requests: public_key: ${P2P_PUBLIC_KEY:str:0250827315351f6f4d3777b77d4bfd67280156240313bf221750b36404344bb35d} save_path: .certs/acn_cosmos_9005.txt is_abstract: true +--- +public_id: balancer/autonomous_fund_abci:0.1.0 +type: skill +models: + params: + args: + cleanup_history_depth: 1 + cleanup_history_depth_current: null + consensus: + max_participants: 1 + drand_public_key: 868f005eb8e6e4ca0a47c8a77ceaa5309a47978a7c71bc5cce96366b5d7a569937c529eeda66c7293784a9402801af31 + fear_and_greed_endpoint: https://api.alternative.me/fng/?format=json + fear_and_greed_num_points: 2 + finalize_timeout: 60.0 + genesis_config: + genesis_time: '2022-09-26T00:00:00.000000000Z' + chain_id: chain-c4daS1 + consensus_params: + block: + max_bytes: '22020096' + max_gas: '-1' + time_iota_ms: '1000' + evidence: + max_age_num_blocks: '100000' + max_age_duration: '172800000000000' + max_bytes: '1048576' + validator: + pub_key_types: + - ed25519 + version: {} + voting_power: '10' + history_check_timeout: 1205 + keeper_allowed_retries: 3 + keeper_timeout: 30.0 + managed_pool_controller_address: '0xb821BFfE924E18F8B3d92473C5279d60F0Dfc6eA' + max_healthcheck: 120 + max_index_change: 0.00040509259 + max_index_value: 100 + min_index_value: 0 + observation_aggregator_function: median + observation_interval: 10 + on_chain_service_id: null + pool_weights: + 0: + - 60 + - 30 + - 10 + 41: + - 33 + - 33 + - 34 + 60: + - 10 + - 30 + - 60 + reset_tendermint_after: 2 + retry_attempts: 400 + retry_timeout: 3 + round_timeout_seconds: 30.0 + service_id: pool_manager + service_registry_address: null + setup: + safe_contract_address: + - '0x8001bdCf80F8Fb61CdcDA48419A30b430B385ca1' + sleep_time: 1 + tendermint_check_sleep_delay: 3 + tendermint_com_url: http://localhost:8080 + tendermint_max_retries: 5 + tendermint_url: http://localhost:26657 + validate_timeout: 1205 + weight_tolerance: 0.1 + weight_update_timespan: 72000 + weighted_pool_address: '0x28BF8d29cFA99aE9C3D876210453272f30e4D131' diff --git a/packages/balancer/agents/autonomous_fund/tests/helpers/constants.py b/packages/balancer/agents/autonomous_fund/tests/helpers/constants.py index eab3cc8..932801a 100644 --- a/packages/balancer/agents/autonomous_fund/tests/helpers/constants.py +++ b/packages/balancer/agents/autonomous_fund/tests/helpers/constants.py @@ -52,5 +52,7 @@ WEIGHTED_POOL = "0x28BF8d29cFA99aE9C3D876210453272f30e4D131" INITIAL_POOL_WEIGHTS = [30, 40, 30] # scaled on 0-100 -# this safe contract is configured with the accounts above, and has the threshold set at 3/4. -CONFIGURED_SAFE_INSTANCE = "0x5564550A54EcD43bA8f7c666fff1C4762889A572" +# this safe contract is configured with the accounts above, and has the threshold set at 1/4. +CONFIGURED_SAFE_INSTANCE = "0x8001bdCf80F8Fb61CdcDA48419A30b430B385ca1" + +MOCK_API_PATH = "/fng?format=json" diff --git a/packages/balancer/agents/autonomous_fund/tests/helpers/data/json_server/data.json b/packages/balancer/agents/autonomous_fund/tests/helpers/data/json_server/data.json new file mode 100644 index 0000000..682e573 --- /dev/null +++ b/packages/balancer/agents/autonomous_fund/tests/helpers/data/json_server/data.json @@ -0,0 +1,23 @@ +{ + "/fng": { + "get": { + "name": "Fear and Greed Index", + "data": [ + { + "value": "22", + "value_classification": "Extreme Fear", + "timestamp": "1665360000", + "time_until_update": "33681" + }, + { + "value": "22", + "value_classification": "Extreme Fear", + "timestamp": "1665273600" + } + ], + "metadata": { + "error": null + } + } + } +} \ No newline at end of file diff --git a/packages/balancer/agents/autonomous_fund/tests/helpers/docker.py b/packages/balancer/agents/autonomous_fund/tests/helpers/docker.py index 55864d0..804100b 100644 --- a/packages/balancer/agents/autonomous_fund/tests/helpers/docker.py +++ b/packages/balancer/agents/autonomous_fund/tests/helpers/docker.py @@ -21,6 +21,7 @@ """Autonomous Fund Contracts Docker image.""" import logging import time +from pathlib import Path from typing import Dict, List import docker @@ -29,6 +30,7 @@ from aea_test_autonomy.docker.base import DockerImage from docker.models.containers import Container +from packages.balancer.agents.autonomous_fund import PACKAGE_DIR from packages.balancer.agents.autonomous_fund.tests.helpers.constants import ( MANAGED_POOL_CONTROLLER, ) @@ -120,3 +122,76 @@ def wait(self, max_attempts: int = 15, sleep_rate: float = 1.0) -> bool: ) time.sleep(sleep_rate) return False + + +DEFAULT_JSON_SERVER_ADDR = "http://127.0.0.1" +DEFAULT_JSON_SERVER_PORT = 3000 +DEFAULT_JSON_DATA_DIR = ( + PACKAGE_DIR / "tests" / "helpers" / "data" / "json_server" / "data.json" +) + + +class MockFearAndGreedApi(DockerImage): + """Spawn a JSON server to for mocking the Fear and Greed API.""" + + def __init__( + self, + client: docker.DockerClient, + addr: str = DEFAULT_JSON_SERVER_ADDR, + port: int = DEFAULT_JSON_SERVER_PORT, + json_data: Path = DEFAULT_JSON_DATA_DIR, + ): + """Initialize.""" + super().__init__(client) + self.addr = addr + self.port = port + self.json_data = json_data + + def create_many(self, nb_containers: int) -> List[Container]: + """Instantiate the image in many containers, parametrized.""" + raise NotImplementedError() + + @property + def tag(self) -> str: + """Get the tag.""" + return "ajoelpod/mock-json-server:latest" + + def create(self) -> Container: + """Create the container.""" + data = "/usr/src/app/data.json" + volumes = { + str(self.json_data): { + "bind": data, + "mode": "rw", + }, + } + ports = {"8000/tcp": ("0.0.0.0", self.port)} # nosec + container = self._client.containers.run( + self.tag, + detach=True, + ports=ports, + volumes=volumes, + extra_hosts={"host.docker.internal": "host-gateway"}, + ) + return container + + def wait(self, max_attempts: int = 15, sleep_rate: float = 1.0) -> bool: + """ + Wait until the image is running. + + :param max_attempts: max number of attempts. + :param sleep_rate: the amount of time to sleep between different requests. + :return: True if the wait was successful, False otherwise. + """ + for i in range(max_attempts): + try: + response = requests.get(f"{self.addr}:{self.port}") + enforce(response.status_code == 200, "") + return True + except Exception as e: # pylint: disable=broad-except + logging.error("Exception: %s: %s", type(e).__name__, str(e)) + logging.info( + "Attempt %s failed. Retrying in %s seconds...", i, sleep_rate + ) + time.sleep(sleep_rate) + return False diff --git a/packages/balancer/agents/autonomous_fund/tests/helpers/fixtures.py b/packages/balancer/agents/autonomous_fund/tests/helpers/fixtures.py index 014c783..3f23a3e 100644 --- a/packages/balancer/agents/autonomous_fund/tests/helpers/fixtures.py +++ b/packages/balancer/agents/autonomous_fund/tests/helpers/fixtures.py @@ -31,6 +31,9 @@ AutonomousFundNetworkDockerImage, DEFAULT_HARDHAT_ADDR, DEFAULT_HARDHAT_PORT, + DEFAULT_JSON_SERVER_ADDR, + DEFAULT_JSON_SERVER_PORT, + MockFearAndGreedApi, ) @@ -62,3 +65,28 @@ def _start_network( use_safe_contracts=cls.USE_SAFE_CONTRACTS, ) yield from launch_image(image, timeout=timeout, max_attempts=max_attempts) + + +@pytest.mark.integration +class UseMockFearAndGreedApiBaseTest: # pylint: disable=too-few-public-methods + """Inherit from this class to use a mock Fear and Greed API.""" + + MOCK_API_ADDRESS = DEFAULT_JSON_SERVER_ADDR + MOCK_API_PORT = DEFAULT_JSON_SERVER_PORT + + @classmethod + @pytest.fixture(autouse=True) + def _start_mock_api( + cls, + timeout: int = 3, + max_attempts: int = 200, + ) -> Generator: + """Start a Fear and Greed API instance.""" + client = docker.from_env() + logging.info(f"Launching the Fear and Greed API on port {cls.MOCK_API_PORT}") + image = MockFearAndGreedApi( + client, + addr=cls.MOCK_API_ADDRESS, + port=cls.MOCK_API_PORT, + ) + yield from launch_image(image, timeout=timeout, max_attempts=max_attempts) diff --git a/packages/balancer/agents/autonomous_fund/tests/test_agents/__init__.py b/packages/balancer/agents/autonomous_fund/tests/test_agents/__init__.py new file mode 100644 index 0000000..360d5a7 --- /dev/null +++ b/packages/balancer/agents/autonomous_fund/tests/test_agents/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2022 Valory AG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ + +"""Tests package for balancer/autonomous_fund agent.""" diff --git a/packages/balancer/agents/autonomous_fund/tests/test_agents/base.py b/packages/balancer/agents/autonomous_fund/tests/test_agents/base.py new file mode 100644 index 0000000..2c3795c --- /dev/null +++ b/packages/balancer/agents/autonomous_fund/tests/test_agents/base.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2021-2022 Valory AG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ +# pylint: disable=broad-except,unspecified-encoding,import-error,redefined-outer-name + +"""End2End tests base classes for the Autonomous Fund.""" + +from aea.configurations.base import PublicId +from aea_test_autonomy.base_test_classes.agents import BaseTestEnd2End + +from packages.balancer.agents.autonomous_fund.tests.helpers.constants import ( + CONFIGURED_SAFE_INSTANCE as _DEFAULT_SAFE_CONTRACT_ADDRESS, +) +from packages.balancer.agents.autonomous_fund.tests.helpers.constants import ( + DEFAULT_CALLBACK_HANDLER as _DEFAULT_SAFE_CALLBACK_HANDLER_ADDRESS, +) +from packages.balancer.agents.autonomous_fund.tests.helpers.constants import ( + MANAGED_POOL_CONTROLLER as _DEFAULT_MANAGED_POOL_CONTROLLER_ADDRESS, +) +from packages.balancer.agents.autonomous_fund.tests.helpers.constants import ( + MOCK_API_PATH as _DEFAULT_MOCK_API_PATH, +) +from packages.balancer.agents.autonomous_fund.tests.helpers.constants import ( + WEIGHTED_POOL as _DEFAULT_WEIGHTED_POOL_ADDRESS, +) +from packages.balancer.agents.autonomous_fund.tests.helpers.docker import ( + DEFAULT_JSON_SERVER_ADDR as _DEFAULT_JSON_SERVER_ADDR, +) +from packages.balancer.agents.autonomous_fund.tests.helpers.docker import ( + DEFAULT_JSON_SERVER_PORT as _DEFAULT_JSON_SERVER_PORT, +) + + +class BaseTestAutonomousFundEnd2End( + BaseTestEnd2End +): # pylint: disable=too-few-public-methods + """ + Extended base class for conducting E2E tests with the Autonomous Fund. + + Test subclasses must set NB_AGENTS, agent_package, wait_to_finish and check_strings. + """ + + cli_log_options = ["-v", "INFO"] # no need for debug + skill_package = "balancer/autonomous_fund_abci:0.1.0" + + # mock Fear and Greed API constants + MOCK_API_ADDRESS = _DEFAULT_JSON_SERVER_ADDR + MOCK_API_PORT = _DEFAULT_JSON_SERVER_PORT + MOCK_API_PATH = _DEFAULT_MOCK_API_PATH + + # contract related constants + SAFE_CALLBACK_HANDLER = _DEFAULT_SAFE_CALLBACK_HANDLER_ADDRESS + SAFE_CONTRACT_ADDRESS = _DEFAULT_SAFE_CONTRACT_ADDRESS + MANAGED_POOL_CONTROLLER_ADDRESS = _DEFAULT_MANAGED_POOL_CONTROLLER_ADDRESS + WEIGHTED_POOL_ADDRESS = _DEFAULT_WEIGHTED_POOL_ADDRESS + + __args_prefix = f"vendor.balancer.skills.{PublicId.from_str(skill_package).name}.models.params.args" + extra_configs = [ + { + "dotted_path": f"{__args_prefix}.managed_pool_controller_address", + "value": MANAGED_POOL_CONTROLLER_ADDRESS, + }, + { + "dotted_path": f"{__args_prefix}.weighted_pool_address", + "value": WEIGHTED_POOL_ADDRESS, + }, + { + "dotted_path": f"{__args_prefix}.fear_and_greed_endpoint", + "value": f"{MOCK_API_ADDRESS}:{MOCK_API_PORT}{MOCK_API_PATH}", + }, + ] + + def test_run(self, nb_nodes: int) -> None: + """Run the test.""" + self.prepare_and_launch(nb_nodes) + self.health_check( + max_retries=self.HEALTH_CHECK_MAX_RETRIES, + sleep_interval=self.HEALTH_CHECK_SLEEP_INTERVAL, + ) + self.check_aea_messages() + self.terminate_processes() diff --git a/packages/balancer/agents/autonomous_fund/tests/test_agents/test_autonomous_fund.py b/packages/balancer/agents/autonomous_fund/tests/test_agents/test_autonomous_fund.py new file mode 100644 index 0000000..c87c650 --- /dev/null +++ b/packages/balancer/agents/autonomous_fund/tests/test_agents/test_autonomous_fund.py @@ -0,0 +1,170 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2021-2022 Valory AG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ +# pylint: skip-file +# mypy: ignore-errors +# flake8: noqa + +"""End-to-End tests for the balancer/autonomous_fund agent.""" + +import pytest +from aea_test_autonomy.fixture_helpers import ( # noqa: F401 + abci_host, + abci_port, + flask_tendermint, + tendermint_port, +) + +from packages.balancer.agents.autonomous_fund.tests.helpers.fixtures import ( + UseHardHatAutoFundBaseTest, + UseMockFearAndGreedApiBaseTest, +) +from packages.balancer.agents.autonomous_fund.tests.test_agents.base import ( + BaseTestAutonomousFundEnd2End, +) + + +TIME_TO_FINISH = 60 # 1 minute +TARGET_AGENT = "balancer/autonomous_fund:0.1.0" +TARGET_SKILL = "balancer/autonomous_fund_abci:0.1.0" + +REGISTRATION_CHECK_STRINGS = ( + "Entered in the 'registration_startup' round for period 0", + "'registration_startup' round is done", +) + +_expected_api_response = ( + '[{"timestamp": 1665360000, "value": 22}, {"timestamp": 1665273600, "value": 22}]' +) +_expected_outlier_status = '{"status": "outlier_not_detected"}' +FEAR_AND_GREED_ORACLE_STRINGS = ( + "Entered in the 'collect_observation' round for period 0", + f"Received data from Fear and Greed API: {_expected_api_response}", + "Entered in the 'estimation_round' round for period 0", + "Estimated Fear and Greed Index values to be ", + "Entered in the 'outlier_detection_round' round for period 0", + f"Outlier detection status: {_expected_outlier_status}", +) + +_expected_update_weights_decision = '{"weights": [60, 30, 10]}' +POOL_MANAGER_STRINGS = ( + "Entered in the 'decision_making' round for period 0", + f"Updated weights decision: {_expected_update_weights_decision}", + "Entered in the 'update_pool_tx' round for period 0", + "Prepared safe tx:", +) + +TRANSACTION_SUBMISSION_STRINGS = ( + "Entered in the 'validate_transaction' round for period 0", + "Verified result: True", +) + +RESET_STRINGS = ( + "Entered in the 'reset_and_pause' round for period 0", + "Period end.", +) + + +@pytest.mark.parametrize("nb_nodes", (1,)) +class TestAutonomousFundSingleAgent( + BaseTestAutonomousFundEnd2End, + UseMockFearAndGreedApiBaseTest, + UseHardHatAutoFundBaseTest, +): + """ + Test the Autonomous Fund through the happy path, when using a single agent. + + By running this test, we spawn up a single agent service, along with the external dependencies: + - tendermint + - a hardhat network + - a mock Fear and Greed API server + The test firstly takes care of the setting up the dependencies, and then runs the service. + The test passes if the agent produces all the logs in specified in `strict_check_strings`. + """ + + agent_package = TARGET_AGENT + skill_package = TARGET_SKILL + wait_to_finish = TIME_TO_FINISH + strict_check_strings = ( + REGISTRATION_CHECK_STRINGS + + FEAR_AND_GREED_ORACLE_STRINGS + + POOL_MANAGER_STRINGS + + TRANSACTION_SUBMISSION_STRINGS + + RESET_STRINGS + ) + use_benchmarks = True + + +@pytest.mark.parametrize("nb_nodes", (2,)) +class TestAutonomousFundTwoAgents( + BaseTestAutonomousFundEnd2End, + UseMockFearAndGreedApiBaseTest, + UseHardHatAutoFundBaseTest, +): + """ + Test the Autonomous Fund through the "happy path", when using two agents. + + By running this test, we spawn up a single agent service, along with the external dependencies: + - tendermint + - a hardhat network + - a mock Fear and Greed API server + The test firstly takes care of the setting up the dependencies, and then runs the service. + The test passes if both agents produce all the logs in specified in `strict_check_strings`. + """ + + agent_package = TARGET_AGENT + skill_package = TARGET_SKILL + wait_to_finish = TIME_TO_FINISH + strict_check_strings = ( + REGISTRATION_CHECK_STRINGS + + FEAR_AND_GREED_ORACLE_STRINGS + + POOL_MANAGER_STRINGS + + TRANSACTION_SUBMISSION_STRINGS + + RESET_STRINGS + ) + use_benchmarks = True + + +@pytest.mark.parametrize("nb_nodes", (4,)) +class TestAutonomousFundFourAgents( + BaseTestAutonomousFundEnd2End, + UseMockFearAndGreedApiBaseTest, + UseHardHatAutoFundBaseTest, +): + """ + Test the Autonomous Fund through the "happy path", when using 4 agents. + + By running this test, we spawn up a single agent service, along with the external dependencies: + - tendermint + - a hardhat network + - a mock Fear and Greed API server + The test firstly takes care of the setting up the dependencies, and then runs the service. + The test passes if all 4 agents produce all the logs in specified in `strict_check_strings`. + """ + + agent_package = TARGET_AGENT + skill_package = TARGET_SKILL + wait_to_finish = TIME_TO_FINISH + strict_check_strings = ( + REGISTRATION_CHECK_STRINGS + + FEAR_AND_GREED_ORACLE_STRINGS + + POOL_MANAGER_STRINGS + + TRANSACTION_SUBMISSION_STRINGS + + RESET_STRINGS + ) + use_benchmarks = True diff --git a/packages/balancer/skills/autonomous_fund_abci/__init__.py b/packages/balancer/skills/autonomous_fund_abci/__init__.py index efdf16c..1dfa8fe 100644 --- a/packages/balancer/skills/autonomous_fund_abci/__init__.py +++ b/packages/balancer/skills/autonomous_fund_abci/__init__.py @@ -22,4 +22,4 @@ from aea.configurations.base import PublicId -PUBLIC_ID = PublicId.from_str("balancer/autonomous_fund:0.1.0") +PUBLIC_ID = PublicId.from_str("balancer/autonomous_fund_abci:0.1.0") diff --git a/packages/balancer/skills/autonomous_fund_abci/skill.yaml b/packages/balancer/skills/autonomous_fund_abci/skill.yaml index 67c147e..013c365 100644 --- a/packages/balancer/skills/autonomous_fund_abci/skill.yaml +++ b/packages/balancer/skills/autonomous_fund_abci/skill.yaml @@ -6,7 +6,7 @@ description: The chained abci for the Autonomous Fund. license: Apache-2.0 aea_version: '>=1.0.0, <2.0.0' fingerprint: - __init__.py: bafybeifre2uvlsm3xo5hn6vhasc23nvn4fv3hy2drygmtivpfpnec7itiy + __init__.py: bafybeifx6ihh7vz7pp3swpfbxgp4fmspjshmu2ksua3w5yo5jdcleq2yhm behaviours.py: bafybeihf3byvmvpoeq4qvwpky2muji2vdl3r2mlizl3cpvm66kpsnjkvoa composition.py: bafybeiebupr7hdkh5c77ouaetlp4u3wdhfysn4jysulaztdxgenmpzjyx4 dialogues.py: bafybeih3x4egnkh7xwnlawqbu6fpqyqbaum7ivdhqm6r6557dyy2rhzneq diff --git a/packages/packages.json b/packages/packages.json index 9007d8d..8965564 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -23,7 +23,7 @@ "skill/valory/registration_abci/0.1.0": "bafybeie7lxe5spcitc7pwfilapsu5wlictp4ibz7gbko5yg3nx6llcjisu", "skill/valory/reset_pause_abci/0.1.0": "bafybeiamkbck2c35uc6h7c6sotmsobr7h6tc2vzskoxztlu7o6af6mcacm", "skill/valory/safe_deployment_abci/0.1.0": "bafybeifgljjbc2x42xcynmirchrno7iwwq6ufnhpqr37ypeoqstfnjujli", - "skill/balancer/autonomous_fund_abci/0.1.0": "bafybeifx2x3g3dhlq3clq2irf5ciqsj2gadyyelfhop7mlfiwj2yx5xri4", - "agent/balancer/autonomous_fund/0.1.0": "bafybeifklwopxhqe3e4cmq6hnjovocwrfcqlsctyjy7l42m6tpkrwjiuja", + "skill/balancer/autonomous_fund_abci/0.1.0": "bafybeie5tls5ppxzuqfny2kdzvxqjy3zpa75ylcngjqnlnjccbfra5tafm", + "agent/balancer/autonomous_fund/0.1.0": "bafybeicqqybrt64mary2vnsygbxgybfdzmldten5rhjngnntjkl5v6ffwm", "contract/valory/multisend/0.1.0": "bafybeig45676hbh4c3p3mujrrskxgxww4cxdyyginlg5rmmav6orv4gtya" } \ No newline at end of file