mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-18 15:10:03 +00:00
Bump golangci-lint, Docker and Go CI versions (#564)
* Bump golangci-lint and Go CI versions * Bump golangci-lint version * Address nitterinos
This commit is contained in:
@@ -320,7 +320,8 @@ func (b *Bitflyer) SendHTTPRequest(path string, result interface{}) error {
|
||||
// if you have access and update the authenticated requests
|
||||
// TODO: Fill out this function once API access is obtained
|
||||
func (b *Bitflyer) SendAuthHTTPRequest() {
|
||||
// nolint: gocritic headers := make(map[string]string)
|
||||
// nolint:gocritic // code example
|
||||
// headers := make(map[string]string)
|
||||
// headers["ACCESS-KEY"] = b.API.Credentials.Key
|
||||
// headers["ACCESS-TIMESTAMP"] = strconv.FormatInt(time.Now().UnixNano(), 10)
|
||||
}
|
||||
|
||||
@@ -151,13 +151,18 @@ func (b *Bithumb) GetTransactionHistory(symbol string) (TransactionHistory, erro
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// GetAccountInformation returns account information by singular currency
|
||||
func (b *Bithumb) GetAccountInformation(currency string) (Account, error) {
|
||||
response := Account{}
|
||||
// GetAccountInformation returns account information based on the desired
|
||||
// order/payment currencies
|
||||
func (b *Bithumb) GetAccountInformation(orderCurrency, paymentCurrency string) (Account, error) {
|
||||
var response Account
|
||||
if orderCurrency == "" {
|
||||
return response, errors.New("order currency must be set")
|
||||
}
|
||||
|
||||
val := url.Values{}
|
||||
if currency != "" {
|
||||
val.Set("currency", currency)
|
||||
val.Add("order_currency", orderCurrency)
|
||||
if paymentCurrency != "" { // optional param, default is KRW
|
||||
val.Add("payment_currency", paymentCurrency)
|
||||
}
|
||||
|
||||
return response,
|
||||
@@ -477,7 +482,7 @@ func (b *Bithumb) SendAuthenticatedHTTPRequest(path string, params url.Values, r
|
||||
|
||||
params.Set("endpoint", path)
|
||||
payload := params.Encode()
|
||||
hmacPayload := path + string(0) + payload + string(0) + n
|
||||
hmacPayload := path + string('\x00') + payload + string('\x00') + n
|
||||
hmac := crypto.GetHMAC(crypto.HashSHA512,
|
||||
[]byte(hmacPayload),
|
||||
[]byte(b.API.Credentials.Secret))
|
||||
|
||||
@@ -92,6 +92,25 @@ func TestGetTransactionHistory(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAccountInformation(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Offline test
|
||||
_, err := b.GetAccountInformation("", "")
|
||||
if err == nil {
|
||||
t.Error("expected error when no order currency is specified")
|
||||
}
|
||||
|
||||
if !areTestAPIKeysSet() {
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
_, err = b.GetAccountInformation(testCurrency, currency.KRW.String())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAccountBalance(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !areTestAPIKeysSet() {
|
||||
|
||||
@@ -338,7 +338,7 @@ type OrderbookResponse struct {
|
||||
|
||||
// FillResponse contains fill information from the exchange
|
||||
type FillResponse struct {
|
||||
TradeID int `json:"trade_id"`
|
||||
TradeID int64 `json:"trade_id"`
|
||||
ProductID string `json:"product_id"`
|
||||
Price float64 `json:"price,string"`
|
||||
Size float64 `json:"size,string"`
|
||||
|
||||
@@ -560,7 +560,7 @@ func (c *CoinbasePro) GetOrderInfo(orderID string) (order.Detail, error) {
|
||||
}
|
||||
response.Trades = append(response.Trades, order.TradeHistory{
|
||||
Timestamp: fillResponse[i].CreatedAt,
|
||||
TID: string(fillResponse[i].TradeID),
|
||||
TID: strconv.FormatInt(fillResponse[i].TradeID, 10),
|
||||
Price: fillResponse[i].Price,
|
||||
Amount: fillResponse[i].Size,
|
||||
Exchange: c.GetName(),
|
||||
|
||||
@@ -494,5 +494,5 @@ func (i *instrumentMap) GetInstrumentIDs() []int64 {
|
||||
}
|
||||
|
||||
func getNonce() int64 {
|
||||
return rand.Int63n(coinutMaxNonce-1) + 1
|
||||
return rand.Int63n(coinutMaxNonce-1) + 1 // nolint:gosec // basic number generation required, no need for crypo/rand
|
||||
}
|
||||
|
||||
@@ -102,11 +102,11 @@ func TestCreateKline(t *testing.T) {
|
||||
rand.Seed(time.Now().Unix())
|
||||
for i := 0; i < 24000; i++ {
|
||||
trades = append(trades, order.TradeHistory{
|
||||
Timestamp: time.Now().Add((time.Duration(rand.Intn(10)) * time.Minute) +
|
||||
(time.Duration(rand.Intn(10)) * time.Second)),
|
||||
Timestamp: time.Now().Add((time.Duration(rand.Intn(10)) * time.Minute) + // nolint:gosec // no need to import crypo/rand for testing
|
||||
(time.Duration(rand.Intn(10)) * time.Second)), // nolint:gosec // no need to import crypo/rand for testing
|
||||
TID: crypto.HexEncodeToString([]byte(string(rune(i)))),
|
||||
Amount: float64(rand.Intn(20)) + 1,
|
||||
Price: 1000 + float64(rand.Intn(1000)),
|
||||
Amount: float64(rand.Intn(20)) + 1, // nolint:gosec // no need to import crypo/rand for testing
|
||||
Price: 1000 + float64(rand.Intn(1000)), // nolint:gosec // no need to import crypo/rand for testing
|
||||
})
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ func TestItem_SortCandlesByTimestamp(t *testing.T) {
|
||||
}
|
||||
|
||||
for x := 0; x < 100; x++ {
|
||||
y := rand.Float64() // nolint gosec: used for generating test data no need to import crypo/rand
|
||||
y := rand.Float64() // nolint:gosec // used for generating test data, no need to import crypo/rand
|
||||
tempKline.Candles = append(tempKline.Candles,
|
||||
Candle{
|
||||
Time: time.Now().AddDate(0, 0, -x),
|
||||
|
||||
@@ -454,12 +454,12 @@ func TestProcessOrderbook(t *testing.T) {
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
newName := "Exchange" + strconv.FormatInt(rand.Int63(), 10)
|
||||
newName := "Exchange" + strconv.FormatInt(rand.Int63(), 10) // nolint:gosec // no need to import crypo/rand for testing
|
||||
newPairs := currency.NewPair(currency.NewCode("BTC"+strconv.FormatInt(rand.Int63(), 10)),
|
||||
currency.NewCode("USD"+strconv.FormatInt(rand.Int63(), 10)))
|
||||
currency.NewCode("USD"+strconv.FormatInt(rand.Int63(), 10))) // nolint:gosec // no need to import crypo/rand for testing
|
||||
|
||||
asks := []Item{{Price: rand.Float64(), Amount: rand.Float64()}}
|
||||
bids := []Item{{Price: rand.Float64(), Amount: rand.Float64()}}
|
||||
asks := []Item{{Price: rand.Float64(), Amount: rand.Float64()}} // nolint:gosec // no need to import crypo/rand for testing
|
||||
bids := []Item{{Price: rand.Float64(), Amount: rand.Float64()}} // nolint:gosec // no need to import crypo/rand for testing
|
||||
base := &Base{
|
||||
Pair: newPairs,
|
||||
Asks: asks,
|
||||
|
||||
@@ -48,12 +48,12 @@ func bidAskGenerator() []orderbook.Item {
|
||||
var response []orderbook.Item
|
||||
randIterator := 100
|
||||
for i := 0; i < randIterator; i++ {
|
||||
price := float64(rand.Intn(1000))
|
||||
price := float64(rand.Intn(1000)) // nolint:gosec // no need to import crypo/rand for testing
|
||||
if price == 0 {
|
||||
price = 1
|
||||
}
|
||||
response = append(response, orderbook.Item{
|
||||
Amount: float64(rand.Intn(10)),
|
||||
Amount: float64(rand.Intn(10)), // nolint:gosec // no need to import crypo/rand for testing
|
||||
Price: price,
|
||||
ID: int64(i),
|
||||
})
|
||||
@@ -124,7 +124,7 @@ func BenchmarkBufferPerformance(b *testing.B) {
|
||||
}
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
randomIndex := rand.Intn(4)
|
||||
randomIndex := rand.Intn(4) // nolint:gosec // no need to import crypo/rand for testing
|
||||
update.Asks = itemArray[randomIndex]
|
||||
update.Bids = itemArray[randomIndex]
|
||||
err = obl.Update(update)
|
||||
@@ -159,7 +159,7 @@ func BenchmarkBufferSortingPerformance(b *testing.B) {
|
||||
}
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
randomIndex := rand.Intn(4)
|
||||
randomIndex := rand.Intn(4) // nolint:gosec // no need to import crypo/rand for testing
|
||||
update.Asks = itemArray[randomIndex]
|
||||
update.Bids = itemArray[randomIndex]
|
||||
err = obl.Update(update)
|
||||
@@ -195,7 +195,7 @@ func BenchmarkBufferSortingByIDPerformance(b *testing.B) {
|
||||
}
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
randomIndex := rand.Intn(4)
|
||||
randomIndex := rand.Intn(4) // nolint:gosec // no need to import crypo/rand for testing
|
||||
update.Asks = itemArray[randomIndex]
|
||||
update.Bids = itemArray[randomIndex]
|
||||
err = obl.Update(update)
|
||||
@@ -229,7 +229,7 @@ func BenchmarkNoBufferPerformance(b *testing.B) {
|
||||
}
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
randomIndex := rand.Intn(4)
|
||||
randomIndex := rand.Intn(4) // nolint:gosec // no need to import crypo/rand for testing
|
||||
update.Asks = itemArray[randomIndex]
|
||||
update.Bids = itemArray[randomIndex]
|
||||
err = obl.Update(update)
|
||||
|
||||
@@ -309,16 +309,17 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
// nolint:gosec // no need to import crypo/rand for testing
|
||||
newName := "Exchange" + strconv.FormatInt(rand.Int63(), 10)
|
||||
newPairs, err := currency.NewPairFromStrings("BTC"+strconv.FormatInt(rand.Int63(), 10),
|
||||
"USD"+strconv.FormatInt(rand.Int63(), 10))
|
||||
newPairs, err := currency.NewPairFromStrings("BTC"+strconv.FormatInt(rand.Int63(), 10), // nolint:gosec // no need to import crypo/rand for testing
|
||||
"USD"+strconv.FormatInt(rand.Int63(), 10)) // nolint:gosec // no need to import crypo/rand for testing
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
tp := Price{
|
||||
Pair: newPairs,
|
||||
Last: rand.Float64(),
|
||||
Last: rand.Float64(), // nolint:gosec // no need to import crypo/rand for testing
|
||||
ExchangeName: newName,
|
||||
AssetType: asset.Spot,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user