exchange

package
v0.0.0-...-fbfbb0b Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixtureToDataHandler

func FixtureToDataHandler(tb testing.TB, fixturePath string, reader func([]byte) error)

FixtureToDataHandler squirts the contents of a file to a reader function (probably e.wsHandleData) and asserts no errors are returned

func MockHTTPInstance

func MockHTTPInstance(e exchange.IBotExchange) error

MockHTTPInstance takes an existing Exchange instance and attaches it to a new http server It is expected to be run once, since http requests do not often tangle with each other

func MockWsInstance

func MockWsInstance[T any, PT interface {
	*T
	exchange.IBotExchange
}](tb testing.TB, h http.HandlerFunc) *T

MockWsInstance creates a new Exchange instance with a mock websocket instance and HTTP server It accepts an exchange package type argument and a http.HandlerFunc See CurryWsMockUpgrader for a convenient way to curry t and a ws mock function It is expected to be run from any WS tests which need a specific response function No default subscriptions will be run since they disrupt unit tests

func Setup

func Setup(e exchange.IBotExchange) error

Setup takes an empty exchange instance and loads config for it from testdata/configtest and connects a NewTestWebsocket

func SetupWs

func SetupWs(tb testing.TB, e exchange.IBotExchange)

SetupWs is a helper function to connect both auth and normal websockets It will skip the test if websockets are not enabled It's up to the test to skip if it requires creds, though

func UpdatePairsOnce

func UpdatePairsOnce(tb testing.TB, e exchange.IBotExchange)

UpdatePairsOnce ensures pairs are only updated once in parallel tests A clone of the cache of the updated pairs is used to populate duplicate requests Any pairs enabled after this is called will be lost on the next call

Types

type FixtureError

type FixtureError struct {
	Err error
	Msg []byte
}

FixtureError contains an error and the message that caused it

func FixtureToDataHandlerWithErrors

func FixtureToDataHandlerWithErrors(tb testing.TB, fixturePath string, reader func([]byte) error) []FixtureError

FixtureToDataHandlerWithErrors squirts the contents of a file to a reader function (probably e.wsHandleData) and returns handler errors Any errors setting up the fixture will fail tests

Jump to

Keyboard shortcuts

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