"""Tests for contract event handlers.""" import pytest from unittest.mock import Mock, AsyncMock from blockchain_event_bridge.action_handlers.agent_daemon import AgentDaemonHandler from blockchain_event_bridge.action_handlers.marketplace import MarketplaceHandler @pytest.mark.asyncio async def test_agent_daemon_handle_staking_event(): """Test agent daemon handler for staking events.""" handler = AgentDaemonHandler("http://localhost:8006") event_log = { "topics": ["StakeCreated"], "data": '{"stakeId": "123", "staker": "0xabc"}' } # Should not raise an error await handler.handle_staking_event(event_log) @pytest.mark.asyncio async def test_agent_daemon_handle_performance_event(): """Test agent daemon handler for performance events.""" handler = AgentDaemonHandler("http://localhost:8006") event_log = { "topics": ["PerformanceVerified"], "data": '{"verificationId": "456", "withinSLA": true}' } # Should not raise an error await handler.handle_performance_event(event_log) @pytest.mark.asyncio async def test_agent_daemon_handle_bounty_event(): """Test agent daemon handler for bounty events.""" handler = AgentDaemonHandler("http://localhost:8006") event_log = { "topics": ["BountyCreated"], "data": '{"bountyId": "789", "creator": "0xdef"}' } # Should not raise an error await handler.handle_bounty_event(event_log) @pytest.mark.asyncio async def test_agent_daemon_handle_bridge_event(): """Test agent daemon handler for bridge events.""" handler = AgentDaemonHandler("http://localhost:8006") event_log = { "topics": ["BridgeInitiated"], "data": '{"requestId": "101", "sourceChain": "ethereum"}' } # Should not raise an error await handler.handle_bridge_event(event_log) @pytest.mark.asyncio async def test_marketplace_handle_contract_event(): """Test marketplace handler for contract events.""" handler = MarketplaceHandler("http://localhost:8011") event_log = { "topics": ["ServiceListed"], "data": '{"serviceId": "202", "provider": "0x123"}' } # Should not raise an error await handler.handle_contract_event(event_log)