sharedtestvalues

package
v0.0.0-...-0658b27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WebsocketResponseDefaultTimeout used in websocket testing
	// Defines wait time for receiving websocket response before cancelling
	WebsocketResponseDefaultTimeout = (3 * time.Second)
	// WebsocketResponseExtendedTimeout used in websocket testing
	// Defines wait time for receiving websocket response before cancelling
	WebsocketResponseExtendedTimeout = (15 * time.Second)
	// WebsocketChannelOverrideCapacity used in websocket testing
	// Defines channel capacity as defaults size can block tests
	WebsocketChannelOverrideCapacity = 500

	MockTesting = "Mock testing framework in use for %s exchange on REST endpoints only"
	LiveTesting = "Mock testing bypassed; live testing of REST endpoints in use for %s exchange"
)

This package is only to be referenced in test files

Variables

View Source
var EmptyStringPotentialPattern = `.*float64.*json:"[^"]*,string".*`

EmptyStringPotentialPattern is a regular expression pattern for a potential empty string into float64

Functions

func AreAPICredentialsSet

func AreAPICredentialsSet(exch exchange.IBotExchange) bool

AreAPICredentialsSet returns if the API credentials are set.

func ForceFileStandard

func ForceFileStandard(t *testing.T, pattern string) error

ForceFileStandard will check all files in the current directory for a regular expression pattern. If the pattern is found the test will fail.

func GetWebsocketInterfaceChannelOverride

func GetWebsocketInterfaceChannelOverride() chan interface{}

GetWebsocketInterfaceChannelOverride returns a new interface based channel with the capacity set to WebsocketChannelOverrideCapacity

func GetWebsocketStructChannelOverride

func GetWebsocketStructChannelOverride() chan struct{}

GetWebsocketStructChannelOverride returns a new struct based channel with the capacity set to WebsocketChannelOverrideCapacity

func NewTestWebsocket

func NewTestWebsocket() *stream.Websocket

NewTestWebsocket returns a test websocket object

func SetupCurrencyPairsForExchangeAsset

func SetupCurrencyPairsForExchangeAsset(t *testing.T, exch exchange.IBotExchange, a asset.Item, cp ...currency.Pair)

SetupCurrencyPairsForExchangeAsset enables an asset for an exchange and adds the currency pair(s) to the available and enabled list of existing pairs if it is already enabled or part of the pairs, no error is raised

func SkipTestIfCannotManipulateOrders

func SkipTestIfCannotManipulateOrders(t *testing.T, exch exchange.IBotExchange, canManipulateOrders bool)

SkipTestIfCannotManipulateOrders will only skip if the credentials are set correctly and can manipulate orders is set to false. It will continue normal operations if credentials are not set, giving better code coverage.

func SkipTestIfCredentialsUnset

func SkipTestIfCredentialsUnset(t *testing.T, exch exchange.IBotExchange, canManipulateOrders ...bool)

SkipTestIfCredentialsUnset is a test helper function checking if the authenticated function can perform the required test.

func TestFixtureToDataHandler

func TestFixtureToDataHandler(t *testing.T, seed, e exchange.IBotExchange, fixturePath string, reader func([]byte) error)

TestFixtureToDataHandler takes a new empty exchange and configures a new websocket handler for it, and squirts the json path contents to it It accepts a reader function, which is probably e.wsHandleData but could be anything

Types

type CustomEx

type CustomEx struct {
	exchange.Base
}

CustomEx creates a mock custom exchange

func (*CustomEx) AuthenticateWebsocket

func (c *CustomEx) AuthenticateWebsocket(_ context.Context) error

AuthenticateWebsocket is a mock method for CustomEx

func (*CustomEx) CancelAllOrders

