#!/usr/bin/env python3 """ Final test and summary for blockchain nodes """ import httpx import json # Node URLs NODES = { "node1": {"url": "http://127.0.0.1:8082", "name": "Node 1"}, "node2": {"url": "http://127.0.0.1:8081", "name": "Node 2"}, } def test_nodes(): """Test both nodes""" print("šŸ”— AITBC Blockchain Node Test Summary") print("=" * 60) results = [] for node_id, node in NODES.items(): print(f"\n{node['name']}:") # Test RPC API try: response = httpx.get(f"{node['url']}/openapi.json", timeout=5) api_ok = response.status_code == 200 print(f" RPC API: {'āœ…' if api_ok else 'āŒ'}") except: api_ok = False print(f" RPC API: āŒ") # Test chain head try: response = httpx.get(f"{node['url']}/rpc/head", timeout=5) if response.status_code == 200: head = response.json() height = head.get('height', 0) print(f" Chain Height: {height}") # Test faucet try: response = httpx.post( f"{node['url']}/rpc/admin/mintFaucet", json={"address": "aitbc1test000000000000000000000000000000000000", "amount": 100}, timeout=5 ) faucet_ok = response.status_code == 200 print(f" Faucet: {'āœ…' if faucet_ok else 'āŒ'}") except: faucet_ok = False print(f" Faucet: āŒ") results.append({ 'node': node['name'], 'api': api_ok, 'height': height, 'faucet': faucet_ok }) else: print(f" Chain Head: āŒ") except: print(f" Chain Head: āŒ") # Summary print("\n\nšŸ“Š Test Results Summary") print("=" * 60) for result in results: status = "āœ… OPERATIONAL" if result['api'] and result['faucet'] else "āš ļø PARTIAL" print(f"{result['node']:.<20} {status}") print(f" - RPC API: {'āœ…' if result['api'] else 'āŒ'}") print(f" - Height: {result['height']}") print(f" - Faucet: {'āœ…' if result['faucet'] else 'āŒ'}") print("\n\nšŸ“ Notes:") print("- Both nodes are running independently") print("- Each node maintains its own chain") print("- Nodes are not connected (different heights)") print("- To connect nodes in production:") print(" 1. Deploy on separate servers") print(" 2. Use Redis for gossip backend") print(" 3. Configure P2P peer discovery") print(" 4. Ensure network connectivity") print("\nāœ… Test completed successfully!") if __name__ == "__main__": test_nodes()