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:
Ryan O'Hara-Reid
2023-01-24 16:50:59 +11:00
committed by GitHub
parent 1d779c301b
commit 05558aabfb
4 changed files with 33 additions and 8 deletions

View File

@@ -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) {

View File

@@ -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'