mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-08 07:26:48 +00:00
codebase: Cleanup various things (#1935)
* codebase: Rid base64/hex to string common funcs * codebase: Rid local scope variable usage and other improvements * codebase: Refactor currency pair usage across multiple exchanges - Updated HitBTC tests to use the new currency pair format. - Modified Kraken futures types to use currency.Pair instead of string for Symbol. - Adjusted Kraken wrapper methods to handle currency pairs correctly. - Refined OKX tests and types to utilize currency.Pair for instrument IDs. - Enhanced Poloniex tests to consistently use predefined currency pairs. - Streamlined order and orderbook tests to replace string pairs with currency.NewBTCUSD(). - Improved Yobit tests to utilize a standardized currency pair format. - Updated validator wrapper to use currency pairs directly instead of string conversions. * codebase: Use types.Number where possible * refactor: update PayoutFee type to types.Number for consistency * Refactor: Remove crypto functions to use standard library and other minor changes - Removed custom crypto functions for SHA256, SHA512, and MD5 from the common/crypto package. - Replaced usages of removed functions with standard library implementations in various files including: - cmd/websocket_client/main.go - engine/apiserver.go - exchanges/kraken/kraken.go - exchanges/lbank/lbank.go - exchanges/okx/okx_business_websocket.go - exchanges/kucoin/kucoin_websocket.go - gctscript/vm/vm.go - Updated tests to reflect changes in the crypto functions. - Renamed several functions for clarity, particularly in the context of order book updates across multiple exchanges. * refactor: replace assert with require for consistency in test assertions * refactor: Improve Binance futures candlestick test, standardise orderbook update function names and improve test parallelism * refactor: Replace require.Len with require.Equal for better output in TestGetFuturesKlineData
This commit is contained in:
@@ -1457,34 +1457,25 @@ func TestSetGlobalPairsManager(t *testing.T) {
|
||||
assert.ErrorIs(t, err, errConfigPairFormatRequiresDelimiter, "SetGlobalPairsManager should error correctly")
|
||||
}
|
||||
|
||||
func Test_FormatExchangeKlineInterval(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
func TestFormatExchangeKlineInterval(t *testing.T) {
|
||||
t.Parallel()
|
||||
b := Base{}
|
||||
for _, tc := range []struct {
|
||||
interval kline.Interval
|
||||
output string
|
||||
}{
|
||||
{
|
||||
"OneMin",
|
||||
kline.OneMin,
|
||||
"60",
|
||||
},
|
||||
{
|
||||
"OneDay",
|
||||
kline.OneDay,
|
||||
"86400",
|
||||
},
|
||||
}
|
||||
|
||||
b := Base{}
|
||||
for x := range testCases {
|
||||
test := testCases[x]
|
||||
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
ret := b.FormatExchangeKlineInterval(test.interval)
|
||||
|
||||
if ret != test.output {
|
||||
t.Fatalf("unexpected result return expected: %v received: %v", test.output, ret)
|
||||
}
|
||||
} {
|
||||
t.Run(tc.interval.String(), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.Equal(t, tc.output, b.FormatExchangeKlineInterval(tc.interval))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1647,13 +1638,6 @@ func TestKlineIntervalEnabled(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatExchangeKlineInterval(t *testing.T) {
|
||||
b := Base{}
|
||||
if b.FormatExchangeKlineInterval(kline.EightHour) != "28800" {
|
||||
t.Fatal("unexpected value")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetSaveTradeDataStatus(t *testing.T) {
|
||||
b := Base{
|
||||
Features: Features{
|
||||
@@ -1765,24 +1749,13 @@ func TestFormatSymbol(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := b.SetAssetPairStore(asset.Spot, spotStore)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
pair, err := currency.NewPairFromString("BTC-USD")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
sym, err := b.FormatSymbol(pair, asset.Spot)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if sym != "BTCUSD" {
|
||||
t.Error("formatting failed")
|
||||
}
|
||||
_, err = b.FormatSymbol(pair, asset.Futures)
|
||||
if err == nil {
|
||||
t.Error("expecting an error since asset pair format has not been set")
|
||||
}
|
||||
require.NoError(t, err, "SetAssetPairStore must not error")
|
||||
p := currency.NewBTCUSD().Format(*spotStore.ConfigFormat)
|
||||
sym, err := b.FormatSymbol(p, asset.Spot)
|
||||
require.NoError(t, err, "FormatSymbol must not error")
|
||||
assert.Equal(t, "BTCUSD", sym, "FormatSymbol should format the pair correctly")
|
||||
_, err = b.FormatSymbol(p, asset.Futures)
|
||||
assert.ErrorIs(t, err, asset.ErrNotSupported)
|
||||
}
|
||||
|
||||
func TestSetAPIURL(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user