#!/bin/bash
# Signet Test Suite
# Run all tests for memory system and identity verification

set -e

cd "$(dirname "$0")"

echo "========================================"
echo "SIGNET TEST SUITE"
echo "========================================"
echo

# Parse args
LIVE_MODE=""
if [[ "$1" == "--live" ]]; then
    LIVE_MODE="--live"
    echo "Mode: LIVE (includes API calls)"
else
    echo "Mode: FAST (config verification only)"
    echo "Use --live for API response tests"
fi
echo

# Run identity tests
echo ">>> Running identity tests..."
python3 -u test_identity.py $LIVE_MODE
IDENTITY_RESULT=$?
echo

# Run memory tests
echo ">>> Running memory tests..."
python3 -u test_memory.py
MEMORY_RESULT=$?
echo

# Summary
echo "========================================"
echo "SUMMARY"
echo "========================================"
if [[ $IDENTITY_RESULT -eq 0 ]]; then
    echo "  Identity: PASSED"
else
    echo "  Identity: FAILED"
fi

if [[ $MEMORY_RESULT -eq 0 ]]; then
    echo "  Memory: PASSED"
else
    echo "  Memory: FAILED"
fi

if [[ $IDENTITY_RESULT -eq 0 && $MEMORY_RESULT -eq 0 ]]; then
    echo "========================================"
    echo "ALL TESTS PASSED"
    echo "========================================"
    exit 0
else
    echo "========================================"
    echo "SOME TESTS FAILED"
    echo "========================================"
    exit 1
fi
