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:
@@ -1,10 +1,12 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"me.thuanle/bbot/internal/data"
|
||||
"me.thuanle/bbot/internal/data/market"
|
||||
"me.thuanle/bbot/internal/helper/binancex"
|
||||
)
|
||||
|
||||
func TestBuildRichTokenMessageInput_AllSources(t *testing.T) {
|
||||
@@ -88,7 +90,25 @@ func (m *marketStub) GetAlphaPrice(symbol string) (float64, bool) {
|
||||
}
|
||||
func (m *marketStub) IsSpotPair(symbol string) bool { return m.spotPairs[symbol] }
|
||||
func (m *marketStub) IsFuturesPair(symbol string) bool { return m.futuresPairs[symbol] }
|
||||
func (m *marketStub) RefreshTradingPairCache() error { return nil }
|
||||
func (m *marketStub) GetSpotSymbolByToken(token string) (string, bool) {
|
||||
token = strings.ToUpper(token)
|
||||
for symbol := range m.spotPairs {
|
||||
if binancex.Symbol2Token(symbol) == token {
|
||||
return symbol, true
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
func (m *marketStub) GetFutureSymbolByToken(token string) (string, bool) {
|
||||
token = strings.ToUpper(token)
|
||||
for symbol := range m.futuresPairs {
|
||||
if binancex.Symbol2Token(symbol) == token {
|
||||
return symbol, true
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
func (m *marketStub) RefreshTradingPairCache() error { return nil }
|
||||
|
||||
func TestCollectRichTokenData_SpotOnlyReachable(t *testing.T) {
|
||||
orig := data.Market
|
||||
|
||||
Reference in New Issue
Block a user