mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
BTSE: Fix duplicate pair errors on Million pairs (M_*) (#1401)
* BTSE: Fix duplicate error on Million pairs (M_*) BTSE has listed Pitbull token with two symbols: PIT-USD and M_PIT-USD for millons of PIT / USD. The native token is not tradable, so we ignore them and get a base of M_PIT because that's what later APIs will accept * BTSE: Fix test errors on locked market * Common: Improve AppendError and ExcludeError This change switches from a stateful multiError to caring more about the Unwrap() []error interface, the same as [go standard lib](https://github.com/golang/go/blob/go1.21.4/src/errors/wrap.go#L54-L68) Notably, if we implement Unwrap() []error and do NOT implement Is() then we get free compatibility with the core functions. The only distateful thing here is needing to deeply unwrap fmt.Errorf errors, since they don't flatten. I can't see any way around that * Pairs: Fix exchange config Pairs loading When a pair string contained two punctuation runes, the first one is used, and the configFormat is ignored. This fix checks the list and corrects any with the wrong delimiter, or errors if the format is inconsistent. * BTSE: Fix all tickers retrieved by GetTicker PR #764 introduced GetTickers, but it wasn't rolled out to BTSE. This fix ensures that when one ticker is a locked market, the rest continue to function. Particularly important if the locked market wasn't even enabled anyway. * Kucoin: Fix test config future pairs * BTSE: Remove PIT tests; Token removed BTSE have removed the PIT token pairs All these changes stand, and this just removes the test * ITBit: Fix fatal error on second run This fix removes incorrect config pair delimiter, because it would be re-inserted into config the first run, and then error the second time. This delimiter doesn't match the config we have. There's no implementation of fetching pairs, so what's in config files now is all that matters * Engine: Fix TestConfigAllJsonResponse * Clarity of non-matching json improved * Handling for fixing pair delimiters
This commit is contained in:
@@ -7,9 +7,9 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/thrasher-corp/gocryptotrader/config"
|
||||
)
|
||||
|
||||
@@ -258,28 +258,22 @@ func TestConfigAllJsonResponse(t *testing.T) {
|
||||
t.Parallel()
|
||||
var c config.Config
|
||||
err := c.LoadConfig(config.TestFile, true)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.NoError(t, err, "LoadConfig should not error")
|
||||
|
||||
resp := makeHTTPGetRequest(t, c)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Error("Body not readable", err)
|
||||
}
|
||||
assert.NoError(t, err, "ReadAll should not error")
|
||||
err = resp.Body.Close()
|
||||
if err != nil {
|
||||
t.Error("Body not closable", err)
|
||||
}
|
||||
assert.NoError(t, err, "Close body should not error")
|
||||
|
||||
var responseConfig config.Config
|
||||
jsonErr := json.Unmarshal(body, &responseConfig)
|
||||
if jsonErr != nil {
|
||||
t.Error("Response not parse-able as json", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(responseConfig, c) {
|
||||
t.Error("Json not equal to config")
|
||||
err = json.Unmarshal(body, &responseConfig)
|
||||
assert.NoError(t, err, "Unmarshal should not error")
|
||||
for _, e := range responseConfig.Exchanges {
|
||||
err = e.CurrencyPairs.SetDelimitersFromConfig()
|
||||
assert.NoError(t, err, "SetDelimitersFromConfig should not error")
|
||||
}
|
||||
assert.Equal(t, c, responseConfig, "Config should match api response")
|
||||
}
|
||||
|
||||
// fakeBot is a basic implementation of the iBot interface used for testing
|
||||
|
||||
Reference in New Issue
Block a user