Some checks failed
Blockchain Synchronization Verification / sync-verification (push) Failing after 2s
Integration Tests / test-service-integration (push) Failing after 15s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 2s
P2P Network Verification / p2p-verification (push) Successful in 2s
Python Tests / test-python (push) Successful in 12s
Security Scanning / security-scan (push) Successful in 41s
Systemd Sync / sync-systemd (push) Successful in 7s
- Phase 1: Core bridge service with gossip broker subscription - Phase 2: Smart contract event integration via eth_getLogs RPC endpoint - Add contract event subscriber for AgentStaking, PerformanceVerifier, Marketplace, Bounty, CrossChainBridge - Add contract event handlers in agent_daemon.py and marketplace.py - Add systemd service file for blockchain-event-bridge - Update blockchain node router.py with eth_getLogs endpoint - Add configuration for contract addresses - Add tests for contract subscriber and handlers (27 tests passing)
71 lines
1.8 KiB
Python
71 lines
1.8 KiB
Python
"""Integration tests for blockchain event bridge."""
|
|
|
|
import pytest
|
|
from unittest.mock import Mock, AsyncMock, patch
|
|
|
|
from blockchain_event_bridge.bridge import BlockchainEventBridge
|
|
from blockchain_event_bridge.config import Settings
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_bridge_initialization():
|
|
"""Test bridge initialization."""
|
|
settings = Settings()
|
|
bridge = BlockchainEventBridge(settings)
|
|
|
|
assert bridge.settings == settings
|
|
assert bridge.is_running is False
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_bridge_start_stop():
|
|
"""Test bridge start and stop."""
|
|
settings = Settings(
|
|
subscribe_blocks=False,
|
|
subscribe_transactions=False,
|
|
)
|
|
bridge = BlockchainEventBridge(settings)
|
|
|
|
await bridge.start()
|
|
assert bridge.is_running is True
|
|
|
|
await bridge.stop()
|
|
assert bridge.is_running is False
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_bridge_handle_block_event():
|
|
"""Test bridge handling a block event."""
|
|
settings = Settings(
|
|
enable_coordinator_api_trigger=False,
|
|
enable_marketplace_trigger=False,
|
|
)
|
|
bridge = BlockchainEventBridge(settings)
|
|
|
|
block_data = {
|
|
"height": 100,
|
|
"hash": "0x123",
|
|
"transactions": []
|
|
}
|
|
|
|
# Should not raise an error even without handlers
|
|
await bridge.handle_block_event(block_data)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_bridge_handle_transaction_event():
|
|
"""Test bridge handling a transaction event."""
|
|
settings = Settings(
|
|
enable_agent_daemon_trigger=False,
|
|
enable_coordinator_api_trigger=False,
|
|
)
|
|
bridge = BlockchainEventBridge(settings)
|
|
|
|
tx_data = {
|
|
"hash": "0x456",
|
|
"type": "transfer"
|
|
}
|
|
|
|
# Should not raise an error even without handlers
|
|
await bridge.handle_transaction_event(tx_data)
|