mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-01 07:26:48 +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:
@@ -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