diff --git a/gltest_cli/config/constants.py b/gltest_cli/config/constants.py index bd9197a..d047b76 100644 --- a/gltest_cli/config/constants.py +++ b/gltest_cli/config/constants.py @@ -4,8 +4,8 @@ GLTEST_CONFIG_FILE = "gltest.config.yaml" DEFAULT_NETWORK = "localnet" -PRECONFIGURED_NETWORKS = ["localnet", "studionet", "testnet_asimov"] -CHAINS = ["localnet", "studionet", "testnet_asimov"] +PRECONFIGURED_NETWORKS = ["localnet", "studionet", "testnet_asimov", "testnet_bradbury"] +CHAINS = ["localnet", "studionet", "testnet_asimov", "testnet_bradbury"] DEFAULT_RPC_URL = SIMULATOR_JSON_RPC_URL DEFAULT_ENVIRONMENT = ".env" DEFAULT_CONTRACTS_DIR = Path("contracts") diff --git a/gltest_cli/config/plugin.py b/gltest_cli/config/plugin.py index 35fd838..c723246 100644 --- a/gltest_cli/config/plugin.py +++ b/gltest_cli/config/plugin.py @@ -89,10 +89,10 @@ def pytest_configure(config): ) user_config = get_default_user_config() - # Special handling for testnet_asimov - check if accounts are configured - if network_name == "testnet_asimov": + # Special handling for remote testnets - check if accounts are configured + if network_name in ("testnet_asimov", "testnet_bradbury"): logger.error( - "For testnet_asimov, you need to configure accounts in gltest.config.yaml, see https://docs.genlayer.com/api-references/genlayer-test" + f"For {network_name}, you need to configure accounts in gltest.config.yaml, see https://docs.genlayer.com/api-references/genlayer-test" ) pytest.exit("gltest configuration error") else: diff --git a/gltest_cli/config/types.py b/gltest_cli/config/types.py index c525d41..3f414a6 100644 --- a/gltest_cli/config/types.py +++ b/gltest_cli/config/types.py @@ -1,7 +1,7 @@ from dataclasses import dataclass, field from pathlib import Path from typing import Dict, List, Optional -from genlayer_py.chains import localnet, studionet, testnet_asimov +from genlayer_py.chains import localnet, studionet, testnet_asimov, testnet_bradbury from genlayer_py.types import GenLayerChain from gltest_cli.config.constants import PRECONFIGURED_NETWORKS from gltest_cli.config.constants import ( @@ -189,6 +189,7 @@ def get_chain(self) -> GenLayerChain: "localnet": localnet, "studionet": studionet, "testnet_asimov": testnet_asimov, + "testnet_bradbury": testnet_bradbury, } chain_type = self.get_chain_type() return chain_map[chain_type] diff --git a/gltest_cli/config/user.py b/gltest_cli/config/user.py index c922aed..2c8beb8 100644 --- a/gltest_cli/config/user.py +++ b/gltest_cli/config/user.py @@ -18,7 +18,7 @@ DEFAULT_LEADER_ONLY, CHAINS, ) -from genlayer_py.chains import localnet, studionet, testnet_asimov +from genlayer_py.chains import localnet, studionet, testnet_asimov, testnet_bradbury from gltest_cli.config.types import UserConfig, NetworkConfigData, PathConfig VALID_ROOT_KEYS = ["networks", "paths", "environment"] @@ -71,6 +71,16 @@ def get_default_user_config() -> UserConfig: default_wait_retries=DEFAULT_WAIT_RETRIES, chain_type="testnet_asimov", ), + "testnet_bradbury": NetworkConfigData( + id=testnet_bradbury.id, + url=testnet_bradbury.rpc_urls["default"]["http"][0], + accounts=None, + from_account=None, + leader_only=DEFAULT_LEADER_ONLY, + default_wait_interval=DEFAULT_WAIT_INTERVAL, + default_wait_retries=DEFAULT_WAIT_RETRIES, + chain_type="testnet_bradbury", + ), } return UserConfig( @@ -176,7 +186,7 @@ def validate_network_config(network_name: str, network_config: dict): raise ValueError(f"network {network_name} must have accounts") if "chain_type" not in network_config: raise ValueError( - f"network {network_name} must have a chain_type. Valid values: localnet, studionet, testnet_asimov" + f"network {network_name} must have a chain_type. Valid values: {', '.join(CHAINS)}" ) diff --git a/pyproject.toml b/pyproject.toml index 3f13660..acdc8bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ readme = "README.md" requires-python = ">=3.12" dependencies = [ "pytest", - "genlayer-py==0.9.0", + "genlayer-py>=0.11.0,<0.12.0", "colorama>=0.4.6", "pyyaml", "python-dotenv" diff --git a/tests/gltest_cli/config/test_plugin.py b/tests/gltest_cli/config/test_plugin.py index 3ec64c0..75c4d45 100644 --- a/tests/gltest_cli/config/test_plugin.py +++ b/tests/gltest_cli/config/test_plugin.py @@ -20,7 +20,7 @@ def test_help_message(pytester): " --leader-only Run contracts in leader-only mode", " --chain-type=CHAIN_TYPE", " Chain type (possible values: localnet, studionet,", - " testnet_asimov)", + " testnet_asimov, testnet_bradbury)", ] ) @@ -129,6 +129,25 @@ def test_network(): assert result.ret != 0 +def test_network_testnet_bradbury(pytester): + pytester.makepyfile( + """ + from gltest_cli.config.general import get_general_config + + def test_network(): + general_config = get_general_config() + assert general_config.get_network_name() == "testnet_bradbury" + """ + ) + + result = pytester.runpytest( + "--network=testnet_bradbury", "--rpc-url=http://test.example.com:9151", "-v" + ) + + # The test should exit with an error code when testnet_bradbury is used without accounts + assert result.ret != 0 + + def test_artifacts_dir(pytester): """Test that artifacts directory CLI parameter works correctly.""" pytester.makepyfile( @@ -346,7 +365,7 @@ def test_chain_type(): assert general_config.plugin_config.chain_type is None # get_chain_type should still work using network config chain_type = general_config.get_chain_type() - assert chain_type in ["localnet", "studionet", "testnet_asimov"] + assert chain_type in ["localnet", "studionet", "testnet_asimov", "testnet_bradbury"] """ )