mirror of
https://github.com/zap-proto/spec.git
synced 2026-10-30 15:04:03 +00:00
Initial release of ZAP (Zero-copy Agent Protocol) for high-performance AI agent communication with post-quantum security. ## Features ### Core Protocol - Cap'n Proto RPC for zero-copy serialization - Client/Server/Gateway architecture - Multi-transport support (TCP, Unix sockets, WebSocket) ### Post-Quantum Cryptography - ML-KEM-768 key encapsulation (NIST FIPS 203) - ML-DSA-65 digital signatures (NIST FIPS 204) - Hybrid X25519 + ML-KEM handshake ### W3C DID Identity - did:lux - Blockchain-anchored DIDs for Lux network - did:key - Self-certifying DIDs from ML-DSA-65 keys - did:web - DNS-based DIDs - DID Document generation with verification methods ### Agentic Consensus - Query/Response/Vote model for agent decisions - Configurable consensus threshold (default 50% majority) - Stake-weighted voting support - Finality proofs with post-quantum signatures ### Lux Integration - LuxConsensusBridge for Quasar finality - Ringtail threshold signature support - BLS + Ringtail hybrid signatures ## SDKs - Rust: Full native implementation with async support - Python: hanzo-zap package with asyncio - TypeScript: @hanzo/zap package with full type safety ## Testing - Rust: 38 tests - Python: 48 tests - TypeScript: 60 tests - CI: GitHub Actions with 80%+ coverage gates
82 lines
2.5 KiB
Python
82 lines
2.5 KiB
Python
"""Tests for hanzo_zap.config module."""
|
|
|
|
import pytest
|
|
from hanzo_zap.config import Config, ServerConfig, Transport
|
|
|
|
|
|
class TestConfig:
|
|
"""Tests for Config class."""
|
|
|
|
def test_default_config(self):
|
|
"""Test creating default config."""
|
|
config = Config()
|
|
assert config.listen == "0.0.0.0"
|
|
assert config.port == 9999
|
|
assert config.log_level == "info"
|
|
assert config.servers == []
|
|
|
|
def test_custom_config(self):
|
|
"""Test creating custom config."""
|
|
config = Config(listen="127.0.0.1", port=8888, log_level="debug")
|
|
assert config.listen == "127.0.0.1"
|
|
assert config.port == 8888
|
|
assert config.log_level == "debug"
|
|
|
|
def test_config_from_dict(self):
|
|
"""Test creating config from dict."""
|
|
data = {
|
|
"listen": "localhost",
|
|
"port": 9000,
|
|
"log_level": "warn",
|
|
"servers": [
|
|
{"name": "test", "url": "http://localhost:8080"}
|
|
]
|
|
}
|
|
config = Config.from_dict(data)
|
|
assert config.listen == "localhost"
|
|
assert config.port == 9000
|
|
assert config.log_level == "warn"
|
|
assert len(config.servers) == 1
|
|
assert config.servers[0].name == "test"
|
|
|
|
def test_config_default_path(self):
|
|
"""Test default config path."""
|
|
path = Config.default_path()
|
|
assert "zap" in str(path)
|
|
assert "config.toml" in str(path)
|
|
|
|
|
|
class TestServerConfig:
|
|
"""Tests for ServerConfig class."""
|
|
|
|
def test_server_config(self):
|
|
"""Test creating server config."""
|
|
config = ServerConfig(name="test", url="http://localhost:8080")
|
|
assert config.name == "test"
|
|
assert config.url == "http://localhost:8080"
|
|
assert config.transport == Transport.STDIO
|
|
assert config.timeout == 30000
|
|
|
|
def test_server_config_with_transport(self):
|
|
"""Test server config with transport."""
|
|
config = ServerConfig(
|
|
name="test",
|
|
url="ws://localhost:8080",
|
|
transport=Transport.WEBSOCKET,
|
|
timeout=60000
|
|
)
|
|
assert config.transport == Transport.WEBSOCKET
|
|
assert config.timeout == 60000
|
|
|
|
|
|
class TestTransport:
|
|
"""Tests for Transport enum."""
|
|
|
|
def test_transport_values(self):
|
|
"""Test transport enum values."""
|
|
assert Transport.STDIO.value == "stdio"
|
|
assert Transport.HTTP.value == "http"
|
|
assert Transport.WEBSOCKET.value == "websocket"
|
|
assert Transport.ZAP.value == "zap"
|
|
assert Transport.UNIX.value == "unix"
|