mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
bitfinex: fix potential panic caused by wrapper issues cmd (#1118)
* bitfinex: fix potential panic caused by wrapper issues cmd * bitfinex: add tests and disallow empty base, empty quote is fine. * rm quote check Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
@@ -1139,10 +1139,7 @@ func disruptFormatting(p currency.Pair) (currency.Pair, error) {
|
||||
if p.Base.IsEmpty() {
|
||||
return currency.EMPTYPAIR, errors.New("cannot disrupt formatting as base is not populated")
|
||||
}
|
||||
if p.Quote.IsEmpty() {
|
||||
return currency.EMPTYPAIR, errors.New("cannot disrupt formatting as quote is not populated")
|
||||
}
|
||||
|
||||
// NOTE: Quote can be empty for margin funding
|
||||
return currency.Pair{
|
||||
Base: p.Base.Upper(),
|
||||
Quote: p.Quote.Lower(),
|
||||
|
||||
@@ -39,6 +39,11 @@
|
||||
"secret": "Secret",
|
||||
"otpSecret": "-"
|
||||
},
|
||||
"binanceus": {
|
||||
"key": "Key",
|
||||
"secret": "Secret",
|
||||
"otpSecret": "-"
|
||||
},
|
||||
"bitfinex": {
|
||||
"key": "Key",
|
||||
"secret": "Secret",
|
||||
@@ -80,6 +85,11 @@
|
||||
"secret": "Secret",
|
||||
"otpSecret": "-"
|
||||
},
|
||||
"bybit": {
|
||||
"key": "Key",
|
||||
"secret": "Secret",
|
||||
"otpSecret": "-"
|
||||
},
|
||||
"coinbasepro": {
|
||||
"key": "Key",
|
||||
"secret": "Secret",
|
||||
@@ -148,10 +158,10 @@
|
||||
"otpSecret": "-"
|
||||
},
|
||||
"okx": {
|
||||
"key": "Key",
|
||||
"secret": "Secret",
|
||||
"clientID": "ClientID",
|
||||
"otpSecret": "-"
|
||||
"key": "Key",
|
||||
"secret": "Secret",
|
||||
"clientID": "ClientID",
|
||||
"otpSecret": "-"
|
||||
},
|
||||
"poloniex": {
|
||||
"key": "Key",
|
||||
|
||||
@@ -1567,6 +1567,21 @@ func TestFixCasing(t *testing.T) {
|
||||
if ret != "fUSD" {
|
||||
t.Errorf("unexpected result: %v", ret)
|
||||
}
|
||||
|
||||
_, err = b.fixCasing(currency.NewPair(currency.EMPTYCODE, currency.BTC), asset.MarginFunding)
|
||||
if !errors.Is(err, currency.ErrCurrencyPairEmpty) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, currency.ErrCurrencyPairEmpty)
|
||||
}
|
||||
|
||||
_, err = b.fixCasing(currency.NewPair(currency.BTC, currency.EMPTYCODE), asset.MarginFunding)
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
|
||||
_, err = b.fixCasing(currency.EMPTYPAIR, asset.MarginFunding)
|
||||
if !errors.Is(err, currency.ErrCurrencyPairEmpty) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, currency.ErrCurrencyPairEmpty)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_FormatExchangeKlineInterval(t *testing.T) {
|
||||
|
||||
@@ -1158,6 +1158,9 @@ func (b *Bitfinex) GetHistoricCandlesExtended(ctx context.Context, pair currency
|
||||
}
|
||||
|
||||
func (b *Bitfinex) fixCasing(in currency.Pair, a asset.Item) (string, error) {
|
||||
if in.IsEmpty() || in.Base.IsEmpty() {
|
||||
return "", currency.ErrCurrencyPairEmpty
|
||||
}
|
||||
var checkString [2]byte
|
||||
if a == asset.Spot || a == asset.Margin {
|
||||
checkString[0] = 't'
|
||||
|
||||
Reference in New Issue
Block a user