mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-28 15:10:32 +00:00
* Removed package-lock.json form gitignore as it ensures specific package versions * Updated all @angular web dependencies * Resolved tslint errors using autofix option * Resolved some more tslint issues * Added lint scripts to package.json to easy lint the ts files * Updated codelyzer and tslint * Run web on travis using node 10 and run the lint task * Resolved some more tslint issues after upgrading tslint and codelyzer * Resolved golint issues with regards to exchange comments * Resolved spelling errors shown by goreportcard.com * Resolved gofmt warnings using goreportcard.com * Resolved golint issue by removing unrequired else statement * Refactored slack.go to reduce cyclomatic complexity * Fixed govet issue where Slack was passed as value instead of reference
202 lines
4.6 KiB
Go
202 lines
4.6 KiB
Go
package btcmarkets
|
|
|
|
import (
|
|
"net/url"
|
|
"testing"
|
|
|
|
"github.com/thrasher-/gocryptotrader/config"
|
|
"github.com/thrasher-/gocryptotrader/currency/pair"
|
|
exchange "github.com/thrasher-/gocryptotrader/exchanges"
|
|
)
|
|
|
|
var bm BTCMarkets
|
|
|
|
// Please supply your own keys here to do better tests
|
|
const (
|
|
apiKey = ""
|
|
apiSecret = ""
|
|
)
|
|
|
|
func TestSetDefaults(t *testing.T) {
|
|
bm.SetDefaults()
|
|
}
|
|
|
|
func TestSetup(t *testing.T) {
|
|
cfg := config.GetConfig()
|
|
cfg.LoadConfig("../../testdata/configtest.json")
|
|
bConfig, err := cfg.GetExchangeConfig("BTC Markets")
|
|
if err != nil {
|
|
t.Error("Test Failed - BTC Markets Setup() init error")
|
|
}
|
|
|
|
if apiKey != "" && apiSecret != "" {
|
|
bConfig.APIKey = apiKey
|
|
bConfig.APISecret = apiSecret
|
|
bConfig.AuthenticatedAPISupport = true
|
|
}
|
|
|
|
bm.Setup(bConfig)
|
|
}
|
|
|
|
func TestGetFee(t *testing.T) {
|
|
t.Parallel()
|
|
if fee := bm.GetFee(); fee == 0 {
|
|
t.Error("Test failed - GetFee() error")
|
|
}
|
|
}
|
|
|
|
func TestGetTicker(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := bm.GetTicker("BTC", "AUD")
|
|
if err != nil {
|
|
t.Error("Test failed - GetTicker() error", err)
|
|
}
|
|
}
|
|
|
|
func TestGetOrderbook(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := bm.GetOrderbook("BTC", "AUD")
|
|
if err != nil {
|
|
t.Error("Test failed - GetOrderbook() error", err)
|
|
}
|
|
}
|
|
|
|
func TestGetTrades(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := bm.GetTrades("BTC", "AUD", nil)
|
|
if err != nil {
|
|
t.Error("Test failed - GetTrades() error", err)
|
|
}
|
|
|
|
val := url.Values{}
|
|
val.Set("since", "0")
|
|
_, err = bm.GetTrades("BTC", "AUD", val)
|
|
if err != nil {
|
|
t.Error("Test failed - GetTrades() error", err)
|
|
}
|
|
}
|
|
|
|
func TestNewOrder(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := bm.NewOrder("AUD", "BTC", 0, 0, "Bid", "limit", "testTest")
|
|
if err == nil {
|
|
t.Error("Test failed - NewOrder() error", err)
|
|
}
|
|
}
|
|
|
|
func TestCancelOrder(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := bm.CancelOrder([]int64{1337})
|
|
if err == nil {
|
|
t.Error("Test failed - CancelOrder() error", err)
|
|
}
|
|
}
|
|
|
|
func TestGetOrders(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := bm.GetOrders("AUD", "BTC", 10, 0, false)
|
|
if err == nil {
|
|
t.Error("Test failed - GetOrders() error", err)
|
|
}
|
|
_, err = bm.GetOrders("AUD", "BTC", 10, 0, true)
|
|
if err == nil {
|
|
t.Error("Test failed - GetOrders() error", err)
|
|
}
|
|
}
|
|
|
|
func TestGetOrderDetail(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := bm.GetOrderDetail([]int64{1337})
|
|
if err == nil {
|
|
t.Error("Test failed - GetOrderDetail() error", err)
|
|
}
|
|
}
|
|
|
|
func TestGetAccountBalance(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := bm.GetAccountBalance()
|
|
if err == nil {
|
|
t.Error("Test failed - GetAccountBalance() error", err)
|
|
}
|
|
}
|
|
|
|
func TestWithdrawCrypto(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := bm.WithdrawCrypto(0, "BTC", "LOLOLOL")
|
|
if err == nil {
|
|
t.Error("Test failed - WithdrawCrypto() error", err)
|
|
}
|
|
}
|
|
|
|
func TestWithdrawAUD(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := bm.WithdrawAUD("BLA", "1337", "blawest", "1336", 10000000)
|
|
if err == nil {
|
|
t.Error("Test failed - WithdrawAUD() error", err)
|
|
}
|
|
}
|
|
|
|
func TestGetExchangeAccountInfo(t *testing.T) {
|
|
_, err := bm.GetExchangeAccountInfo()
|
|
if err == nil {
|
|
t.Error("Test failed - GetExchangeAccountInfo() error", err)
|
|
}
|
|
}
|
|
|
|
func TestGetExchangeFundTransferHistory(t *testing.T) {
|
|
_, err := bm.GetExchangeFundTransferHistory()
|
|
if err == nil {
|
|
t.Error("Test failed - GetExchangeAccountInfo() error", err)
|
|
}
|
|
}
|
|
|
|
func TestSubmitExchangeOrder(t *testing.T) {
|
|
p := pair.NewCurrencyPair("LTC", "AUD")
|
|
_, err := bm.SubmitExchangeOrder(p, exchange.OrderSideSell(), exchange.OrderTypeMarket(), 0, 0.0, "testID001")
|
|
if err == nil {
|
|
t.Error("Test failed - SubmitExchangeOrder() error", err)
|
|
}
|
|
}
|
|
|
|
func TestModifyExchangeOrder(t *testing.T) {
|
|
_, err := bm.ModifyExchangeOrder(1337, exchange.ModifyOrder{})
|
|
if err == nil {
|
|
t.Error("Test failed - ModifyExchangeOrder() error", err)
|
|
}
|
|
}
|
|
|
|
func TestCancelExchangeOrder(t *testing.T) {
|
|
err := bm.CancelExchangeOrder(1337)
|
|
if err == nil {
|
|
t.Error("Test failed - CancelExchangeOrder() error", err)
|
|
}
|
|
}
|
|
|
|
func TestCancelAllExchangeOrders(t *testing.T) {
|
|
err := bm.CancelAllExchangeOrders()
|
|
if err == nil {
|
|
t.Error("Test failed - CancelAllExchangeOrders() error", err)
|
|
}
|
|
}
|
|
|
|
func TestGetExchangeOrderInfo(t *testing.T) {
|
|
_, err := bm.GetExchangeOrderInfo(1337)
|
|
if err == nil {
|
|
t.Error("Test failed - GetExchangeOrderInfo() error", err)
|
|
}
|
|
}
|
|
|
|
func TestWithdrawCryptoExchangeFunds(t *testing.T) {
|
|
_, err := bm.WithdrawCryptoExchangeFunds("someaddress", "ltc", 0)
|
|
if err == nil {
|
|
t.Error("Test failed - WithdrawExchangeFunds() error", err)
|
|
}
|
|
}
|
|
|
|
func TestWithdrawFiatExchangeFunds(t *testing.T) {
|
|
_, err := bm.WithdrawFiatExchangeFunds("AUD", 0)
|
|
if err == nil {
|
|
t.Error("Test failed - WithdrawFiatExchangeFunds() error", err)
|
|
}
|
|
}
|