Files
epusdt2/src/notify/telegram_sender_test.go
T
line-6000 6bb47d4b00 feat: add admin panel with multi-chain support and notification system
- Add full admin REST API: auth, API keys, chains, chain tokens, wallets,
  orders, RPC nodes, settings, dashboard stats, notifications
- Add JWT-based admin authentication and API key auth middleware
- Add multi-chain listeners: BSC, ETH, Polygon, Plasma, EVM WebSocket
- Add RPC node health check job with automatic failover
- Add Telegram notification channel for order events
- Add installer for first-run database initialization
- Add new DB models: admin_user, api_key, chain, chain_token,
  rpc_node, settings, notification_channel
- Add order statistics aggregation (daily/monthly/by-chain)
- Serve built admin SPA from embedded www/ assets
- Add comprehensive test coverage for all new features
2026-04-22 02:28:31 +08:00

54 lines
1.5 KiB
Go

package notify
import "testing"
func TestParseTelegramConfigAcceptsNumericChatID(t *testing.T) {
raw := `{"bot_token":"123:ABC","chat_id":123456789}`
cfg, err := ParseTelegramConfig(raw)
if err != nil {
t.Fatalf("parse config: %v", err)
}
if cfg.BotToken != "123:ABC" {
t.Fatalf("bot token = %q, want %q", cfg.BotToken, "123:ABC")
}
if cfg.ChatID != 123456789 {
t.Fatalf("chat id = %d, want %d", cfg.ChatID, 123456789)
}
}
func TestParseTelegramConfigAcceptsStringChatID(t *testing.T) {
raw := `{"bot_token":"123:ABC","chat_id":"-1001234567890"}`
cfg, err := ParseTelegramConfig(raw)
if err != nil {
t.Fatalf("parse config: %v", err)
}
if cfg.ChatID != -1001234567890 {
t.Fatalf("chat id = %d, want %d", cfg.ChatID, int64(-1001234567890))
}
}
func TestParseTelegramConfigRejectsInvalidChatID(t *testing.T) {
raw := `{"bot_token":"123:ABC","chat_id":"not-a-number"}`
_, err := ParseTelegramConfig(raw)
if err == nil {
t.Fatal("expected parse error for invalid chat_id")
}
}
func TestParseTelegramConfigAcceptsCamelCaseKeys(t *testing.T) {
raw := `{"botToken":"123:ABC","chatId":"-1001234567890","proxyUrl":"http://127.0.0.1:7890"}`
cfg, err := ParseTelegramConfig(raw)
if err != nil {
t.Fatalf("parse config: %v", err)
}
if cfg.BotToken != "123:ABC" {
t.Fatalf("bot token = %q, want %q", cfg.BotToken, "123:ABC")
}
if cfg.ChatID != -1001234567890 {
t.Fatalf("chat id = %d, want %d", cfg.ChatID, int64(-1001234567890))
}
if cfg.Proxy != "http://127.0.0.1:7890" {
t.Fatalf("proxy = %q, want %q", cfg.Proxy, "http://127.0.0.1:7890")
}
}