Actions
업무 #408
진행중
JL
JL
gRPC test client (Python CLI) 추가
업무 #408:
gRPC test client (Python CLI) 추가
설명
개요¶
alphea-ai-edge gRPC 서버의 모든 서비스를 커맨드라인에서 직접 테스트할 수 있는 Python CLI 클라이언트를 추가한다.
목적¶
- Dev Console(HTTP REST)과 별도로, gRPC endpoint 에 직접 접속하여 RPC 동작을 검증
- 로컬 및 프로덕션 서버(
edge.alphea.ai:443) 모두 지원 - secp256k1 서명 기반 인증 플로우 전체를 CLI에서 재현
구현 내용¶
tools/client.py¶
인터랙티브 메뉴 방식의 gRPC 테스트 클라이언트.
지원 서비스 및 RPC:
| 메뉴 | 서비스 | RPC |
|---|---|---|
| 1 | SystemService | Health, Info |
| 2 | AuthService | GenerateKeypair(local/server), Challenge→Sign→Verify, EmailRegister, Login |
| 3 | UserService | GetUser |
| 4 | NodeService | ListNodes, GetNode, NodeChallenge→RegisterNode, Heartbeat, GetNodeJobs, DeleteNode |
| 5 | WalletService | GetJobs, GetNodes, GetNodesDetail, GetEarnings, GetEarningsToday, GetReceipts, GetEarningsByRange |
| 6 | ConnectNode | bidi 스트림 연결 시뮬레이션 |
주요 특징:
- 첫 실행 시 proto 파일 자동 컴파일 (
tools/_gen/에 생성) - TLS 자동 감지 (port 443 →
grpc.ssl_channel_credentials()) - 세션 상태(wallet, private key, JWT token, node_id)를
tools/.client_state.json에 자동 저장 - secp256k1 서명은
eth-keys+pycryptodome라이브러리로 로컬 생성
tools/requirements.txt¶
grpcio>=1.60.0
grpcio-tools>=1.60.0
eth-keys>=0.6.0
eth-hash[pycryptodome]>=0.5.0
pycryptodome>=3.20.0
사용 방법¶
pip3 install -r tools/requirements.txt
python3 tools/client.py # localhost:3000
python3 tools/client.py --host edge.alphea.ai:443
테스트 결과¶
edge.alphea.ai:443 프로덕션 서버에서 확인:
- Health:
status=ok,db=True - 전체 인증 플로우 (GenerateKeypair → Challenge → Sign → Verify) 성공, JWT 토큰 발급 확인
Actions