refactor: use canonical token-to-symbol maps for market lookup
Build canonical spot/future token maps with quote priority, unify cache refresh scheduling, and switch resolver/token tests to map-based token lookups. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package market
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSelectCanonicalSymbolByQuotePriority(t *testing.T) {
|
||||
pairs := []string{"DOGEFDUSD", "DOGEUSDC", "DOGEUSDT"}
|
||||
got := selectCanonicalSymbolByQuotePriority("DOGE", pairs)
|
||||
if got != "DOGEUSDT" {
|
||||
t.Fatalf("expected DOGEUSDT, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSelectCanonicalSymbolByQuotePriority_FallbackOrder(t *testing.T) {
|
||||
pairs := []string{"DOGEFDUSD", "DOGEUSDC"}
|
||||
got := selectCanonicalSymbolByQuotePriority("DOGE", pairs)
|
||||
if got != "DOGEUSDC" {
|
||||
t.Fatalf("expected DOGEUSDC, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSelectCanonicalSymbolByQuotePriority_NoPreferredQuote(t *testing.T) {
|
||||
pairs := []string{"DOGEBUSD"}
|
||||
got := selectCanonicalSymbolByQuotePriority("DOGE", pairs)
|
||||
if got != "DOGEBUSD" {
|
||||
t.Fatalf("expected DOGEBUSD, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeFutureToken_AppliesOverride(t *testing.T) {
|
||||
got := normalizeFutureToken("LUNA2")
|
||||
if got != "LUNA" {
|
||||
t.Fatalf("expected LUNA, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeFutureToken_NoOverride(t *testing.T) {
|
||||
got := normalizeFutureToken("PEPE")
|
||||
if got != "PEPE" {
|
||||
t.Fatalf("expected PEPE, got %q", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user