|
| 1 | +import pytest |
| 2 | +import os |
| 3 | +from virtuals_acp.contract_clients.contract_client_v2 import ACPContractClientV2 |
| 4 | + |
| 5 | + |
| 6 | +# Skip all integration tests if environment variables are not set |
| 7 | +pytestmark = pytest.mark.integration |
| 8 | + |
| 9 | +# Check if we have required environment variables for integration tests |
| 10 | +SKIP_INTEGRATION = not all([ |
| 11 | + os.getenv("WHITELISTED_WALLET_PRIVATE_KEY"), |
| 12 | + os.getenv("SELLER_AGENT_WALLET_ADDRESS"), |
| 13 | + os.getenv("SELLER_ENTITY_ID"), |
| 14 | +]) |
| 15 | + |
| 16 | + |
| 17 | +@pytest.mark.skipif(SKIP_INTEGRATION, reason="Integration test environment variables not set") |
| 18 | +class TestIntegrationACPContractClientV2: |
| 19 | + @pytest.fixture(scope="class") |
| 20 | + def integration_client(self): |
| 21 | + wallet_private_key = os.getenv("WHITELISTED_WALLET_PRIVATE_KEY") |
| 22 | + agent_wallet_address = os.getenv("SELLER_AGENT_WALLET_ADDRESS") |
| 23 | + entity_id = int(os.getenv("SELLER_ENTITY_ID", "0")) |
| 24 | + |
| 25 | + try: |
| 26 | + client = ACPContractClientV2( |
| 27 | + agent_wallet_address=agent_wallet_address, |
| 28 | + wallet_private_key=wallet_private_key, |
| 29 | + entity_id=entity_id, |
| 30 | + ) |
| 31 | + yield client |
| 32 | + except Exception as e: |
| 33 | + pytest.fail(f"Failed to initialize integration client: {e}") |
| 34 | + |
| 35 | + class TestInitialization: |
| 36 | + def test_should_connect_to_mainnet(self, integration_client): |
| 37 | + assert integration_client is not None |
| 38 | + assert integration_client.agent_wallet_address is not None |
| 39 | + |
| 40 | + def test_should_have_valid_web3_connection(self, integration_client): |
| 41 | + assert integration_client.w3 is not None |
| 42 | + assert integration_client.w3.is_connected() |
| 43 | + |
| 44 | + def test_should_fetch_manager_addresses(self, integration_client): |
| 45 | + assert integration_client.job_manager_address is not None |
| 46 | + assert integration_client.job_manager_address.startswith("0x") |
| 47 | + |
| 48 | + def test_should_validate_session_key(self, integration_client): |
| 49 | + # If client initialized, session key validation already passed |
| 50 | + assert integration_client.account is not None |
| 51 | + assert integration_client.entity_id is not None |
| 52 | + |
| 53 | + def test_should_have_x402_instance(self, integration_client): |
| 54 | + assert integration_client.x402 is not None |
| 55 | + |
| 56 | + def test_should_have_alchemy_kit_instance(self, integration_client): |
| 57 | + assert integration_client.alchemy_kit is not None |
0 commit comments