mock

package
v0.0.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FailingMockProvider

type FailingMockProvider struct {
	*StaticMockProvider
}

FailingMockProvider defines a mocked exchange rate provider that always fails when fetching prices.

func NewFailingMockProvider

func NewFailingMockProvider() *FailingMockProvider

NewFailingMockProvider returns a new failing mock provider.

func (FailingMockProvider) GetPrices

GetPrices always fails for the failing mock provider.

func (FailingMockProvider) Name

func (p FailingMockProvider) Name() string

Name returns the name of the failing mock provider.

type StaticMockProvider

type StaticMockProvider struct {
	// contains filtered or unexported fields
}

StaticMockProvider defines a mocked exchange rate provider using fixed exchange rates.

func NewStaticMockProvider

func NewStaticMockProvider() *StaticMockProvider

NewStaticMockProvider returns a new mock provider. The mock provider will always return the same static data. Meant to be used for testing.

func NewStaticMockProviderFromConfig

func NewStaticMockProviderFromConfig(providerConfig config.ProviderConfig) (*StaticMockProvider, error)

NewStaticMockProviderFromConfig constructs a new static mock provider from the config Notice this method expects the TokenNameToSymbol map to be populated w/ entries of the form CurrencyPair.ToString(): big.NewInt(price)

func (StaticMockProvider) GetPairs

GetPairs is a no-op for the mock provider.

func (StaticMockProvider) GetPrices

GetPrices returns the mocked exchange rates.

func (StaticMockProvider) Name

func (p StaticMockProvider) Name() string

Name returns the name of the mock provider.

func (StaticMockProvider) SetPairs

func (p StaticMockProvider) SetPairs(_ ...oracletypes.CurrencyPair)

SetPairs is a no-op for the mock provider.

type StaticMockProviderConfig

type StaticMockProviderConfig struct {
	// TokenPrices is a map of token names to their metadata.
	TokenPrices map[string]string `mapstructure:"tokens" toml:"tokens"`
}

StaticMockProviderConfig is a map of token names to their metadata.

func ReadStaticMockProviderConfigFromFile

func ReadStaticMockProviderConfigFromFile(path string) (StaticMockProviderConfig, error)

ReadStaticMockProviderConfigFromFile reads the static mock provider config from the given file.

type TimeoutMockProvider

type TimeoutMockProvider struct {
	*StaticMockProvider
	// contains filtered or unexported fields
}

TimeoutMockProvider defines a mocked exchange rate provider that always times out when fetching prices.

func NewTimeoutMockProvider

func NewTimeoutMockProvider(timeout time.Duration) (*TimeoutMockProvider, error)

NewTimeoutMockProvider returns a new timeout mock provider.

func (TimeoutMockProvider) GetPrices

GetPrices always times out for the timeout mock provider.

func (TimeoutMockProvider) Name

func (p TimeoutMockProvider) Name() string

Name returns the name of the timeout mock provider.

Jump to

Keyboard shortcuts

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