feat(lighter): improve API key validation and market caching

- Add API key validation status tracking
- Add market list caching to reduce API calls
- Improve logging (debug vs info levels)
- Add comprehensive integration tests
- Update trader manager and store for lighter support
This commit is contained in:
tinkle-community
2026-01-17 23:07:35 +08:00
parent 19698529b8
commit 7f24a90851
11 changed files with 2024 additions and 166 deletions

View File

@@ -92,7 +92,7 @@ func TestBinanceSyncE2E(t *testing.T) {
t.Logf(" [%d] %s %s %s qty=%.6f price=%.4f action=%s time=%s",
i+1, order.ExchangeOrderID, order.Symbol, order.Side,
order.Quantity, order.Price, order.OrderAction,
order.FilledAt.Format(time.RFC3339))
time.UnixMilli(order.FilledAt).Format(time.RFC3339))
}
}
@@ -118,10 +118,11 @@ func TestBinanceSyncE2E(t *testing.T) {
}
// Test GetLastFillTimeByExchange
lastFillTime, err := orderStore.GetLastFillTimeByExchange(exchangeID)
lastFillTimeMs, err := orderStore.GetLastFillTimeByExchange(exchangeID)
if err != nil {
t.Logf(" ⚠️ GetLastFillTimeByExchange error: %v", err)
} else {
lastFillTime := time.UnixMilli(lastFillTimeMs)
t.Logf("\n📅 Last fill time from DB: %s", lastFillTime.Format(time.RFC3339))
// Check if it would be in the future (the bug we fixed)
@@ -175,7 +176,7 @@ func TestBinanceSyncWithExistingData(t *testing.T) {
Price: 50000,
Quantity: 0.001,
QuoteQuantity: 50,
CreatedAt: localTime, // This time is "in the future" if interpreted as UTC
CreatedAt: localTime.UnixMilli(), // This time is "in the future" if interpreted as UTC
}
if err := orderStore.CreateFill(fakeFill); err != nil {
t.Fatalf("Failed to create fake fill: %v", err)
@@ -186,10 +187,11 @@ func TestBinanceSyncWithExistingData(t *testing.T) {
t.Logf(" Current UTC time: %s", time.Now().UTC().Format(time.RFC3339))
// Check GetLastFillTimeByExchange
lastFillTime, _ := orderStore.GetLastFillTimeByExchange(exchangeID)
t.Logf(" GetLastFillTimeByExchange returned: %s", lastFillTime.Format(time.RFC3339))
lastFillTimeMs2, _ := orderStore.GetLastFillTimeByExchange(exchangeID)
lastFillTime2 := time.UnixMilli(lastFillTimeMs2)
t.Logf(" GetLastFillTimeByExchange returned: %s", lastFillTime2.Format(time.RFC3339))
if lastFillTime.After(time.Now().UTC()) {
if lastFillTime2.After(time.Now().UTC()) {
t.Logf(" ⚠️ Last fill time is in the future - this is the bug scenario!")
}