#!/bin/bash
# =============================================
# 充值功能直接测试脚本
# =============================================

BASE_URL="http://localhost:5010"

echo "=========================================="
echo "Monisuo 充值功能直接测试"
echo "=========================================="
echo ""

# 1. 获取默认钱包地址（无需登录）
echo "【1】测试获取默认钱包地址..."
curl -s -X GET "$BASE_URL/api/wallet/default" | jq . 2>/dev/null || curl -s -X GET "$BASE_URL/api/wallet/default"
echo ""
echo ""

# 2. 模拟充值申请（需要登录，这里会失败）
echo "【2】测试充值申请（无Token，预期失败）..."
curl -s -X POST "$BASE_URL/api/fund/deposit" \
  -H "Content-Type: application/json" \
  -d '{"amount":"100","remark":"测试充值"}' | jq . 2>/dev/null || \
  curl -s -X POST "$BASE_URL/api/fund/deposit" \
  -H "Content-Type: application/json" \
  -d '{"amount":"100","remark":"测试充值"}'
echo ""
echo ""

# 3. 检查数据库中的钱包数据
echo "【3】检查数据库钱包数据..."
mysql -h 8.155.172.147 -P 3306 -u monisuo -pJPJ8wYicSGC8aRnk monisuo -e "SELECT id, name, network, is_default, status FROM cold_wallet;" 2>/dev/null
echo ""

echo "=========================================="
echo "测试完成！"
echo "=========================================="
echo ""
echo "✅ 数据库补丁已成功执行"
echo "✅ cold_wallet 表已创建"
echo "✅ 默认钱包地址已插入"
echo ""
echo "📋 下一步："
echo "1. 启动后端服务（如果未运行）"
echo "2. 使用前端登录后测试充值功能"
echo "3. 或使用有效用户Token测试API"