func (c *CustomEx) CancelAllOrders(_ context.Context, _ *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders is a mock method for CustomEx

func (*CustomEx) CancelBatchOrders

func (c *CustomEx) CancelBatchOrders(_ context.Context, _ []order.Cancel) (*order.CancelBatchResponse, error)

CancelBatchOrders is a mock method for CustomEx

func (*CustomEx) CancelOrder

func (c *CustomEx) CancelOrder(_ context.Context, _ *order.Cancel) error

CancelOrder is a mock method for CustomEx

func (*CustomEx) CheckOrderExecutionLimits

func (c *CustomEx) CheckOrderExecutionLimits(_ asset.Item, _ currency.Pair, _, _ float64, _ order.Type) error

CheckOrderExecutionLimits is a mock method for CustomEx

func (*CustomEx) DisableRateLimiter

func (c *CustomEx) DisableRateLimiter() error

DisableRateLimiter is a mock method for CustomEx

func (*CustomEx) EnableRateLimiter

func (c *CustomEx) EnableRateLimiter() error

EnableRateLimiter is a mock method for CustomEx

func (*CustomEx) FetchAccountInfo

func (c *CustomEx) FetchAccountInfo(_ context.Context, _ asset.Item) (account.Holdings, error)

FetchAccountInfo is a mock method for CustomEx

func (*CustomEx) FetchOrderbook

func (c *CustomEx) FetchOrderbook(_ context.Context, _ currency.Pair, _ asset.Item) (*orderbook.Base, error)

FetchOrderbook is a mock method for CustomEx

func (*CustomEx) FetchTicker

func (c *CustomEx) FetchTicker(_ context.Context, _ currency.Pair, _ asset.Item) (*ticker.Price, error)

FetchTicker is a mock method for CustomEx

func (*CustomEx) FetchTradablePairs

func (c *CustomEx) FetchTradablePairs(_ context.Context, _ asset.Item) (currency.Pairs, error)

FetchTradablePairs is a mock method for CustomEx

func (*CustomEx) FlushWebsocketChannels

func (c *CustomEx) FlushWebsocketChannels() error

FlushWebsocketChannels is a mock method for CustomEx

func (*CustomEx) FormatWithdrawPermissions

func (c *CustomEx) FormatWithdrawPermissions() string

FormatWithdrawPermissions is a mock method for CustomEx

func (*CustomEx) GetAccountFundingHistory

func (c *CustomEx) GetAccountFundingHistory(_ context.Context) ([]exchange.FundingHistory, error)

GetAccountFundingHistory is a mock method for CustomEx

func (*CustomEx) GetActiveOrders

GetActiveOrders is a mock method for CustomEx

func (*CustomEx) GetAssetTypes

func (c *CustomEx) GetAssetTypes(_ bool) asset.Items

GetAssetTypes is a mock method for CustomEx

func (*CustomEx) GetAvailablePairs

func (c *CustomEx) GetAvailablePairs(_ asset.Item) (currency.Pairs, error)

GetAvailablePairs is a mock method for CustomEx

func (*CustomEx) GetBase

func (c *CustomEx) GetBase() *exchange.Base

GetBase is a mock method for CustomEx

func (*CustomEx) GetDepositAddress

func (c *CustomEx) GetDepositAddress(_ context.Context, _ currency.Code, _, _ string) (*deposit.Address, error)

GetDepositAddress is a mock method for CustomEx

func (*CustomEx) GetEnabledPairs

func (c *CustomEx) GetEnabledPairs(_ asset.Item) (currency.Pairs, error)

GetEnabledPairs is a mock method for CustomEx

func (*CustomEx) GetFeeByType

func (c *CustomEx) GetFeeByType(_ context.Context, _ *exchange.FeeBuilder) (float64, error)

GetFeeByType is a mock method for CustomEx

func (*CustomEx) GetFuturesContractDetails

func (c *CustomEx) GetFuturesContractDetails(context.Context, asset.Item) ([]futures.Contract, error)

GetFuturesContractDetails returns all contracts from the exchange by asset type

func (*CustomEx) GetHTTPClientUserAgent

func (c *CustomEx) GetHTTPClientUserAgent() (string, error)

GetHTTPClientUserAgent is a mock method for CustomEx

func (*CustomEx) GetHistoricCandles

func (c *CustomEx) GetHistoricCandles(_ context.Context, _ currency.Pair, _ asset.Item, _ kline.Interval, _, _ time.Time) (*kline.Item, error)

GetHistoricCandles is a mock method for CustomEx

func (*CustomEx) GetHistoricCandlesExtended

func (c *CustomEx) GetHistoricCandlesExtended(_ context.Context, _ currency.Pair, _ asset.Item, _ kline.Interval, _, _ time.Time) (*kline.Item, error)

GetHistoricCandlesExtended is a mock method for CustomEx

func (*CustomEx) GetHistoricTrades

func (c *CustomEx) GetHistoricTrades(_ context.Context, _ currency.Pair, _ asset.Item, _, _ time.Time) ([]trade.Data, error)

GetHistoricTrades is a mock method for CustomEx

func (*CustomEx) GetHistoricalFundingRates

GetHistoricalFundingRates returns funding rates for a given asset and currency for a time period

func (*CustomEx) GetLastPairsUpdateTime

func (c *CustomEx) GetLastPairsUpdateTime() int64

GetLastPairsUpdateTime is a mock method for CustomEx

func (*CustomEx) GetLatestFundingRates

GetLatestFundingRates returns the latest funding rates data

func (*CustomEx) GetName

func (c *CustomEx) GetName() string

GetName is a mock method for CustomEx

func (*CustomEx) GetOrderExecutionLimits

func (c *CustomEx) GetOrderExecutionLimits(_ asset.Item, _ currency.Pair) (order.MinMaxLevel, error)

GetOrderExecutionLimits is a mock method for CustomEx

func (*CustomEx) GetOrderHistory

GetOrderHistory is a mock method for CustomEx

func (*CustomEx) GetOrderInfo

func (c *CustomEx) GetOrderInfo(_ context.Context, _ string, _ currency.Pair, _ asset.Item) (*order.Detail, error)

GetOrderInfo is a mock method for CustomEx

func (*CustomEx) GetRecentTrades

func (c *CustomEx) GetRecentTrades(_ context.Context, _ currency.Pair, _ asset.Item) ([]trade.Data, error)

GetRecentTrades is a mock method for CustomEx

func (*CustomEx) GetServerTime

func (c *CustomEx) GetServerTime(context.Context, asset.Item) (time.Time, error)

GetServerTime is a mock method for CustomEx

func (*CustomEx) GetSubscriptions

func (c *CustomEx) GetSubscriptions() ([]subscription.Subscription, error)

GetSubscriptions is a mock method for CustomEx

func (*CustomEx) GetWebsocket

func (c *CustomEx) GetWebsocket() (*stream.Websocket, error)

GetWebsocket is a mock method for CustomEx

func (*CustomEx) GetWithdrawPermissions

func (c *CustomEx) GetWithdrawPermissions() uint32

GetWithdrawPermissions is a mock method for CustomEx

func (*CustomEx) GetWithdrawalsHistory

func (c *CustomEx) GetWithdrawalsHistory(_ context.Context, _ currency.Code, _ asset.Item) ([]exchange.WithdrawalHistory, error)

GetWithdrawalsHistory is a mock method for CustomEx

func (*CustomEx) IsAssetWebsocketSupported

func (c *CustomEx) IsAssetWebsocketSupported(_ asset.Item) bool

IsAssetWebsocketSupported is a mock method for CustomEx

func (*CustomEx) IsEnabled

func (c *CustomEx) IsEnabled() bool

IsEnabled is a mock method for CustomEx

func (*CustomEx) IsWebsocketEnabled

func (c *CustomEx) IsWebsocketEnabled() bool

IsWebsocketEnabled is a mock method for CustomEx

func (*CustomEx) ModifyOrder

func (c *CustomEx) ModifyOrder(_ context.Context, _ *order.Modify) (*order.ModifyResponse, error)

ModifyOrder is a mock method for CustomEx

func (*CustomEx) SetClientProxyAddress

func (c *CustomEx) SetClientProxyAddress(_ string) error

SetClientProxyAddress is a mock method for CustomEx

func (*CustomEx) SetDefaults

func (c *CustomEx) SetDefaults()

SetDefaults is a mock method for CustomEx

func (*CustomEx) SetEnabled

func (c *CustomEx) SetEnabled(bool)

SetEnabled is a mock method for CustomEx

func (*CustomEx) SetHTTPClientUserAgent

func (c *CustomEx) SetHTTPClientUserAgent(_ string) error

SetHTTPClientUserAgent is a mock method for CustomEx

func (*CustomEx) SetPairs

func (c *CustomEx) SetPairs(_ currency.Pairs, _ asset.Item, _ bool) error

SetPairs is a mock method for CustomEx

func (*CustomEx) Setup

func (c *CustomEx) Setup(_ *config.Exchange) error

Setup is a mock method for CustomEx

func (*CustomEx) SubmitOrder

func (c *CustomEx) SubmitOrder(_ context.Context, _ *order.Submit) (*order.SubmitResponse, error)

SubmitOrder is a mock method for CustomEx

func (*CustomEx) SubscribeToWebsocketChannels

func (c *CustomEx) SubscribeToWebsocketChannels(_ []subscription.Subscription) error

SubscribeToWebsocketChannels is a mock method for CustomEx

func (*CustomEx) SupportsAsset

func (c *CustomEx) SupportsAsset(_ asset.Item) bool

SupportsAsset is a mock method for CustomEx

func (*CustomEx) SupportsAutoPairUpdates

func (c *CustomEx) SupportsAutoPairUpdates() bool

SupportsAutoPairUpdates is a mock method for CustomEx

func (*CustomEx) SupportsREST

func (c *CustomEx) SupportsREST() bool

SupportsREST is a mock method for CustomEx

func (*CustomEx) SupportsRESTTickerBatchUpdates

func (c *CustomEx) SupportsRESTTickerBatchUpdates() bool

SupportsRESTTickerBatchUpdates is a mock method for CustomEx

func (*CustomEx) SupportsWebsocket

func (c *CustomEx) SupportsWebsocket() bool

SupportsWebsocket is a mock method for CustomEx

func (*CustomEx) SupportsWithdrawPermissions

func (c *CustomEx) SupportsWithdrawPermissions(_ uint32) bool

SupportsWithdrawPermissions is a mock method for CustomEx

func (*CustomEx) UnsubscribeToWebsocketChannels

func (c *CustomEx) UnsubscribeToWebsocketChannels(_ []subscription.Subscription) error

UnsubscribeToWebsocketChannels is a mock method for CustomEx

func (*CustomEx) UpdateAccountInfo

func (c *CustomEx) UpdateAccountInfo(_ context.Context, _ asset.Item) (account.Holdings, error)

UpdateAccountInfo is a mock method for CustomEx

func (*CustomEx) UpdateOrderExecutionLimits

func (c *CustomEx) UpdateOrderExecutionLimits(_ context.Context, _ asset.Item) error

UpdateOrderExecutionLimits is a mock method for CustomEx

func (*CustomEx) UpdateOrderbook

func (c *CustomEx) UpdateOrderbook(_ context.Context, _ currency.Pair, _ asset.Item) (*orderbook.Base, error)

UpdateOrderbook is a mock method for CustomEx

func (*CustomEx) UpdateTicker

func (c *CustomEx) UpdateTicker(_ context.Context, _ currency.Pair, _ asset.Item) (*ticker.Price, error)

UpdateTicker is a mock method for CustomEx

func (*CustomEx) UpdateTickers

func (c *CustomEx) UpdateTickers(_ context.Context, _ asset.Item) error

UpdateTickers is a mock method for CustomEx

func (*CustomEx) UpdateTradablePairs

func (c *CustomEx) UpdateTradablePairs(_ context.Context, _ bool) error

UpdateTradablePairs is a mock method for CustomEx

func (*CustomEx) ValidateAPICredentials

func (c *CustomEx) ValidateAPICredentials(_ context.Context, _ asset.Item) error

ValidateAPICredentials is a mock method for CustomEx

func (*CustomEx) WithdrawCryptocurrencyFunds

func (c *CustomEx) WithdrawCryptocurrencyFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds is a mock method for CustomEx

func (*CustomEx) WithdrawFiatFunds

func (c *CustomEx) WithdrawFiatFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds is a mock method for CustomEx

func (*CustomEx) WithdrawFiatFundsToInternationalBank

func (c *CustomEx) WithdrawFiatFundsToInternationalBank(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFundsToInternationalBank is a mock method for CustomEx

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL