linter: Enable error checking linter (#766)

* golangci: Enable err checking linter to expose unchecked errors.

* gct: handle errors across the board

* gct: handle errors NOTE: Found bug in FTX (WIP)

* linter: fix issues

* ftx/exchanges: fix bug where error was being returned when setting pair management variables to an already enabled state

* bitmex: fix bug where a dangly supported asset in config danglied up the place.

* linter: fix more linter issues

* linter: fix my terrible spelling.

* currency: fix test

* exchanges: fix tests

* logger: fix test

* exchanges: fix tests

* glorious: nits

* vm: revert rm variable and instigate test
This commit is contained in:
Ryan O'Hara-Reid
2021-08-30 14:06:40 +10:00
committed by GitHub
parent c9ab0b1164
commit 8020e1ec6a
99 changed files with 814 additions and 293 deletions

View File

@@ -386,9 +386,18 @@ func (b *Bittrex) SendAuthHTTPRequest(ep exchange.URL, method, action string, pa
}
}
body = bytes.NewBuffer(payload)
contentHash = crypto.HexEncodeToString(crypto.GetSHA512(payload))
hash, err := crypto.GetSHA512(payload)
if err != nil {
return nil, err
}
contentHash = crypto.HexEncodeToString(hash)
sigPayload := ts + endpoint + path + method + contentHash
hmac = crypto.GetHMAC(crypto.HashSHA512, []byte(sigPayload), []byte(b.API.Credentials.Secret))
hmac, err = crypto.GetHMAC(crypto.HashSHA512,
[]byte(sigPayload),
[]byte(b.API.Credentials.Secret))
if err != nil {
return nil, err
}
headers := make(map[string]string)
headers["Api-Key"] = b.API.Credentials.Key

View File

@@ -339,7 +339,10 @@ func setFeeBuilder() *exchange.FeeBuilder {
// TestGetFeeByTypeOfflineTradeFee logic test
func TestGetFeeByTypeOfflineTradeFee(t *testing.T) {
var feeBuilder = setFeeBuilder()
b.GetFeeByType(feeBuilder)
_, err := b.GetFeeByType(feeBuilder)
if err != nil {
t.Fatal(err)
}
if !areTestAPIKeysSet() {
if feeBuilder.FeeType != exchange.OfflineTradeFee {
t.Errorf("Expected %v, received %v", exchange.OfflineTradeFee, feeBuilder.FeeType)

View File

@@ -155,11 +155,15 @@ func (b *Bittrex) WsAuth() error {
return err
}
timestamp := strconv.FormatInt(time.Now().UnixNano()/1000000, 10)
hmac := crypto.GetHMAC(
hmac, err := crypto.GetHMAC(
crypto.HashSHA512,
[]byte(timestamp+randomContent.String()),
[]byte(b.API.Credentials.Secret),
)
if err != nil {
return err
}
signature := crypto.HexEncodeToString(hmac)
req := WsEventRequest{

View File

@@ -144,7 +144,10 @@ func (b *Bittrex) Setup(exch *config.ExchangeConfig) error {
return nil
}
b.SetupDefaults(exch)
err := b.SetupDefaults(exch)
if err != nil {
return err
}
wsRunningEndpoint, err := b.API.Endpoints.GetURL(exchange.WebsocketSpot)
if err != nil {

View File

@@ -166,7 +166,10 @@ func (b *Bittrex) applyBufferUpdate(pair currency.Pair) error {
"%s error processing update - initiating new orderbook sync via REST: %s\n",
b.Name,
err)
b.obm.setNeedsFetchingBook(pair)
err = b.obm.setNeedsFetchingBook(pair)
if err != nil {
return err
}
}
}
return nil