Documentation ¶
Index ¶
- func Compare(t *testing.T, expected interface{}, value interface{})
- func CompareAccount(t *testing.T, a, b *types.Account)
- func CompareAccountStrict(t *testing.T, a, b *types.Account)
- func CompareEngineResponse(t *testing.T, a, b *types.EngineResponse)
- func CompareMatches(t *testing.T, a, b *types.Matches)
- func CompareOrder(t *testing.T, a, b *types.Order)
- func ComparePair(t *testing.T, a, b *types.Pair)
- func ComparePublicOrder(t *testing.T, a, b *types.Order)
- func ComparePublicTrade(t *testing.T, a, b *types.Trade)
- func CompareStructs(t *testing.T, expected interface{}, order interface{})
- func CompareToken(t *testing.T, a, b *types.Token)
- func CompareTrade(t *testing.T, a, b *types.Trade)
- func GetTestAddress1() string
- func GetTestAddress2() string
- func GetTestAddress3() string
- func GetTestOrder1() types.Order
- func GetTestOrder2() types.Order
- func GetTestOrder3() types.Order
- func GetTestTrade1() types.Trade
- func GetTestTrade2() types.Trade
- func GetTestWETHToken() types.Token
- func GetTestZRXToken() types.Token
- func GetZRXWETHTestPair() *types.Pair
- func NewDBTestServer() *dbtest.DBServer
- type Client
- type ClientLogMessage
- type MockDaos
- type MockServices
- type OrderFactory
- func (f *OrderFactory) GetAddress() string
- func (f *OrderFactory) GetMatcherAddress() string
- func (f *OrderFactory) GetWallet() *Wallet
- func (f *OrderFactory) NewBuyOrder(pricepoint float64, value int64, filled ...int64) (types.Order, error)
- func (f *OrderFactory) NewBuyOrderMessage(price float64, amount int64) (*types.WebsocketMessage, *types.Order, error)
- func (f *OrderFactory) NewCancelOrder(o *types.Order) (*types.OrderCancel, error)
- func (f *OrderFactory) NewCancelOrderMessage(o *types.Order) (*types.WebsocketMessage, *types.OrderCancel, error)
- func (f *OrderFactory) NewLargeOrder(baseToken string, quoteToken string, amount int64, pricepoint float64) (*types.Order, error)
- func (f *OrderFactory) NewOrder(baseToken string, quoteToken string, amount int64, pricepoint int64) (*types.Order, error)
- func (f *OrderFactory) NewOrderMessage(baseToken, quoteToken string, amount, pricepoint int64) (*types.WebsocketMessage, *types.Order, error)
- func (f *OrderFactory) NewSellOrder(pricepoint float64, value int64, filled ...int64) (types.Order, error)
- func (f *OrderFactory) NewSellOrderMessage(price float64, amount int64) (*types.WebsocketMessage, *types.Order, error)
- func (f *OrderFactory) NewTrade(o *types.Order, amount int64) (types.Trade, error)
- func (f *OrderFactory) SetMatcherAddress(addr string) error
- type OrderParams
- type Server
- type Wallet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareEngineResponse ¶
func CompareEngineResponse(t *testing.T, a, b *types.EngineResponse)
func CompareStructs ¶
func GetTestAddress1 ¶
func GetTestAddress1() string
func GetTestAddress2 ¶
func GetTestAddress2() string
func GetTestAddress3 ¶
func GetTestAddress3() string
func GetTestOrder1 ¶
func GetTestOrder2 ¶
func GetTestOrder3 ¶
func GetTestTrade1 ¶
func GetTestTrade2 ¶
func GetTestWETHToken ¶
func GetTestZRXToken ¶
func GetZRXWETHTestPair ¶
func NewDBTestServer ¶
Types ¶
type Client ¶
type Client struct { Requests chan *types.WebsocketMessage Responses chan *types.WebsocketMessage Logs chan *ClientLogMessage //Wallet *types.Wallet RequestLogs []types.WebsocketMessage ResponseLogs []types.WebsocketMessage // contains filtered or unexported fields }
Client simulates the client websocket handler that will be used to perform trading. requests and responses are respectively the outbound and incoming messages. requestLogs and responseLogs are arrays of messages that denote the history of received messages wallet is the Obyte account used for orders and trades. mutex is used to prevent concurrent writes on the websocket connection
type ClientLogMessage ¶
type ClientLogMessage struct { MessageType string `json:"messageType"` Orders []*types.Order `json:"order"` Trades []*types.Trade `json:"trade"` Matches *types.Matches `json:"matches"` Tx *string `json:"tx"` ErrorID int8 `json:"errorID"` }
The client log is mostly used for testing. It optionally takes orders, trade, error ids and transaction hashes. All these parameters are optional in order to allow the client log message to take in a lot of different types of messages An error id of -1 means that there was no error.
type MockDaos ¶
type MockDaos struct { AccountDao *mocks.AccountDao OrderDao *mocks.OrderDao TokenDao *mocks.TokenDao TradeDao *mocks.TradeDao PairDao *mocks.PairDao }
func NewMockDaos ¶
func NewMockDaos() *MockDaos
type MockServices ¶
type MockServices struct { AccountService *mocks.AccountService OrderService *mocks.OrderService OrderBookService *mocks.OrderBookService TokenService *mocks.TokenService PairService *mocks.PairService TradeService *mocks.TradeService }
func NewMockServices ¶
func NewMockServices() *MockServices
type OrderFactory ¶
type OrderFactory struct { Wallet *Wallet Pair *types.Pair Params *OrderParams }
Orderfactory simplifies creating orders, trades and cancelOrders objects Pair is the token pair for which the order is created
func NewOrderFactory ¶
NewOrderFactory returns an order factory from a given token pair and a given wallet TODO: Refactor this function to send back an error
func (*OrderFactory) GetAddress ¶
func (f *OrderFactory) GetAddress() string
GetAddress returns the order factory address
func (*OrderFactory) GetMatcherAddress ¶
func (f *OrderFactory) GetMatcherAddress() string
func (*OrderFactory) GetWallet ¶
func (f *OrderFactory) GetWallet() *Wallet
GetWallet returns the order factory wallet
func (*OrderFactory) NewBuyOrder ¶
func (f *OrderFactory) NewBuyOrder(pricepoint float64, value int64, filled ...int64) (types.Order, error)
NewBuyOrder creates a new buy order from the order factory
func (*OrderFactory) NewBuyOrderMessage ¶
func (f *OrderFactory) NewBuyOrderMessage(price float64, amount int64) (*types.WebsocketMessage, *types.Order, error)
func (*OrderFactory) NewCancelOrder ¶
func (f *OrderFactory) NewCancelOrder(o *types.Order) (*types.OrderCancel, error)
func (*OrderFactory) NewCancelOrderMessage ¶
func (f *OrderFactory) NewCancelOrderMessage(o *types.Order) (*types.WebsocketMessage, *types.OrderCancel, error)
func (*OrderFactory) NewLargeOrder ¶
func (*OrderFactory) NewOrder ¶
func (f *OrderFactory) NewOrder(baseToken string, quoteToken string, amount int64, pricepoint int64) (*types.Order, error)
NewOrder returns a new order with the given params. The order is signed by the factory wallet.
func (*OrderFactory) NewOrderMessage ¶
func (f *OrderFactory) NewOrderMessage(baseToken, quoteToken string, amount, pricepoint int64) (*types.WebsocketMessage, *types.Order, error)
NewOrderMessage creates an order with the given params and returns a new PLACE_ORDER message
func (*OrderFactory) NewSellOrder ¶
func (f *OrderFactory) NewSellOrder(pricepoint float64, value int64, filled ...int64) (types.Order, error)
NewBuyOrder returns a new order with the given params. The order is signed by the factory wallet NewBuyOrder computes the AmountBuy and AmountSell parameters from the given amount and price. Currently, the amount, price and order type are also kept. This could be amended in the future (meaning we would let the engine compute OrderBuy, Amount and Price. Ultimately this does not really matter except maybe for convenience/readability purposes)
func (*OrderFactory) NewSellOrderMessage ¶
func (f *OrderFactory) NewSellOrderMessage(price float64, amount int64) (*types.WebsocketMessage, *types.Order, error)
func (*OrderFactory) NewTrade ¶
NewTrade returns a new trade with the given params. The trade is signed by the factory wallet.
func (*OrderFactory) SetMatcherAddress ¶
func (f *OrderFactory) SetMatcherAddress(addr string) error
SetMatcherAddress changes the default exchange address for orders created by this factory
type OrderParams ¶
type OrderParams struct {
MatcherAddress string
}
type Wallet ¶
type Wallet struct {
Address string
}
func GetTestWallet ¶
func GetTestWallet() *Wallet
func GetTestWallet1 ¶
func GetTestWallet1() *Wallet
func GetTestWallet2 ¶
func GetTestWallet2() *Wallet
func GetTestWallet3 ¶
func GetTestWallet3() *Wallet
func GetTestWallet4 ¶
func GetTestWallet4() *Wallet
func GetTestWallet5 ¶
func GetTestWallet5() *Wallet