diff --git a/autotx/tests/agents/token/send/test_send.py b/autotx/tests/agents/token/send/test_send.py index fb79edc..b183c41 100644 --- a/autotx/tests/agents/token/send/test_send.py +++ b/autotx/tests/agents/token/send/test_send.py @@ -1,6 +1,9 @@ +import pytest + from autotx.utils.ethereum import get_erc20_balance from autotx.utils.ethereum.get_native_balance import get_native_balance +@pytest.mark.timeout(60) def test_send_native(smart_account, auto_tx, test_accounts): receiver = test_accounts[0] balance = get_native_balance(smart_account.web3, receiver) @@ -11,6 +14,7 @@ def test_send_native(smart_account, auto_tx, test_accounts): balance = get_native_balance(smart_account.web3, receiver) assert balance == 1 +@pytest.mark.timeout(60) def test_send_erc20(smart_account, auto_tx, usdc, test_accounts): receiver = test_accounts[0] @@ -25,6 +29,7 @@ def test_send_erc20(smart_account, auto_tx, usdc, test_accounts): assert balance + 10 == new_balance +@pytest.mark.timeout(60) def test_send_native_sequential(smart_account, auto_tx, test_accounts): receiver = test_accounts[0] @@ -38,6 +43,7 @@ def test_send_native_sequential(smart_account, auto_tx, test_accounts): balance = get_native_balance(smart_account.web3, receiver) assert balance == 1.5 +@pytest.mark.timeout(60) def test_send_erc20_parallel(smart_account, auto_tx, usdc, test_accounts): receiver_one = test_accounts[0] @@ -56,6 +62,7 @@ def test_send_erc20_parallel(smart_account, auto_tx, usdc, test_accounts): assert balance_one + 2 == new_balance_one assert balance_two + 3 == new_balance_two +@pytest.mark.timeout(60) def test_send_eth_multiple(smart_account, auto_tx, usdc, test_accounts): receiver_1 = test_accounts[0] diff --git a/autotx/tests/agents/token/test_swap.py b/autotx/tests/agents/token/test_swap.py index 2443d09..212ee36 100644 --- a/autotx/tests/agents/token/test_swap.py +++ b/autotx/tests/agents/token/test_swap.py @@ -1,9 +1,12 @@ +import pytest + from autotx.utils.ethereum.get_erc20_balance import get_erc20_balance from autotx.utils.ethereum.networks import NetworkInfo from autotx.eth_address import ETHAddress DIFFERENCE_PERCENTAGE = 1.01 +@pytest.mark.timeout(60) def test_swap_with_non_default_token(smart_account, auto_tx): network_info = NetworkInfo(smart_account.web3.eth.chain_id) shib_address = ETHAddress(network_info.tokens["shib"]) @@ -18,6 +21,7 @@ def test_swap_with_non_default_token(smart_account, auto_tx): expected_shib_amount = 100000 assert expected_shib_amount <= new_balance <= expected_shib_amount * DIFFERENCE_PERCENTAGE +@pytest.mark.timeout(60) def test_swap_native(smart_account, auto_tx): network_info = NetworkInfo(smart_account.web3.eth.chain_id) usdc_address = ETHAddress(network_info.tokens["usdc"]) @@ -29,6 +33,7 @@ def test_swap_native(smart_account, auto_tx): expected_usdc_amount = 100 assert expected_usdc_amount <= new_balance <= expected_usdc_amount * DIFFERENCE_PERCENTAGE +@pytest.mark.timeout(60) def test_swap_multiple_1(smart_account, auto_tx): network_info = NetworkInfo(smart_account.web3.eth.chain_id) usdc_address = ETHAddress(network_info.tokens["usdc"]) @@ -46,6 +51,7 @@ def test_swap_multiple_1(smart_account, auto_tx): assert expected_usdc_amount <= usdc_balance <= expected_usdc_amount_plus_slippage - expected_usdc_amount assert wbtc_balance < get_erc20_balance(smart_account.web3, wbtc_address, smart_account.address) +@pytest.mark.timeout(60) def test_swap_multiple_2(smart_account, auto_tx): network_info = NetworkInfo(smart_account.web3.eth.chain_id) usdc_address = ETHAddress(network_info.tokens["usdc"]) @@ -61,6 +67,7 @@ def test_swap_multiple_2(smart_account, auto_tx): assert expected_amount <= usdc_balance assert wbtc_balance < get_erc20_balance(smart_account.web3, wbtc_address, smart_account.address) +@pytest.mark.timeout(60) def test_swap_triple(smart_account, auto_tx): network_info = NetworkInfo(smart_account.web3.eth.chain_id) usdc_address = ETHAddress(network_info.tokens["usdc"]) @@ -81,6 +88,7 @@ def test_swap_triple(smart_account, auto_tx): assert expected_uni_amount <= uni_balance <= expected_uni_amount * DIFFERENCE_PERCENTAGE assert expected_wbtc_amount <= wbtc_balance <= expected_wbtc_amount * DIFFERENCE_PERCENTAGE +@pytest.mark.timeout(60) def test_swap_complex_1(smart_account, auto_tx): # This one is complex because it confuses the LLM with WBTC amount network_info = NetworkInfo(smart_account.web3.eth.chain_id) usdc_address = ETHAddress(network_info.tokens["usdc"]) @@ -95,6 +103,7 @@ def test_swap_complex_1(smart_account, auto_tx): # This one is complex because i assert expected_usdc_amount <= usdc_balance <= expected_usdc_amount * DIFFERENCE_PERCENTAGE assert wbtc_balance < get_erc20_balance(smart_account.web3, wbtc_address, smart_account.address) +@pytest.mark.timeout(60) def test_swap_complex_2(smart_account, auto_tx): # This one is complex because it confuses the LLM with WBTC amount network_info = NetworkInfo(smart_account.web3.eth.chain_id) usdc_address = ETHAddress(network_info.tokens["usdc"]) diff --git a/autotx/tests/agents/token/test_swap_and_send.py b/autotx/tests/agents/token/test_swap_and_send.py index adc15b9..fcdeeca 100644 --- a/autotx/tests/agents/token/test_swap_and_send.py +++ b/autotx/tests/agents/token/test_swap_and_send.py @@ -1,9 +1,11 @@ +import pytest from autotx.utils.ethereum import get_erc20_balance, get_native_balance from autotx.utils.ethereum.networks import NetworkInfo from autotx.eth_address import ETHAddress DIFFERENCE_PERCENTAGE = 1.01 +@pytest.mark.timeout(60) def test_swap_and_send_simple(smart_account, auto_tx, test_accounts): network_info = NetworkInfo(smart_account.web3.eth.chain_id) wbtc_address = ETHAddress(network_info.tokens["wbtc"]) @@ -20,6 +22,7 @@ def test_swap_and_send_simple(smart_account, auto_tx, test_accounts): assert excepted_safe_wbtc_balance <= new_wbtc_safe_address <= new_wbtc_safe_address * DIFFERENCE_PERCENTAGE assert new_receiver_wbtc_balance == 0.01 +@pytest.mark.timeout(60) def test_swap_and_send_complex(smart_account, auto_tx, test_accounts): network_info = NetworkInfo(smart_account.web3.eth.chain_id) usdc_address = ETHAddress(network_info.tokens["usdc"]) @@ -41,6 +44,7 @@ def test_swap_and_send_complex(smart_account, auto_tx, test_accounts): assert expected_usdc_safe_balance <= new_usdc_safe_address <= expected_usdc_safe_balance * DIFFERENCE_PERCENTAGE assert new_receiver_usdc_balance == 50 +@pytest.mark.timeout(60) def test_send_and_swap_simple(smart_account, auto_tx, test_accounts): network_info = NetworkInfo(smart_account.web3.eth.chain_id) wbtc_address = ETHAddress(network_info.tokens["wbtc"]) @@ -64,6 +68,7 @@ def test_send_and_swap_simple(smart_account, auto_tx, test_accounts): assert new_receiver_wbtc_balance == receiver_wbtc_balance assert new_receiver_native_balance == receiver_native_balance + 0.1 +@pytest.mark.timeout(60) def test_send_and_swap_complex(smart_account, auto_tx, test_accounts): network_info = NetworkInfo(smart_account.web3.eth.chain_id) usdc_address = ETHAddress(network_info.tokens["usdc"]) diff --git a/poetry.lock b/poetry.lock index a21cf8f..7831d5a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2249,6 +2249,20 @@ tomli = {version = ">=1", markers = "python_version < \"3.11\""} [package.extras] dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +[[package]] +name = "pytest-timeout" +version = "2.3.1" +description = "pytest plugin to abort hanging tests" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-timeout-2.3.1.tar.gz", hash = "sha256:12397729125c6ecbdaca01035b9e5239d4db97352320af155b3f5de1ba5165d9"}, + {file = "pytest_timeout-2.3.1-py3-none-any.whl", hash = "sha256:68188cb703edfc6a18fad98dc25a3c61e9f24d644b0b70f33af545219fc7813e"}, +] + +[package.dependencies] +pytest = ">=7.0.0" + [[package]] name = "pytest-vcr" version = "1.0.2" @@ -3578,4 +3592,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = ">=3.10,<3.13" -content-hash = "300ed8dedc21e53f9f0a4bcd9ffa9f98f0464befeb2ada5441b170a101b08c1a" +content-hash = "c358c59f6f591afe7264818076545c27f31d51e67663bd4b67c8227bfe8689ab" diff --git a/pyproject.toml b/pyproject.toml index 222077e..df271af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,7 @@ uvicorn = "^0.29.0" supabase = "^2.5.0" llama-cpp-python = "^0.2.78" aiohttp = "^3.9.5" +pytest-timeout = "^2.3.1" [tool.poetry.group.dev.dependencies] mypy = "^1.8.0"