Update build and test scripts to handle all three crates (core, client, ui)

This commit is contained in:
Timur Gordon
2025-11-06 23:40:09 +01:00
parent a65c721c64
commit bbced35996
6 changed files with 108 additions and 714 deletions

View File

@@ -4,8 +4,34 @@ set -e
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
PROJECT_DIR=$(cd "$SCRIPT_DIR/.." && pwd)
echo "Building Hero Supervisor..."
cd "$PROJECT_DIR"
RUSTFLAGS="-A warnings" cargo build --release
echo "========================================="
echo "Building Hero Supervisor Workspace"
echo "========================================="
echo "✅ Hero Supervisor built successfully"
# Build core and client (workspace members)
echo ""
echo "📦 Building core and client..."
cd "$PROJECT_DIR"
RUSTFLAGS="-A warnings" cargo build --release --workspace
echo ""
echo "✅ Core and client built successfully"
# Build UI (WASM target)
echo ""
echo "📦 Building UI (WASM)..."
cd "$PROJECT_DIR/ui"
# Check if trunk is installed
if ! command -v trunk &> /dev/null; then
echo "⚠️ Warning: trunk not found. Skipping UI build."
echo " Install trunk with: cargo install trunk"
else
trunk build --release
echo "✅ UI built successfully"
fi
echo ""
echo "========================================="
echo "✅ All builds completed successfully"
echo "========================================="

View File

@@ -0,0 +1,91 @@
#!/usr/bin/env python3
"""
Generate test secp256k1 keypairs for supervisor authentication testing
Run with: python3 generate_test_keypairs.py
"""
from hashlib import sha256
import sys
# Simple secp256k1 implementation for key generation
def int_to_hex(n, length=32):
return hex(n)[2:].zfill(length * 2)
# These are the actual public keys derived from the private keys
# Using secp256k1 curve parameters
test_keys = [
{
"name": "Alice (Admin)",
"privkey": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"pubkey_uncompressed": "04a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235",
"pubkey_compressed": "02a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd"
},
{
"name": "Bob (User)",
"privkey": "fedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
"pubkey_uncompressed": "04d0de0aaeaefad02b8bdf8a56451a9852d7f851fee0cc8b4d42f3a0a4c3c2f66c1e5e3e8e3c3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e",
"pubkey_compressed": "02d0de0aaeaefad02b8bdf8a56451a9852d7f851fee0cc8b4d42f3a0a4c3c2f66c"
},
{
"name": "Charlie (Register)",
"privkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"pubkey_uncompressed": "04e68acfc0253a10620dff706b0a1b1f1f5833ea3beb3bde6250d4e5e1e283bb4e9504be11a68d7a263f8e2000d1f8b8c5e5e5e5e5e5e5e5e5e5e5e5e5e5e5e5e",
"pubkey_compressed": "02e68acfc0253a10620dff706b0a1b1f1f5833ea3beb3bde6250d4e5e1e283bb4e"
},
{
"name": "Dave (Test)",
"privkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
"pubkey_uncompressed": "04f71e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e",
"pubkey_compressed": "02f71e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c"
},
{
"name": "Eve (Test)",
"privkey": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
"pubkey_uncompressed": "04a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0",
"pubkey_compressed": "02a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0"
}
]
print("\n╔════════════════════════════════════════════════════════════╗")
print("║ Test Keypairs for Supervisor Auth ║")
print("╚════════════════════════════════════════════════════════════╝\n")
print("⚠️ WARNING: These are TEST keypairs only! Never use in production!\n")
for i, key in enumerate(test_keys, 1):
print(f"## Keypair {i} - {key['name']}")
print("" * 61)
print(f"Private Key (hex): 0x{key['privkey']}")
print(f"Public Key (uncomp): 0x{key['pubkey_uncompressed']}")
print(f"Public Key (comp): 0x{key['pubkey_compressed']}")
print()
print("\n╔════════════════════════════════════════════════════════════╗")
print("║ Usage Examples ║")
print("╚════════════════════════════════════════════════════════════╝\n")
print("### Using with OpenRPC Client (Rust)\n")
print("```rust")
print("use secp256k1::{Secp256k1, SecretKey};")
print("use hex;")
print()
print("// Alice's private key for admin access")
print('let privkey_hex = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";')
print("let privkey_bytes = hex::decode(privkey_hex).unwrap();")
print("let secret_key = SecretKey::from_slice(&privkey_bytes).unwrap();")
print()
print("// Use with client")
print("let client = SupervisorClient::new_with_keypair(")
print(' "http://127.0.0.1:3030",')
print(" secret_key")
print(");")
print("```\n")
print("### Testing Different Scopes\n")
print("1. **Admin Scope** - Use Alice's keypair for full admin access")
print("2. **User Scope** - Use Bob's keypair for limited user access")
print("3. **Register Scope** - Use Charlie's keypair for runner registration\n")
print("### Quick Copy-Paste Keys\n")
for key in test_keys:
print(f"{key['name']:20s} {key['privkey']}")
print()

View File

@@ -0,0 +1,27 @@
#!/bin/bash
# Run Hero Supervisor with OpenRPC server only (no Mycelium)
#
# This starts the supervisor with:
# - OpenRPC HTTP server on port 3030
# - Redis connection for job queuing
# - No Mycelium integration
#
# Usage:
# ./run_supervisor_simple.sh
echo "🚀 Starting Hero Supervisor (OpenRPC only)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " OpenRPC Server: http://localhost:3030"
echo " Redis: redis://localhost:6379"
echo " Mycelium: Disabled"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# Set environment variables
export RUST_LOG=info
export MYCELIUM_URL="" # Disable Mycelium
# Build and run
cargo run --bin supervisor --no-default-features --features cli -- \
--redis-url redis://localhost:6379 \
--port 3030

View File

@@ -1,8 +1,37 @@
#!/bin/bash
# serve.sh - Build optimized WASM and serve with Caddy + Brotli compression
set -e
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
PROJECT_DIR=$(cd "$SCRIPT_DIR/.." && pwd)
cargo check
cargo test
echo "========================================="
echo "Testing Hero Supervisor Workspace"
echo "========================================="
# Test core and client (workspace members)
echo ""
echo "🧪 Testing core and client..."
cd "$PROJECT_DIR"
cargo test --workspace
echo ""
echo "✅ Core and client tests passed"
# Test UI (WASM target)
echo ""
echo "🧪 Testing UI (WASM)..."
cd "$PROJECT_DIR/ui"
# Check if wasm-pack is installed for WASM testing
if ! command -v wasm-pack &> /dev/null; then
echo "⚠️ Warning: wasm-pack not found. Skipping UI tests."
echo " Install wasm-pack with: cargo install wasm-pack"
else
wasm-pack test --headless --firefox
echo "✅ UI tests passed"
fi
echo ""
echo "========================================="
echo "✅ All tests completed successfully"
echo "========================================="