Files
gocryptotrader/exchanges/alphapoint/alphapoint_test.go
Scott b686cf2e0e Feature: Websocket order handling (#446)
* Initial changes, removing exchange name as an arg and puts it in the pointer struct. Adds case to ws routines

* Adds CancelAllOrders func, adds GetByExchangeAndID. Adds modify handler in routines.go

* initial poor attempts to have bitmex work with new datahandler handlers. fixes ordersides

* bitmex Completes new order

* Better bitmex handling, but not complete. Begins a gargantuan task of unifying order data structs. Sometimes an order update will contain lot's of information, so its best to be able to update all fields of our orders, rather than just an arbitrary subset. As a result, everything will be broken for the foreseeable future :glitch_crab:

* Removes old order handler which did nothing. Updates order properties for everything everywhere - now consistent. Changes order status. Adds asset type and wallet address to all order types

* Adds order updater to update only relevant fields since the object is generic, we don't know what fields are passed from what exchanges. Adds "lastupdated" field to order.Detail. Expands order cancellation for engine orders.

* Ensures that new orders are added to the ordermanager's order store. Saaa many comments. Internalises orderStore get func. Adds internalOrderID to orderdetail and adds websocket support for it

* Fixes a cancelAllOrders oopsie doopsie

* Adds potential func to update orderdetails from an orderdetail struct. Unsure if will keep.

* Begins btcmarkets implementation. Expands order "stringToOrder" funcs to allow for some more flexible string coversions. Removes order.Submit via websocket as it would cause unlimited order place issues :D

* Finishes btc markets without testing

* Adds untested ws auth func to btse

* Finises btse, fixes btcmarkets bug

* Adds coinbasepro support

* Fixes a few more fields in coinbase pro and readds the extra subs

* Begins work on coinbene. Plus theyve added a new ws connection yeee

* Wasted a bunch of time adding support to an additional websocket that isn't needed ;_; Fixed a bug in coinbasepro. Fully kitted out coinbene support. Updates order types with all fields

* Removes extra websocket connection ;_;

* Finishes gemini. Fixes order side unknown

* Adds okgroup support. Moves byte reading to another function to allow for unit testing. Updates routines to use pointers. Updates date update handling for order details

* Finishes order data for okgroup websocket, but starts the STRANGE process of converting all other websocket endpoints to be a little less silly

* Cleans up okroup websocket implementation. Fixes bug in Gemini

* Adds poloniex support. Updates ws order handling

* new bitmex support. Adds some tests now that its all in its own func. Fixes poloniex bug

* Begins work on authenticated binance websocket

* Attempts to track user data via binance websocket

* Maybe finishes Binance websocket support

* Begins adding test coverage to orders.go. Updates names of script properties to match updated

* Begins an experiment with code coverage. Fixes more rebase issues

* Completes orders coverage. Botches a few other things though. Fixes more scripting stuff

* All tests in engine package pass

* Adds some loevely routine tests

* Moves ordermanager to test Bot ordermanager
Adds lovely routine tests to ensure things that get sent to be handled the data handler are handled by the data handler by handling them

* Replaces "wsHandleData" with "wsReadData" as that's what its going to do now.

* Splits all wsHandleData into wsReadData and wsHandleData to allow for easy testing via sending []byte json examples to test proper functionality. Breaks so many tests

* Fixes majority of test issues. But data races which are tough on the engine package

* "Fixes" test by removing shutdown test. It interferes with too many things. Requires some thought

* Tests all the binance websocket points

* Adds better bitfinex websocket support.

* Adds testing for bitfinex, bitstamp and btcmarkets. Fixes websocket bugs encountered

* Adds BTSE ws tests. Fixes bugs in ws

* Adds coinbase pro tests. Fixes any issues

* Coinbene tests

* Starts to handle coinut. Runs into a problem conceptually regarding websocket roundtrip and orders. Both events need to happen without impacting eachother/racing

* Addresses a data race issue regarding websocket and bot order management submission - order submission locks at an earlier point to prevent routines.go from creating an order before order submission creates it. Updates rpcserver to use order management bot to submit orders.

* Finishes the hectic coinut testing

* Adds tests for gateio

* Fixes rebase issues. Updates tests to work without being overloaded

* Begins testing of gemini. fixes up minor issues

* ginishes gemini tests and fixes

* Adds hitbtc tests. Fixes all the many issues with hitbtc websocket

* Adds remaining tests. Increases default test channel limit again

* Begins work towards huobi tests

* Finishes huobi tests

* Fixed all mythical rebase adventures

* Begins kraken transformation

* Finishes kraken. Fixes coinbene leverage now that its changed

* Begins okgroup testing

* Adds okgroup ws tests

* Does some poloniex

* Fixes basic curreny issue by extracting to func

* Begins redesign of poloniex websocket datahandling. Completes authenticated handling, now onto unauth

* Finishes poloniex revision

* Finishes ZB additions

* Fixes data races

* Fixes rebase issues. Fixes bad kraken logic

* Fixes after reviewing code

* lint everywhere

* Fixes lingering lints

* lint

* Adds test coverage to order detail and modify updating

* Fixes linting

* Fixes huge int, fixes date tests

* Adds GetByExchange, adds test for it. Protects fakepass echange. Renames DisplayQty to DisplayQuantity. Removes verbose. Adds some websocket properties.  Updates bitmex asset type in test

* Addresses timestamps, type abbreviations, verbosity. Expands binance kline switch cases. Updates some websocket capabilities.

* Adds coverage to the stringToOrderType/Status functions introduced in PR

* Minor fixes addressing some time, error text and use of StringDataCompareInsensitive

* Introduces shiny new system which checks if there is an awaiting ID, if found, processes via wrapper method, else, goes through wsHandleData method. Removes weird locking system from wrapper/websocket data race. Updates bitfinex to properly handle websocket order requests and notifications

* Moves fakePassingExchange to test_helper. Fixes some order side implementations for trades. Botches a new error type

* Adds new error type to track and handle order classification errors separately

* Fully fleshes out ClassificationError for all instances of status conversion. Even in order trades and some wrapper functions

* Introduces common.SimpleTimeFormat for "2006-01-02 15:04:05". Fixes binance and bitfinex issues with auth endpoint use, map casting. Expands more order.ClassificationError usage. Fixes some more generic websocket response errors

* Future proofs order updating by utilising asset types. Expands testing to accomodate. Adds shiny new time type. Expands wrapper websocket functionality definitions

* minty linty

* Broken end of day code addressing basic nits on comments, returns and currency conversion

* Adds testing to btcmarkets websocket. Also updates websocket orderbook to use update instead

* Fixes fun rebase fun fun so fun

* Addresses minor nits regarding changed interface and comments

* Creates new function `GetRequestFormattedPairAndAssetType` to retrieve a currency pair and asset type based on a string. It will iterate over enabled pairs and compare them to formatted pairs and then return that pair if found.

* Fixes test

* Adds a single line to the end of the file, because that would be really bad if it wasn't there

* Updates fakepassexchange to not use params, updates test params, uses fatal in some tests where its important, updates order manager to have a rwmutex, removes some returns, improves ws key test for binance, updates properties to reflect their actual values, adds some more websocket properties

* Addresses binance switch linting

* Updates leverage property to int64

* Fixes what was broken
2020-03-03 13:32:14 +11:00

594 lines
17 KiB
Go

package alphapoint
import (
"encoding/json"
"log"
"os"
"testing"
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/core"
"github.com/thrasher-corp/gocryptotrader/currency"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
const (
onlineTest = false
apiKey = ""
apiSecret = ""
canManipulateRealOrders = false
)
var a Alphapoint
func TestMain(m *testing.M) {
a.SetDefaults()
a.API.Credentials.Key = apiKey
a.API.Credentials.Secret = apiSecret
a.API.AuthenticatedSupport = true
if a.API.Endpoints.URL != "https://sim3.alphapoint.com:8400" {
log.Fatal("SetDefaults: String Incorrect -", a.API.Endpoints.URL)
}
if a.API.Endpoints.WebsocketURL != "wss://sim3.alphapoint.com:8401/v1/GetTicker/" {
log.Fatal("SetDefaults: String Incorrect -", a.API.Endpoints.WebsocketURL)
}
os.Exit(m.Run())
}
func areTestAPIKeysSet() bool {
return a.ValidateAPICredentials()
}
func TestGetTicker(t *testing.T) {
t.Parallel()
var ticker Ticker
var err error
if onlineTest {
ticker, err = a.GetTicker("BTCUSD")
if err != nil {
t.Fatal("Alphapoint GetTicker init error: ", err)
}
_, err = a.GetTicker("wigwham")
if err == nil {
t.Error("Alphapoint GetTicker Expected error")
}
} else {
mockResp := []byte(
string(`{"high":253.101,"last":249.76,"bid":248.8901,"volume":5.813354,"low":231.21,"ask":248.9012,"Total24HrQtyTraded":52.654968,"Total24HrProduct2Traded":569.05762,"Total24HrNumTrades":4,"sellOrderCount":7,"buyOrderCount":11,"numOfCreateOrders":0,"isAccepted":true}`),
)
err = json.Unmarshal(mockResp, &ticker)
if err != nil {
t.Fatal("Alphapoint GetTicker unmarshalling error: ", err)
}
if ticker.Last != 249.76 {
t.Error("Alphapoint GetTicker expected last = 249.76")
}
}
if ticker.Last < 0 {
t.Error("Alphapoint GetTicker last < 0")
}
}
func TestGetTrades(t *testing.T) {
t.Parallel()
var trades Trades
var err error
if onlineTest {
trades, err = a.GetTrades("BTCUSD", 0, 10)
if err != nil {
t.Fatalf("Init error: %s", err)
}
_, err = a.GetTrades("wigwham", 0, 10)
if err == nil {
t.Fatal("GetTrades Expected error")
}
} else {
mockResp := []byte(
string(`{"isAccepted":true,"dateTimeUtc":635507981548085938,"ins":"BTCUSD","startIndex":0,"count":10,"trades":[{"tid":0,"px":231.8379,"qty":4.913,"unixtime":1399951989,"utcticks":635355487898355234,"incomingOrderSide":0,"incomingServerOrderId":2598,"bookServerOrderId":2588},{"tid":1,"px":7895.1487,"qty":0.25,"unixtime":1403143708,"utcticks":635387405087297421,"incomingOrderSide":0,"incomingServerOrderId":284241,"bookServerOrderId":284235},{"tid":2,"px":7935.058,"qty":0.25,"unixtime":1403195348,"utcticks":635387921488684140,"incomingOrderSide":0,"incomingServerOrderId":575845,"bookServerOrderId":574078},{"tid":3,"px":7935.0448,"qty":0.25,"unixtime":1403195378,"utcticks":635387921780090390,"incomingOrderSide":0,"incomingServerOrderId":576028,"bookServerOrderId":575946},{"tid":4,"px":7933.9566,"qty":0.1168,"unixtime":1403195510,"utcticks":635387923108371640,"incomingOrderSide":0,"incomingServerOrderId":576974,"bookServerOrderId":576947},{"tid":5,"px":7961.0856,"qty":0.25,"unixtime":1403202307,"utcticks":635387991073850156,"incomingOrderSide":0,"incomingServerOrderId":600547,"bookServerOrderId":600338},{"tid":6,"px":7961.1388,"qty":0.011,"unixtime":1403202307,"utcticks":635387991073850156,"incomingOrderSide":0,"incomingServerOrderId":600547,"bookServerOrderId":600418},{"tid":7,"px":7961.2451,"qty":0.02,"unixtime":1403202307,"utcticks":635387991073850156,"incomingOrderSide":0,"incomingServerOrderId":600547,"bookServerOrderId":600428},{"tid":8,"px":7947.1437,"qty":0.09,"unixtime":1403202749,"utcticks":635387995498225156,"incomingOrderSide":0,"incomingServerOrderId":602183,"bookServerOrderId":601745},{"tid":9,"px":7818.5073,"qty":0.25,"unixtime":1403219720,"utcticks":635388165206506406,"incomingOrderSide":0,"incomingServerOrderId":661909,"bookServerOrderId":661620}]}`),
)
err = json.Unmarshal(mockResp, &trades)
if err != nil {
t.Fatal("GetTrades unmarshalling error: ", err)
}
}
if !trades.IsAccepted {
t.Error("GetTrades IsAccepted failed")
}
if trades.Count <= 0 {
t.Error("GetTrades trades count is <= 0")
}
if trades.Instrument != "BTCUSD" {
t.Error("GetTrades instrument is != BTCUSD")
}
}
func TestGetTradesByDate(t *testing.T) {
t.Parallel()
var trades Trades
var err error
if onlineTest {
trades, err = a.GetTradesByDate("BTCUSD", 1414799400, 1414800000)
if err != nil {
t.Errorf("Init error: %s", err)
}
_, err = a.GetTradesByDate("wigwham", 1414799400, 1414800000)
if err == nil {
t.Error("GetTradesByDate Expected error")
}
} else {
mockResp := []byte(
string(`{"isAccepted":true,"dateTimeUtc":635504540880633671,"ins":"BTCUSD","startDate":1414799400,"endDate":1414800000,"trades":[{"tid":11505,"px":334.669,"qty":0.1211,"unixtime":1414799403,"utcticks":635503962032459843,"incomingOrderSide":1,"incomingServerOrderId":5185651,"bookServerOrderId":5162440},{"tid":11506,"px":334.669,"qty":0.1211,"unixtime":1414799405,"utcticks":635503962058446171,"incomingOrderSide":1,"incomingServerOrderId":5186245,"bookServerOrderId":5162440},{"tid":11507,"px":336.498,"qty":0.011,"unixtime":1414799407,"utcticks":635503962072967656,"incomingOrderSide":0,"incomingServerOrderId":5186530,"bookServerOrderId":5178944},{"tid":11508,"px":335.948,"qty":0.011,"unixtime":1414799410,"utcticks":635503962108055546,"incomingOrderSide":0,"incomingServerOrderId":5187260,"bookServerOrderId":5186531}]}`),
)
err = json.Unmarshal(mockResp, &trades)
if err != nil {
t.Fatal("GetTradesByDate unmarshalling error: ", err)
}
}
if trades.DateTimeUTC < 0 {
t.Error("Alphapoint trades.Count value is negative")
}
if trades.EndDate < 0 {
t.Error("Alphapoint trades.DateTimeUTC value is negative")
}
if trades.Instrument != "BTCUSD" {
t.Error("Alphapoint trades.Instrument value is incorrect")
}
if !trades.IsAccepted {
t.Error("Alphapoint trades.IsAccepted value is true")
}
if len(trades.RejectReason) > 0 {
t.Error("Alphapoint trades.IsAccepted value has been returned")
}
if trades.StartDate < 0 {
t.Error("Alphapoint trades.StartIndex value is negative")
}
}
func TestGetOrderbook(t *testing.T) {
t.Parallel()
var orderBook Orderbook
var err error
if onlineTest {
orderBook, err = a.GetOrderbook("BTCUSD")
if err != nil {
t.Errorf("Init error: %s", err)
}
_, err = a.GetOrderbook("wigwham")
if err == nil {
t.Error("GetOrderbook() Expected error")
}
} else {
mockResp := []byte(
string(`{"bids":[{"qty":725,"px":66},{"qty":1289,"px":65},{"qty":1266,"px":64}],"asks":[{"qty":1,"px":67},{"qty":1,"px":69},{"qty":2,"px":70}],"isAccepted":true}`),
)
err = json.Unmarshal(mockResp, &orderBook)
if err != nil {
t.Fatal("TestGetOrderbook unmarshalling error: ", err)
}
if orderBook.Bids[0].Quantity != 725 {
t.Error("TestGetOrderbook Bids[0].Quantity != 725")
}
}
if !orderBook.IsAccepted {
t.Error("Alphapoint orderBook.IsAccepted value is negative")
}
if len(orderBook.Asks) == 0 {
t.Error("Alphapoint orderBook.Asks has len 0")
}
if len(orderBook.Bids) == 0 {
t.Error("Alphapoint orderBook.Bids has len 0")
}
}
func TestGetProductPairs(t *testing.T) {
t.Parallel()
var products ProductPairs
var err error
if onlineTest {
products, err = a.GetProductPairs()
if err != nil {
t.Errorf("Init error: %s", err)
}
} else {
mockResp := []byte(
string(`{"productPairs":[{"name":"LTCUSD","productPairCode":100,"product1Label":"LTC","product1DecimalPlaces":8,"product2Label":"USD","product2DecimalPlaces":6}, {"name":"BTCUSD","productPairCode":99,"product1Label":"BTC","product1DecimalPlaces":8,"product2Label":"USD","product2DecimalPlaces":6}],"isAccepted":true}`),
)
err = json.Unmarshal(mockResp, &products)
if err != nil {
t.Fatal("TestGetProductPairs unmarshalling error: ", err)
}
if products.ProductPairs[0].Name != "LTCUSD" {
t.Error("Alphapoint ProductPairs 0 != LTCUSD")
}
if products.ProductPairs[1].Product1Label != "BTC" {
t.Error("Alphapoint ProductPairs 1 != BTC")
}
}
if !products.IsAccepted {
t.Error("Alphapoint ProductPairs.IsAccepted value is negative")
}
if len(products.ProductPairs) == 0 {
t.Error("Alphapoint ProductPairs len is 0")
}
}
func TestGetProducts(t *testing.T) {
t.Parallel()
var products Products
var err error
if onlineTest {
products, err = a.GetProducts()
if err != nil {
t.Errorf("Init error: %s", err)
}
} else {
mockResp := []byte(
string(`{"products": [{"name": "USD","isDigital": false,"productCode": 0,"decimalPlaces": 4,"fullName": "US Dollar"},{"name": "BTC","isDigital": true,"productCode": 1,"decimalPlaces": 6,"fullName": "Bitcoin"}],"isAccepted": true}`),
)
err = json.Unmarshal(mockResp, &products)
if err != nil {
t.Fatal("TestGetProducts unmarshalling error: ", err)
}
if products.Products[0].Name != "USD" {
t.Error("Alphapoint Products 0 != USD")
}
if products.Products[1].ProductCode != 1 {
t.Error("Alphapoint Products 1 product code != 1")
}
}
if !products.IsAccepted {
t.Error("Alphapoint Products.IsAccepted value is negative")
}
if len(products.Products) == 0 {
t.Error("Alphapoint Products len is 0")
}
}
func TestCreateAccount(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys not set, skipping")
}
err := a.CreateAccount("test", "account", "something@something.com", "0292383745", "lolcat123")
if err != nil {
t.Errorf("Init error: %s", err)
}
err = a.CreateAccount("test", "account", "something@something.com", "0292383745", "bla")
if err == nil {
t.Errorf("CreateAccount() Expected error")
}
err = a.CreateAccount("", "", "", "", "lolcat123")
if err == nil {
t.Errorf("CreateAccount() Expected error")
}
}
func TestGetUserInfo(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys not set, skipping")
}
_, err := a.GetUserInfo()
if err == nil {
t.Error("GetUserInfo() Expected error")
}
}
func TestSetUserInfo(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys not set, skipping")
}
_, err := a.SetUserInfo("bla", "bla", "1", "meh", true, true)
if err == nil {
t.Error("GetUserInfo() Expected error")
}
}
func TestGetAccountInfo(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys not set, skipping")
}
_, err := a.UpdateAccountInfo()
if err == nil {
t.Error("GetUserInfo() Expected error")
}
}
func TestGetAccountTrades(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys not set, skipping")
}
_, err := a.GetAccountTrades("", 1, 2)
if err == nil {
t.Error("GetUserInfo() Expected error")
}
}
func TestGetDepositAddresses(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys not set, skipping")
}
_, err := a.GetDepositAddresses()
if err == nil {
t.Error("GetUserInfo() Expected error")
}
}
func TestWithdrawCoins(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys not set, skipping")
}
err := a.WithdrawCoins("", "", "", 0.01)
if err == nil {
t.Error("GetUserInfo() Expected error")
}
}
func TestCreateOrder(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys not set, skipping")
}
_, err := a.CreateOrder("", "", order.Limit.String(), 0.01, 0)
if err == nil {
t.Error("GetUserInfo() Expected error")
}
}
func TestModifyExistingOrder(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys not set, skipping")
}
_, err := a.ModifyExistingOrder("", 1, 1)
if err == nil {
t.Error("GetUserInfo() Expected error")
}
}
func TestCancelAllExistingOrders(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys not set, skipping")
}
err := a.CancelAllExistingOrders("")
if err == nil {
t.Error("GetUserInfo() Expected error")
}
}
func TestGetOrders(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys not set, skipping")
}
_, err := a.GetOrders()
if err == nil {
t.Error("GetUserInfo() Expected error")
}
}
func TestGetOrderFee(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys not set, skipping")
}
_, err := a.GetOrderFee("", "", 1, 1)
if err == nil {
t.Error("GetUserInfo() Expected error")
}
}
func TestFormatWithdrawPermissions(t *testing.T) {
t.Parallel()
expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + " & " + exchange.WithdrawCryptoWith2FAText + " & " + exchange.NoFiatWithdrawalsText
withdrawPermissions := a.FormatWithdrawPermissions()
if withdrawPermissions != expectedResult {
t.Errorf("Expected: %s, Received: %s", expectedResult, withdrawPermissions)
}
}
func TestGetActiveOrders(t *testing.T) {
t.Parallel()
var getOrdersRequest = order.GetOrdersRequest{
Type: order.AnyType,
}
_, err := a.GetActiveOrders(&getOrdersRequest)
if areTestAPIKeysSet() && err != nil {
t.Errorf("Could not get open orders: %s", err)
} else if !areTestAPIKeysSet() && err == nil {
t.Error("Expecting an error when no keys are set")
}
}
func TestGetOrderHistory(t *testing.T) {
t.Parallel()
var getOrdersRequest = order.GetOrdersRequest{
Type: order.AnyType,
}
_, err := a.GetOrderHistory(&getOrdersRequest)
if areTestAPIKeysSet() && err != nil {
t.Errorf("Could not get order history: %s", err)
} else if !areTestAPIKeysSet() && err == nil {
t.Error("Expecting an error when no keys are set")
}
}
// Any tests below this line have the ability to impact your orders on the exchange. Enable canManipulateRealOrders to run them
// ----------------------------------------------------------------------------------------------------------------------------
func TestSubmitOrder(t *testing.T) {
t.Parallel()
if areTestAPIKeysSet() && !canManipulateRealOrders {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var orderSubmission = &order.Submit{
Pair: currency.Pair{
Delimiter: "_",
Base: currency.BTC,
Quote: currency.USD,
},
Side: order.Buy,
Type: order.Limit,
Price: 1,
Amount: 1,
ClientID: "meowOrder",
}
response, err := a.SubmitOrder(orderSubmission)
if !areTestAPIKeysSet() && err == nil {
t.Error("Expecting an error when no keys are set")
}
if areTestAPIKeysSet() && err != nil {
t.Errorf("Withdraw failed to be placed: %v", err)
if !response.IsOrderPlaced {
t.Errorf("Order failed to be placed: %v", err)
}
}
}
func TestCancelExchangeOrder(t *testing.T) {
t.Parallel()
if areTestAPIKeysSet() && !canManipulateRealOrders {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
currencyPair := currency.NewPair(currency.BTC, currency.LTC)
var orderCancellation = &order.Cancel{
ID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
}
err := a.CancelOrder(orderCancellation)
if !areTestAPIKeysSet() && err == nil {
t.Error("Expecting an error when no keys are set")
}
if areTestAPIKeysSet() && err != nil {
t.Errorf("Withdraw failed to be placed: %v", err)
}
}
func TestCancelAllExchangeOrders(t *testing.T) {
t.Parallel()
if areTestAPIKeysSet() && !canManipulateRealOrders {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
currencyPair := currency.NewPair(currency.BTC, currency.LTC)
var orderCancellation = &order.Cancel{
ID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
}
resp, err := a.CancelAllOrders(orderCancellation)
if !areTestAPIKeysSet() && err == nil {
t.Error("Expecting an error when no keys are set")
}
if areTestAPIKeysSet() && err != nil {
t.Errorf("Withdraw failed to be placed: %v", err)
}
if len(resp.Status) > 0 {
t.Errorf("%v orders failed to cancel", len(resp.Status))
}
}
func TestModifyOrder(t *testing.T) {
t.Parallel()
if areTestAPIKeysSet() && !canManipulateRealOrders {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
_, err := a.ModifyOrder(&order.Modify{})
if err == nil {
t.Error("ModifyOrder() Expected error")
}
}
func TestWithdraw(t *testing.T) {
t.Parallel()
_, err := a.WithdrawCryptocurrencyFunds(&withdraw.Request{})
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not implemented', received %v", err)
}
}
func TestWithdrawFiat(t *testing.T) {
t.Parallel()
if areTestAPIKeysSet() && !canManipulateRealOrders {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
_, err := a.WithdrawFiatFunds(&withdraw.Request{})
if err != common.ErrNotYetImplemented {
t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err)
}
}
func TestWithdrawInternationalBank(t *testing.T) {
t.Parallel()
if areTestAPIKeysSet() && !canManipulateRealOrders {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
_, err := a.WithdrawFiatFundsToInternationalBank(&withdraw.Request{})
if err != common.ErrNotYetImplemented {
t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err)
}
}