mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +00:00
testing: bybit references, bybit mock testing, pair formatting, standards improvement (#1322)
* fixes tests * pair formats and extra fixes * quick change before shazbert sees * sneaky lint * adds bybit mock testing and fixes test * whoops * error response instead * classic forgetting to lint * bybit live test no longer auto-records results * ty thrasher- Update exchanges/bybit/bybit_wrapper.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> --------- Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
@@ -33,6 +33,9 @@ func TestMain(m *testing.M) {
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
// singleExchangeOverride enter an exchange name to only test that exchange
|
||||
var singleExchangeOverride = ""
|
||||
|
||||
func TestAllExchangeWrappers(t *testing.T) {
|
||||
t.Parallel()
|
||||
cfg := config.GetConfig()
|
||||
@@ -47,6 +50,9 @@ func TestAllExchangeWrappers(t *testing.T) {
|
||||
if common.StringDataContains(unsupportedExchangeNames, name) {
|
||||
t.Skipf("skipping unsupported exchange %v", name)
|
||||
}
|
||||
if singleExchangeOverride != "" && name != singleExchangeOverride {
|
||||
t.Skip("skipping ", name, " due to override")
|
||||
}
|
||||
ctx := context.Background()
|
||||
if isCITest() && common.StringDataContains(blockedCIExchanges, name) {
|
||||
// rather than skipping tests where execution is blocked, provide an expired
|
||||
@@ -158,7 +164,6 @@ func executeExchangeWrapperTests(ctx context.Context, t *testing.T, exch exchang
|
||||
t.Helper()
|
||||
iExchange := reflect.TypeOf(&exch).Elem()
|
||||
actualExchange := reflect.ValueOf(exch)
|
||||
|
||||
for x := 0; x < iExchange.NumMethod(); x++ {
|
||||
methodName := iExchange.Method(x).Name
|
||||
if _, ok := excludedMethodNames[methodName]; ok {
|
||||
@@ -510,6 +515,7 @@ var excludedMethodNames = map[string]struct{}{
|
||||
// blockedCIExchanges are exchanges that are not able to be tested on CI
|
||||
var blockedCIExchanges = []string{
|
||||
"binance", // binance API is banned from executing within the US where github Actions is ran
|
||||
"bybit", // bybit API is banned from executing within the US where github Actions is ran
|
||||
}
|
||||
|
||||
var unsupportedExchangeNames = []string{
|
||||
@@ -554,11 +560,23 @@ var warningErrors = []error{
|
||||
// likelihood of returning data from API endpoints
|
||||
func getPairFromPairs(t *testing.T, p currency.Pairs) (currency.Pair, error) {
|
||||
t.Helper()
|
||||
pFmt, err := p.GetFormatting()
|
||||
if err != nil {
|
||||
return currency.Pair{}, err
|
||||
}
|
||||
goodEth := currency.NewPair(currency.ETH, currency.USDT).Format(pFmt)
|
||||
if p.Contains(goodEth, true) {
|
||||
return goodEth, nil
|
||||
}
|
||||
for i := range p {
|
||||
if p[i].Base.Equal(currency.ETH) {
|
||||
return p[i], nil
|
||||
}
|
||||
}
|
||||
goodBtc := currency.NewPair(currency.BTC, currency.USDT).Format(pFmt)
|
||||
if p.Contains(goodBtc, true) {
|
||||
return goodBtc, nil
|
||||
}
|
||||
for i := range p {
|
||||
if p[i].Base.Equal(currency.BTC) {
|
||||
return p[i], nil
|
||||
|
||||
Reference in New Issue
Block a user