mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
CI: Bump go version, linters and fix minor issues (#1130)
* CI: Bump go version, linters and fix minor issues * Bump version, fix loop variables * Revert * Rid TODOs now that 1.51 has been released
This commit is contained in:
@@ -55,7 +55,7 @@ before_test:
|
||||
|
||||
test_script:
|
||||
# test back-end
|
||||
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0
|
||||
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0
|
||||
- '%GOPATH%\bin\golangci-lint.exe run --verbose'
|
||||
- ps: >-
|
||||
if($env:APPVEYOR_SCHEDULED_BUILD -eq 'true') {
|
||||
|
||||
4
.github/workflows/linter.yml
vendored
4
.github/workflows/linter.yml
vendored
@@ -8,8 +8,8 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19.x'
|
||||
go-version: '1.20.x'
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
version: v1.48.0
|
||||
version: v1.51.0
|
||||
|
||||
2
.github/workflows/proto-lint.yml
vendored
2
.github/workflows/proto-lint.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.19.x
|
||||
go-version: 1.20.x
|
||||
|
||||
- name: Setup build depends
|
||||
run: |
|
||||
|
||||
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@@ -1,7 +1,7 @@
|
||||
on: [push, pull_request]
|
||||
name: CI
|
||||
env:
|
||||
GO_VERSION: 1.19.x
|
||||
GO_VERSION: 1.20.x
|
||||
jobs:
|
||||
backend-psql:
|
||||
name: GoCryptoTrader back-end with PSQL
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,7 +2,10 @@ config.json
|
||||
config.dat
|
||||
node_modules
|
||||
lib
|
||||
|
||||
# VS Code
|
||||
.vscode
|
||||
tmp/
|
||||
|
||||
testdata/dump
|
||||
testdata/preengine_config.json
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
run:
|
||||
timeout: 8m
|
||||
timeout: 10m
|
||||
issues-exit-code: 1
|
||||
tests: true
|
||||
skip-dirs:
|
||||
@@ -12,7 +12,6 @@ linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
# defaults
|
||||
# - deadcode
|
||||
- errcheck
|
||||
- gosimple
|
||||
- govet
|
||||
@@ -20,7 +19,6 @@ linters:
|
||||
- staticcheck
|
||||
- typecheck
|
||||
# - unused
|
||||
# - varcheck
|
||||
|
||||
# disabled by default linters
|
||||
# - asasalint
|
||||
@@ -30,23 +28,27 @@ linters:
|
||||
- containedctx
|
||||
# - contextcheck
|
||||
# - cyclop
|
||||
# - deadcode // abandoned by its owner, replaced by unused
|
||||
- decorder
|
||||
- depguard
|
||||
- dogsled
|
||||
# - dupl
|
||||
- dupword
|
||||
- durationcheck
|
||||
- errchkjson
|
||||
- errname
|
||||
# - errorlint
|
||||
- execinquery
|
||||
# - exhaustive
|
||||
# - exhaustivestruct // abandoned by its owner, replaced with exhaustruct
|
||||
# - exhaustivestruct // abandoned by its owner, replaced by exhaustruct
|
||||
# - exhaustruct
|
||||
- exportloopref
|
||||
# - forbidigo
|
||||
- forcetypeassert
|
||||
# - funlen
|
||||
- gci
|
||||
# - ginkgolinter
|
||||
- gocheckcompilerdirectives
|
||||
# - gochecknoglobals
|
||||
# - gochecknoinits
|
||||
# - gocognit
|
||||
@@ -69,13 +71,16 @@ linters:
|
||||
- grouper
|
||||
# - ifshort // deprecated by its owner
|
||||
# - importas
|
||||
# - interfacebloat
|
||||
# - interfacer // deprecated by its owner
|
||||
# - ireturn
|
||||
# - lll
|
||||
# - loggercheck
|
||||
# - maintidx
|
||||
- makezero
|
||||
# - maligned
|
||||
# - maligned // deprecated by its owner, replaced by govet 'fieldalignment'
|
||||
- misspell
|
||||
# - musttag
|
||||
- nakedret
|
||||
# - nestif
|
||||
- nilerr
|
||||
@@ -84,26 +89,29 @@ linters:
|
||||
- noctx
|
||||
- nolintlint
|
||||
# - nonamedreturns
|
||||
# - nosnakecase
|
||||
# - nosnakecase // deprecated by its owner, replaced by revive 'var-naming'
|
||||
- nosprintfhostport
|
||||
# - paralleltest
|
||||
- prealloc
|
||||
- predeclared
|
||||
# - promlinter
|
||||
- reassign
|
||||
- revive
|
||||
- rowserrcheck
|
||||
# - scopelint // deprecated since v1.39.0, replaced by exportloopref
|
||||
- sqlclosecheck
|
||||
- structcheck
|
||||
# - structcheck // abandoned by its owner, replaced by unused
|
||||
- stylecheck
|
||||
# - tagliatelle
|
||||
- tenv
|
||||
- testableexamples
|
||||
# - testpackage
|
||||
- thelper
|
||||
- tparallel
|
||||
- unconvert
|
||||
- unparam
|
||||
- usestdlibvars
|
||||
# - varcheck // abandoned by its owner, replaced by unused
|
||||
# - varnamelen
|
||||
- wastedassign
|
||||
- whitespace
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.19 as build
|
||||
FROM golang:1.20 as build
|
||||
WORKDIR /go/src/github.com/thrasher-corp/gocryptotrader
|
||||
COPY . .
|
||||
RUN GO111MODULE=on go mod vendor
|
||||
|
||||
2
Makefile
2
Makefile
@@ -1,6 +1,6 @@
|
||||
LDFLAGS = -ldflags "-w -s"
|
||||
GCTPKG = github.com/thrasher-corp/gocryptotrader
|
||||
LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0
|
||||
LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0
|
||||
LINTBIN = $(GOPATH)/bin/golangci-lint
|
||||
GCTLISTENPORT=9050
|
||||
GCTPROFILERLISTENPORT=8085
|
||||
|
||||
@@ -89,6 +89,7 @@ func TestCanTransact(t *testing.T) {
|
||||
expected: false,
|
||||
},
|
||||
} {
|
||||
ti := ti
|
||||
t.Run(ti.side.String(), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if CanTransact(ti.side) != ti.expected {
|
||||
@@ -123,6 +124,7 @@ func TestDataTypeConversion(t *testing.T) {
|
||||
expectErr: true,
|
||||
},
|
||||
} {
|
||||
ti := ti
|
||||
t.Run(ti.title, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
got, err := DataTypeToInt(ti.dataType)
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package crypto
|
||||
|
||||
//nolint:gosec // md5/sha1 hash functions used by some exchanges
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/md5"
|
||||
"crypto/md5" //nolint:gosec // Used for exchanges
|
||||
"crypto/rand"
|
||||
"crypto/sha1"
|
||||
"crypto/sha1" //nolint:gosec // Used for exchanges
|
||||
"crypto/sha256"
|
||||
"crypto/sha512"
|
||||
"encoding/base64"
|
||||
|
||||
@@ -62,7 +62,7 @@ type CommunicationsConfig struct {
|
||||
TelegramConfig TelegramConfig `json:"telegram"`
|
||||
}
|
||||
|
||||
// IsAnyEnabled returns whether or any any comms relayers
|
||||
// IsAnyEnabled returns whether any comms relayers
|
||||
// are enabled
|
||||
func (c *CommunicationsConfig) IsAnyEnabled() bool {
|
||||
if c.SMSGlobalConfig.Enabled ||
|
||||
|
||||
@@ -33,7 +33,7 @@ type SMSGlobal struct {
|
||||
}
|
||||
|
||||
// Setup takes in a SMSGlobal configuration, sets username, password and
|
||||
// and recipient list
|
||||
// recipient list
|
||||
func (s *SMSGlobal) Setup(cfg *base.CommunicationsConfig) {
|
||||
s.Name = cfg.SMSGlobalConfig.Name
|
||||
s.Enabled = cfg.SMSGlobalConfig.Enabled
|
||||
|
||||
@@ -1386,7 +1386,7 @@ func TestCheckExchangeConfigValues(t *testing.T) {
|
||||
t.Error("unexpected values")
|
||||
}
|
||||
|
||||
// Test feature and endpoint migrations migrations
|
||||
// Test feature and endpoint migrations
|
||||
cfg.Exchanges[0].Features = nil
|
||||
cfg.Exchanges[0].SupportsAutoPairUpdates = convert.BoolPtr(true)
|
||||
cfg.Exchanges[0].Websocket = convert.BoolPtr(true)
|
||||
|
||||
@@ -127,7 +127,7 @@ func (c *Coinmarketcap) GetCryptocurrencyHistoricalListings() ([]CryptocurrencyH
|
||||
// NOTE unreachable code but will be utilised at a later date
|
||||
// resp := struct {
|
||||
// Data []CryptocurrencyHistoricalListings `json:"data"`
|
||||
// Status Status `json:"status"`
|
||||
// ServerStatus Status `json:"status"`
|
||||
// }{}
|
||||
|
||||
//nolint:gocritic // unused code, used as example
|
||||
@@ -143,8 +143,8 @@ func (c *Coinmarketcap) GetCryptocurrencyHistoricalListings() ([]CryptocurrencyH
|
||||
// }
|
||||
|
||||
//nolint:gocritic // unused code, used as example
|
||||
// if resp.Status.ErrorCode != 0 {
|
||||
// return resp.Data, errors.New(resp.Status.ErrorMessage)
|
||||
// if resp.ServerStatus.ErrorCode != 0 {
|
||||
// return resp.Data, errors.New(resp.ServerStatus.ErrorMessage)
|
||||
// }
|
||||
|
||||
//nolint:gocritic // unused code, used as example
|
||||
|
||||
@@ -569,8 +569,7 @@ func (bot *Engine) GetSpecificTicker(ctx context.Context, p currency.Pair, excha
|
||||
}
|
||||
|
||||
// GetCollatedExchangeAccountInfoByCoin collates individual exchange account
|
||||
// information and turns into into a map string of
|
||||
// exchange.AccountCurrencyInfo
|
||||
// information and turns it into a map string of exchange.AccountCurrencyInfo
|
||||
func GetCollatedExchangeAccountInfoByCoin(accounts []account.Holdings) map[currency.Code]account.Balance {
|
||||
result := make(map[currency.Code]account.Balance)
|
||||
for x := range accounts {
|
||||
|
||||
@@ -570,7 +570,7 @@ func TestIsRelatablePairs(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Test relationl crypto pairs with with similar names
|
||||
// Test relationl crypto pairs with similar names
|
||||
result = IsRelatablePairs(xbtltc, btcltc, false)
|
||||
if !result {
|
||||
t.Fatal("Unexpected result")
|
||||
|
||||
@@ -2542,10 +2542,7 @@ func fillMissingCandlesWithStoredTrades(startTime, endTime time.Time, klineItem
|
||||
if len(tradeCandles.Candles) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
for i := range tradeCandles.Candles {
|
||||
response.Candles = append(response.Candles, tradeCandles.Candles[i])
|
||||
}
|
||||
response.Candles = append(response.Candles, tradeCandles.Candles...)
|
||||
|
||||
for i := range response.Candles {
|
||||
log.Infof(log.GRPCSys,
|
||||
|
||||
@@ -467,7 +467,7 @@ func (a *Alphapoint) CancelExistingOrder(ctx context.Context, orderID int64, oms
|
||||
return response.CancelOrderID, nil
|
||||
}
|
||||
|
||||
// CancelAllExistingOrders cancels all open orders by symbol
|
||||
// CancelAllExistingOrders cancels all open orders by symbol.
|
||||
// symbol - Instrument code (ex: “BTCUSD”)
|
||||
func (a *Alphapoint) CancelAllExistingOrders(ctx context.Context, omsid string) error {
|
||||
req := make(map[string]interface{})
|
||||
|
||||
@@ -1745,7 +1745,7 @@ func TestReOrderbyID(t *testing.T) {
|
||||
func TestPopulateAcceptableMethods(t *testing.T) {
|
||||
t.Parallel()
|
||||
if acceptableMethods.loaded() {
|
||||
// we may have have been loaded from another test, so reset
|
||||
// we may have been loaded from another test, so reset
|
||||
acceptableMethods.m.Lock()
|
||||
acceptableMethods.a = make(map[string][]string)
|
||||
acceptableMethods.m.Unlock()
|
||||
|
||||
@@ -189,7 +189,7 @@ func (b *Bitmex) SendTrollboxMessage(ctx context.Context, params ChatSendParams)
|
||||
&messages)
|
||||
}
|
||||
|
||||
// GetTrollboxChannels the channels from the the bitmex trollbox
|
||||
// GetTrollboxChannels the channels from the bitmex trollbox
|
||||
func (b *Bitmex) GetTrollboxChannels(ctx context.Context) ([]ChatChannel, error) {
|
||||
var channels []ChatChannel
|
||||
|
||||
@@ -198,7 +198,7 @@ func (b *Bitmex) GetTrollboxChannels(ctx context.Context) ([]ChatChannel, error)
|
||||
&channels)
|
||||
}
|
||||
|
||||
// GetTrollboxConnectedUsers the channels from the the bitmex trollbox
|
||||
// GetTrollboxConnectedUsers the channels from the bitmex trollbox
|
||||
func (b *Bitmex) GetTrollboxConnectedUsers(ctx context.Context) (ConnectedUsers, error) {
|
||||
var users ConnectedUsers
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ type IndexComposite struct {
|
||||
Weight float64 `json:"weight"`
|
||||
}
|
||||
|
||||
// Insurance Insurance Fund Data
|
||||
// Insurance stores insurance fund data
|
||||
type Insurance struct {
|
||||
Currency string `json:"currency"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
|
||||
@@ -483,7 +483,7 @@ func (b *Bitstamp) OpenInternationalBankWithdrawal(ctx context.Context, amount f
|
||||
return resp, b.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, bitstampAPIOpenWithdrawal, true, req, &resp)
|
||||
}
|
||||
|
||||
// GetCryptoDepositAddress returns a depositing address by crypto
|
||||
// GetCryptoDepositAddress returns a depositing address by crypto.
|
||||
// crypto - example "btc", "ltc", "eth", "xrp" or "bch"
|
||||
func (b *Bitstamp) GetCryptoDepositAddress(ctx context.Context, crypto currency.Code) (*DepositAddress, error) {
|
||||
path := crypto.Lower().String() + "_address"
|
||||
|
||||
@@ -826,10 +826,7 @@ func (b *BTCMarkets) GetActiveOrders(ctx context.Context, req *order.GetOrdersRe
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for a := range allPairs {
|
||||
req.Pairs = append(req.Pairs,
|
||||
allPairs[a])
|
||||
}
|
||||
req.Pairs = append(req.Pairs, allPairs...)
|
||||
}
|
||||
|
||||
var resp []order.Detail
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -131,7 +130,6 @@ func (c *COINUT) SetDefaults() {
|
||||
c.WebsocketResponseMaxLimit = exchange.DefaultWebsocketResponseMaxLimit
|
||||
c.WebsocketResponseCheckTimeout = exchange.DefaultWebsocketResponseCheckTimeout
|
||||
c.WebsocketOrderbookBufferLimit = exchange.DefaultWebsocketOrderbookBufferLimit
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
}
|
||||
|
||||
// Setup sets the current exchange configuration
|
||||
|
||||
@@ -1014,7 +1014,7 @@ func (b *Base) StoreAssetPairFormat(a asset.Item, f currency.PairStore) error {
|
||||
}
|
||||
|
||||
// SetGlobalPairsManager sets defined asset and pairs management system with
|
||||
// with global formatting
|
||||
// global formatting
|
||||
func (b *Base) SetGlobalPairsManager(request, config *currency.PairFormat, assets ...asset.Item) error {
|
||||
if request == nil {
|
||||
return fmt.Errorf("%s cannot set pairs manager, request pair format not provided",
|
||||
|
||||
@@ -173,7 +173,7 @@ func TestSetDefaultEndpoints(t *testing.T) {
|
||||
EdgeCase1: "",
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("expecting a warning due due to invalid url val but got an error: %v", err)
|
||||
t.Errorf("expecting a warning due to invalid url value but got an error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ const (
|
||||
// Gemini is the overarching type across the Gemini package, create multiple
|
||||
// instances with differing APIkeys for segregation of roles for authenticated
|
||||
// requests & sessions by appending new sessions to the Session map using
|
||||
// AddSession, if sandbox test is needed append a new session with with the same
|
||||
// AddSession. If sandbox test is needed, append a new session with the same
|
||||
// API keys and change the IsSandbox variable to true.
|
||||
type Gemini struct {
|
||||
exchange.Base
|
||||
|
||||
@@ -905,7 +905,7 @@ func (h *HUOBI) FGetOpenOrders(ctx context.Context, symbol currency.Code, pageIn
|
||||
return resp, h.FuturesAuthenticatedHTTPRequest(ctx, exchange.RestFutures, http.MethodPost, fQueryOpenOrders, nil, req, &resp)
|
||||
}
|
||||
|
||||
// FGetOrderHistory gets order order history for futures
|
||||
// FGetOrderHistory gets order history for futures
|
||||
func (h *HUOBI) FGetOrderHistory(ctx context.Context, contractCode currency.Pair, symbol, tradeType, reqType, orderType string, status []order.Status, createDate, pageIndex, pageSize int64) (FOrderHistoryData, error) {
|
||||
var resp FOrderHistoryData
|
||||
req := make(map[string]interface{})
|
||||
|
||||
@@ -568,7 +568,7 @@ type Trade struct {
|
||||
Timestamp int64 `json:"ts"`
|
||||
}
|
||||
|
||||
// TradeHistory stores the the trade history data
|
||||
// TradeHistory stores the trade history data
|
||||
type TradeHistory struct {
|
||||
ID int64 `json:"id"`
|
||||
Timestamp int64 `json:"ts"`
|
||||
|
||||
@@ -487,7 +487,7 @@ func (i *ItBit) GetOrderInfo(ctx context.Context, orderID string, pair currency.
|
||||
|
||||
// GetDepositAddress returns a deposit address for a specified currency
|
||||
// NOTE: This has not been implemented due to the fact you need to generate a
|
||||
// a specific wallet ID and they restrict the amount of deposit address you can
|
||||
// specific wallet ID and they restrict the amount of deposit addresses you can
|
||||
// request limiting them to 2.
|
||||
func (i *ItBit) GetDepositAddress(_ context.Context, _ currency.Code, _, _ string) (*deposit.Address, error) {
|
||||
return nil, common.ErrNotYetImplemented
|
||||
|
||||
@@ -96,7 +96,6 @@ func TestCreateKline(t *testing.T) {
|
||||
|
||||
tradeTotal := 24000
|
||||
var trades []order.TradeHistory
|
||||
rand.Seed(time.Now().Unix())
|
||||
execution := time.Now()
|
||||
for i := 0; i < tradeTotal; i++ {
|
||||
price, rndTime := 1000+float64(rand.Intn(1000)), rand.Intn(10) //nolint:gosec // no need to import crypo/rand for testing
|
||||
|
||||
@@ -333,7 +333,7 @@ func (k *Item) GetRelativeStrengthIndexOnClose(period int64) ([]float64, error)
|
||||
return ohlc.GetRelativeStrengthIndex(ohlc.Close, period)
|
||||
}
|
||||
|
||||
// GetRelativeStrengthIndex returns the relative strength index from the the
|
||||
// GetRelativeStrengthIndex returns the relative strength index from the
|
||||
// given price set and period.
|
||||
func (o *OHLC) GetRelativeStrengthIndex(option []float64, period int64) ([]float64, error) {
|
||||
if o == nil {
|
||||
|
||||
@@ -1958,7 +1958,7 @@ func (ok *Okx) EstimatedDeliveryExercisePriceSubscription(operation string, asse
|
||||
return ok.wsChannelSubscription(operation, okxChannelEstimatedPrice, assetType, pair, true, true, false)
|
||||
}
|
||||
|
||||
// MarkPriceSubscription to subscribe or unsubscribe to to "mark-price" to retrieve the mark price. Data will be pushed every 200 ms when the mark price changes, and will be pushed every 10 seconds when the mark price does not change.
|
||||
// MarkPriceSubscription to subscribe or unsubscribe to the "mark-price" to retrieve the mark price. Data will be pushed every 200 ms when the mark price changes, and will be pushed every 10 seconds when the mark price does not change.
|
||||
func (ok *Okx) MarkPriceSubscription(operation string, assetType asset.Item, pair currency.Pair) error {
|
||||
return ok.wsChannelSubscription(operation, okxChannelMarkPrice, assetType, pair, false, true, false)
|
||||
}
|
||||
|
||||
@@ -1665,6 +1665,7 @@ func TestIsOrderPlaced(t *testing.T) {
|
||||
}
|
||||
// specific tests
|
||||
for num, tt := range statusTests {
|
||||
num := num
|
||||
tt := tt
|
||||
t.Run(fmt.Sprintf("TEST CASE: %d", num), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -556,7 +556,6 @@ func TestProcessOrderbook(t *testing.T) {
|
||||
|
||||
func deployUnorderedSlice() Items {
|
||||
var items []Item
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
for i := 0; i < 1000; i++ {
|
||||
items = append(items, Item{Amount: 1, Price: rand.Float64(), ID: rand.Int63()}) //nolint:gosec // Not needed in tests
|
||||
}
|
||||
@@ -593,7 +592,6 @@ func TestSorting(t *testing.T) {
|
||||
}
|
||||
|
||||
func deploySliceOrdered() Items {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
var items []Item
|
||||
for i := 0; i < 1000; i++ {
|
||||
items = append(items, Item{Amount: 1, Price: float64(i + 1), ID: rand.Int63()}) //nolint:gosec // Not needed in tests
|
||||
|
||||
@@ -70,8 +70,8 @@ type RetryPolicy func(resp *http.Response, err error) (bool, error)
|
||||
type RequesterOption func(*Requester)
|
||||
|
||||
// Generate defines a closure for functionality outside of the requester to
|
||||
// to generate new *http.Request on every attempt. This minimizes the chance of
|
||||
// being outside of receive window if application rate limiting reduces outbound
|
||||
// generate a new *http.Request on every attempt. This minimizes the chance of
|
||||
// being outside of the receive window if application rate limiting reduces outbound
|
||||
// requests.
|
||||
type Generate func() (*Item, error)
|
||||
|
||||
|
||||
@@ -895,7 +895,6 @@ func TestEnsureMultipleUpdatesViaPrice(t *testing.T) {
|
||||
}
|
||||
|
||||
func deploySliceOrdered(size int) orderbook.Items {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
var items []orderbook.Item
|
||||
for i := 0; i < size; i++ {
|
||||
items = append(items, orderbook.Item{Amount: 1, Price: rand.Float64() + float64(i), ID: rand.Int63()}) //nolint:gosec // Not needed for tests
|
||||
|
||||
@@ -953,7 +953,7 @@ func (w *ChannelSubscription) Equal(s *ChannelSubscription) bool {
|
||||
}
|
||||
|
||||
// GetSubscriptions returns a copied list of subscriptions
|
||||
// subscriptions is a private member and cannot be manipulated
|
||||
// and is a private member that cannot be manipulated
|
||||
func (w *Websocket) GetSubscriptions() []ChannelSubscription {
|
||||
w.subscriptionMutex.Lock()
|
||||
defer w.subscriptionMutex.Unlock()
|
||||
|
||||
@@ -347,8 +347,8 @@ func TestStageNewLogEvent(t *testing.T) {
|
||||
fields.output.StageLogEvent(func() string { return "out" }, "header", "SUBLOGGER", " space ", "", false, false)
|
||||
|
||||
<-w.Finished
|
||||
if contents := w.Read(); contents != "header space space out\n" {
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, "header space space out\n")
|
||||
if contents := w.Read(); contents != "header space space out\n" { //nolint:dupword // False positive
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, "header space space out\n") //nolint:dupword // False positive
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,11 +382,11 @@ func TestInfo(t *testing.T) {
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, "hello")
|
||||
}
|
||||
|
||||
Infoln(sl, "hello", "hello")
|
||||
Infoln(sl, "hello", "goodbye")
|
||||
<-w.Finished
|
||||
contents = w.Read()
|
||||
if !strings.Contains(contents, "hello hello") {
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, "hello hello")
|
||||
if !strings.Contains(contents, "hello goodbye") {
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, "hello goodbye")
|
||||
}
|
||||
|
||||
_, err = SetLevel("TESTYMCTESTALOTINFO", "")
|
||||
@@ -439,11 +439,11 @@ func TestDebug(t *testing.T) {
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, "hello")
|
||||
}
|
||||
|
||||
Debugln(sl, "hello", "hello")
|
||||
Debugln(sl, ":sun_with_face:", ":angrysun:")
|
||||
<-w.Finished
|
||||
contents = w.Read()
|
||||
if !strings.Contains(contents, "hello hello") {
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, "hello hello")
|
||||
if !strings.Contains(contents, ":sun_with_face: :angrysun:") {
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, ":sun_with_face: :angrysun:")
|
||||
}
|
||||
|
||||
_, err = SetLevel("TESTYMCTESTALOTDEBUG", "")
|
||||
@@ -496,11 +496,11 @@ func TestWarn(t *testing.T) {
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, "hello")
|
||||
}
|
||||
|
||||
Warnln(sl, "hello", "hello")
|
||||
Warnln(sl, "hello", "world")
|
||||
<-w.Finished
|
||||
contents = w.Read()
|
||||
if !strings.Contains(contents, "hello hello") {
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, "hello hello")
|
||||
if !strings.Contains(contents, "hello world") {
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, "hello world")
|
||||
}
|
||||
|
||||
_, err = SetLevel("TESTYMCTESTALOTWARN", "")
|
||||
@@ -558,11 +558,11 @@ func TestError(t *testing.T) {
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, "hello")
|
||||
}
|
||||
|
||||
Errorln(sl, "hello", "hello")
|
||||
Errorln(sl, "hello", "goodbye")
|
||||
<-w.Finished
|
||||
contents = w.Read()
|
||||
if !strings.Contains(contents, "hello hello") {
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, "hello hello")
|
||||
if !strings.Contains(contents, "hello goodbye") {
|
||||
t.Errorf("received: '%v' but expected: '%v'", contents, "hello goodbye")
|
||||
}
|
||||
|
||||
_, err = SetLevel("TESTYMCTESTALOTERROR", "")
|
||||
|
||||
Reference in New Issue
Block a user