exchanges/btse: Handle TRUMPSOL in MarketPair.Pair and add test coverage (#1808)

* exchanges/btse: Handle TRUMPSOL in MarketPair.Pair and add test coverage

* BTSE: Update test table

* nits: Make slight adjustments to test table
This commit is contained in:
Adrian Gallagher
2025-02-24 14:26:11 +11:00
committed by GitHub
parent 744ee7c099
commit ef0f398455
2 changed files with 32 additions and 4 deletions

View File

@@ -752,6 +752,29 @@ func TestStripExponent(t *testing.T) {
assert.ErrorIs(t, err, errInvalidPairSymbol, "Should error on a symbol with too many underscores")
}
func TestMarketPair(t *testing.T) {
t.Parallel()
for _, tt := range []struct {
symbol string
base string
futures bool
expectedErr error
expectedSymbol string
}{
{symbol: "RUNEPFC", base: currency.RUNE.String(), futures: true, expectedSymbol: "RUNEPFC"},
{symbol: "TRUMPPFC", base: "TRUMPSOL", futures: true, expectedSymbol: "TRUMPPFC"},
{symbol: "BTCUSD", base: "NAUGHTYBASE", futures: true, expectedErr: errInvalidPairSymbol},
{symbol: "NAUGHTYSYMBOL", base: currency.BTC.String(), expectedErr: errInvalidPairSymbol},
{symbol: "BTC-USD", base: currency.BTC.String(), expectedSymbol: "BTCUSD"},
} {
mp := MarketPair{Symbol: tt.symbol, Base: tt.base, Quote: "USD", Futures: tt.futures}
p, err := mp.Pair()
assert.ErrorIs(t, err, tt.expectedErr, "Pair should not error")
assert.Equal(t, tt.expectedSymbol, p.String(), "Pair should return the expected symbol")
}
}
func TestGenerateSubscriptions(t *testing.T) {
t.Parallel()

View File

@@ -1051,11 +1051,16 @@ func (m *MarketPair) Pair() (currency.Pair, error) {
baseCurr := m.Base
var quoteCurr string
if m.Futures {
s := strings.Split(m.Symbol, m.Base) // e.g. RUNEPFC for RUNE-USD futures pair
if len(s) <= 1 {
return currency.EMPTYPAIR, errInvalidPairSymbol
if baseCurr == "TRUMPSOL" { // Only base currency which is different to the rest
baseCurr = "TRUMP"
quoteCurr = strings.TrimPrefix(m.Symbol, baseCurr)
} else {
s := strings.Split(m.Symbol, m.Base) // e.g. RUNEPFC for RUNE-USD futures pair
if len(s) <= 1 {
return currency.EMPTYPAIR, errInvalidPairSymbol
}
quoteCurr = s[1]
}
quoteCurr = s[1]
} else {
s := strings.Split(m.Symbol, currency.DashDelimiter)
if len(s) != 2 {