refactor: clean up tests/ root — delete junk, sort into subdirs
Deleted (7 files): - test_discovery.py, test_windsurf_integration.py (trivial assert True stubs) - pytest_simple.ini (unused --collect-only config) - conftest_path.py (duplicate of conftest.py path setup) - conftest_fixtures.py, conftest_full.py (unused conftest variants) Moved to integration/ (6 files): - test_blockchain_final.py, test_blockchain_nodes.py, test_blockchain_simple.py - test_basic_integration.py, test_integration_simple.py, test_working_integration.py Moved to fixtures/: - mock_blockchain_node.py tests/ root now has only conftest.py and README.md.
This commit is contained in:
90
tests/integration/test_blockchain_final.py
Normal file
90
tests/integration/test_blockchain_final.py
Normal file
@@ -0,0 +1,90 @@
|
||||
#!/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()
|
||||
Reference in New Issue
Block a user