mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-09 15:11:10 +00:00
Engine: Protocol Features, coverage, types, BTC markets websocket (#368)
* Attempts to update orderbook so it doesn't need to sort * Reverts the ws ob stuff. Gets rid of sorting because it happens later. Adds some exchange features * update existing feature lists. Expands list definition to match my emotions * Adds bithumb bitmex and bitstamp. adds a couple more types * Features for you, features for me, features for bittrex, btcmarkets, btse, coinbasepro, coinut, exmo, gateio and gemini * Features for hitbtc, huobi, itbit, kraken, lakebtc, lbank, localbitcoins, okcoin, okex, poloniex, yobit, zb * Who can forget good old alphapoint? * Adds btcmarksets websocket :glitch_crab: fixes alphapoint features * Adds extra data not in the documentation :/ * Replaces websocket features by using protocol features. However, it breaks it due to import cycles. I'm not sure what I'll do just yet * Removes import cycle via duplicate structs. * Increases coverage of config with `TestCheckCurrencyConfigValues`. Moves all currency pair package types into their own files or places it at the bottom of files if necessary * Increase coverage in code.go * One way of determining a test has failed, is when to it fails. Removed redundant explanation * Increases code coverage of conversion * Lint fixes * Fixes orderbook tests * Re-adds sorting because its important to still have the internal pre-processed orderbook to be representative of a real orderbook * Secret lints that did not show up via Windows linting * Adds protocol package to contain exchange features * Fixes protocol implementation * Fixes ws tests * Addresses the following: Removes st-st-stutters in config types, changes GetAvailableForexProviders -> GetSupportedForexProviders, removes errors from tests where error is nil, removes orderbook setup when not necessary, removes import newlines, removes false bools from declaration, changes should of to should have * imports and casing * Fixes two more nil error checks
This commit is contained in:
@@ -14,16 +14,16 @@ func TestGetEthereumBalance(t *testing.T) {
|
||||
|
||||
response, err := GetEthereumBalance(address)
|
||||
if err != nil {
|
||||
t.Errorf("Test Failed - Portfolio GetEthereumBalance() Error: %s", err)
|
||||
t.Errorf("Portfolio GetEthereumBalance() Error: %s", err)
|
||||
}
|
||||
|
||||
if response.Address != "0xb794f5ea0ba39494ce839613fffba74279579268" {
|
||||
t.Error("Test Failed - Portfolio GetEthereumBalance() address invalid")
|
||||
t.Error("Portfolio GetEthereumBalance() address invalid")
|
||||
}
|
||||
|
||||
response, err = GetEthereumBalance(nonsenseAddress)
|
||||
if response.Error.Message != "" || err == nil {
|
||||
t.Errorf("Test Failed - Portfolio GetEthereumBalance() Error: %s",
|
||||
t.Errorf("Portfolio GetEthereumBalance() Error: %s",
|
||||
response.Error.Message)
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ func TestGetCryptoIDBalance(t *testing.T) {
|
||||
ltcAddress := "LX2LMYXtuv5tiYEMztSSoEZcafFPYJFRK1"
|
||||
_, err := GetCryptoIDAddress(ltcAddress, currency.LTC)
|
||||
if err != nil {
|
||||
t.Fatalf("Test failed. TestGetCryptoIDBalance error: %s", err)
|
||||
t.Fatalf("TestGetCryptoIDBalance error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func TestGetAddressBalance(t *testing.T) {
|
||||
ltc)
|
||||
|
||||
if addBalance != balance {
|
||||
t.Error("Test Failed - Portfolio GetAddressBalance() Error: Incorrect value")
|
||||
t.Error("Portfolio GetAddressBalance() Error: Incorrect value")
|
||||
}
|
||||
|
||||
addBalance, found := portfolio.GetAddressBalance("WigWham",
|
||||
@@ -58,10 +58,10 @@ func TestGetAddressBalance(t *testing.T) {
|
||||
ltc)
|
||||
|
||||
if addBalance != 0 {
|
||||
t.Error("Test Failed - Portfolio GetAddressBalance() Error: Incorrect value")
|
||||
t.Error("Portfolio GetAddressBalance() Error: Incorrect value")
|
||||
}
|
||||
if found {
|
||||
t.Error("Test Failed - Portfolio GetAddressBalance() Error: Incorrect value")
|
||||
t.Error("Portfolio GetAddressBalance() Error: Incorrect value")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,10 +73,10 @@ func TestExchangeExists(t *testing.T) {
|
||||
0.02)
|
||||
|
||||
if !newBase.ExchangeExists("someaddress") {
|
||||
t.Error("Test Failed - portfolio_test.go - AddressExists error")
|
||||
t.Error("portfolio_test.go - AddressExists error")
|
||||
}
|
||||
if newBase.ExchangeExists("bla") {
|
||||
t.Error("Test Failed - portfolio_test.go - AddressExists error")
|
||||
t.Error("portfolio_test.go - AddressExists error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,10 +88,10 @@ func TestAddressExists(t *testing.T) {
|
||||
0.02)
|
||||
|
||||
if !newbase.AddressExists("someaddress") {
|
||||
t.Error("Test Failed - portfolio_test.go - AddressExists error")
|
||||
t.Error("portfolio_test.go - AddressExists error")
|
||||
}
|
||||
if newbase.AddressExists("bla") {
|
||||
t.Error("Test Failed - portfolio_test.go - AddressExists error")
|
||||
t.Error("portfolio_test.go - AddressExists error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,10 +103,10 @@ func TestExchangeAddressExists(t *testing.T) {
|
||||
0.02)
|
||||
|
||||
if !newbase.ExchangeAddressExists("someaddress", currency.LTC) {
|
||||
t.Error("Test Failed - portfolio_test.go - ExchangeAddressExists error")
|
||||
t.Error("portfolio_test.go - ExchangeAddressExists error")
|
||||
}
|
||||
if newbase.ExchangeAddressExists("TEST", currency.LTC) {
|
||||
t.Error("Test Failed - portfolio_test.go - ExchangeAddressExists error")
|
||||
t.Error("portfolio_test.go - ExchangeAddressExists error")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -117,7 +117,7 @@ func TestAddExchangeAddress(t *testing.T) {
|
||||
newbase.AddExchangeAddress("ANX", currency.BTC, 200)
|
||||
|
||||
if !newbase.ExchangeAddressExists("ANX", currency.BTC) {
|
||||
t.Error("Test Failed - TestExchangeAddressExists address doesn't exist")
|
||||
t.Error("TestExchangeAddressExists address doesn't exist")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func TestUpdateAddressBalance(t *testing.T) {
|
||||
value := newbase.GetPortfolioSummary()
|
||||
if value.Totals[0].Coin != currency.LTC &&
|
||||
value.Totals[0].Balance != 0.03 {
|
||||
t.Error("Test Failed - portfolio_test.go - UpdateUpdateAddressBalance error")
|
||||
t.Error("portfolio_test.go - UpdateUpdateAddressBalance error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,14 +157,14 @@ func TestRemoveAddress(t *testing.T) {
|
||||
420)
|
||||
|
||||
if !newbase.AddressExists("someaddr") {
|
||||
t.Error("Test failed - portfolio_test.go - TestRemoveAddress")
|
||||
t.Error("portfolio_test.go - TestRemoveAddress")
|
||||
}
|
||||
|
||||
newbase.RemoveAddress("someaddr",
|
||||
currency.LTC.String(),
|
||||
currency.NewCode("LTCWALLETTEST"))
|
||||
if newbase.AddressExists("someaddr") {
|
||||
t.Error("Test failed - portfolio_test.go - TestRemoveAddress")
|
||||
t.Error("portfolio_test.go - TestRemoveAddress")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,12 +176,12 @@ func TestRemoveExchangeAddress(t *testing.T) {
|
||||
newbase.AddExchangeAddress(exchangeName, coinType, 420)
|
||||
|
||||
if !newbase.ExchangeAddressExists(exchangeName, coinType) {
|
||||
t.Error("Test failed - portfolio_test.go - TestRemoveAddress")
|
||||
t.Error("portfolio_test.go - TestRemoveAddress")
|
||||
}
|
||||
|
||||
newbase.RemoveExchangeAddress(exchangeName, coinType)
|
||||
if newbase.ExchangeAddressExists(exchangeName, coinType) {
|
||||
t.Error("Test failed - portfolio_test.go - TestRemoveAddress")
|
||||
t.Error("portfolio_test.go - TestRemoveAddress")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ func TestUpdateExchangeAddressBalance(t *testing.T) {
|
||||
|
||||
value := portfolio.GetPortfolioSummary()
|
||||
if value.Totals[0].Coin != currency.LTC && value.Totals[0].Balance != 0.04 {
|
||||
t.Error("Test Failed - portfolio_test.go - UpdateExchangeAddressBalance error")
|
||||
t.Error("portfolio_test.go - UpdateExchangeAddressBalance error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ func TestAddAddress(t *testing.T) {
|
||||
portfolio := GetPortfolio()
|
||||
portfolio.Seed(newbase)
|
||||
if !portfolio.AddressExists("Gibson") {
|
||||
t.Error("Test Failed - portfolio_test.go - AddAddress error")
|
||||
t.Error("portfolio_test.go - AddAddress error")
|
||||
}
|
||||
|
||||
// Test updating balance to <= 0, expected result is to remove the address.
|
||||
@@ -243,7 +243,7 @@ func TestAddAddress(t *testing.T) {
|
||||
-1)
|
||||
|
||||
if newbase.AddressExists("Gibson") {
|
||||
t.Error("Test Failed - portfolio_test.go - AddAddress error")
|
||||
t.Error("portfolio_test.go - AddAddress error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,24 +261,24 @@ func TestUpdatePortfolio(t *testing.T) {
|
||||
[]string{"LdP8Qox1VAhCzLJNqrr74YovaWYyNBUWvL"}, currency.LTC,
|
||||
)
|
||||
if !value {
|
||||
t.Error("Test Failed - portfolio_test.go - UpdatePortfolio error")
|
||||
t.Error("portfolio_test.go - UpdatePortfolio error")
|
||||
}
|
||||
value = portfolio.UpdatePortfolio([]string{"Testy"}, currency.LTC)
|
||||
if value {
|
||||
t.Error("Test Failed - portfolio_test.go - UpdatePortfolio error")
|
||||
t.Error("portfolio_test.go - UpdatePortfolio error")
|
||||
}
|
||||
value = portfolio.UpdatePortfolio(
|
||||
[]string{"LdP8Qox1VAhCzLJNqrr74YovaWYyNBUWvL", "LVa8wZ983PvWtdwXZ8viK6SocMENLCXkEy"},
|
||||
currency.LTC,
|
||||
)
|
||||
if !value {
|
||||
t.Error("Test Failed - portfolio_test.go - UpdatePortfolio error")
|
||||
t.Error("portfolio_test.go - UpdatePortfolio error")
|
||||
}
|
||||
value = portfolio.UpdatePortfolio(
|
||||
[]string{"LdP8Qox1VAhCzLJNqrr74YovaWYyNBUWvL", "Testy"}, currency.LTC,
|
||||
)
|
||||
if value {
|
||||
t.Error("Test Failed - portfolio_test.go - UpdatePortfolio error")
|
||||
t.Error("portfolio_test.go - UpdatePortfolio error")
|
||||
}
|
||||
|
||||
time.Sleep(time.Second * 5)
|
||||
@@ -287,20 +287,20 @@ func TestUpdatePortfolio(t *testing.T) {
|
||||
"0xe853c56864a2ebe4576a807d26fdc4a0ada51919"}, currency.ETH,
|
||||
)
|
||||
if !value {
|
||||
t.Error("Test Failed - portfolio_test.go - UpdatePortfolio error")
|
||||
t.Error("portfolio_test.go - UpdatePortfolio error")
|
||||
}
|
||||
value = portfolio.UpdatePortfolio(
|
||||
[]string{"0xb794f5ea0ba39494ce839613fffba74279579268", "TESTY"}, currency.ETH,
|
||||
)
|
||||
if value {
|
||||
t.Error("Test Failed - portfolio_test.go - UpdatePortfolio error")
|
||||
t.Error("portfolio_test.go - UpdatePortfolio error")
|
||||
}
|
||||
|
||||
value = portfolio.UpdatePortfolio(
|
||||
[]string{PortfolioAddressExchange, PortfolioAddressPersonal}, currency.LTC)
|
||||
|
||||
if !value {
|
||||
t.Error("Test Failed - portfolio_test.go - UpdatePortfolio error")
|
||||
t.Error("portfolio_test.go - UpdatePortfolio error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,21 +314,21 @@ func TestGetPortfolioByExchange(t *testing.T) {
|
||||
value := portfolio.GetPortfolioByExchange("ANX")
|
||||
result, ok := value[currency.LTC]
|
||||
if !ok {
|
||||
t.Error("Test Failed - portfolio_test.go - GetPortfolioByExchange error")
|
||||
t.Error("portfolio_test.go - GetPortfolioByExchange error")
|
||||
}
|
||||
|
||||
if result != 0.07 {
|
||||
t.Error("Test Failed - portfolio_test.go - GetPortfolioByExchange result != 0.10")
|
||||
t.Error("portfolio_test.go - GetPortfolioByExchange result != 0.10")
|
||||
}
|
||||
|
||||
value = portfolio.GetPortfolioByExchange("Bitfinex")
|
||||
result, ok = value[currency.LTC]
|
||||
if !ok {
|
||||
t.Error("Test Failed - portfolio_test.go - GetPortfolioByExchange error")
|
||||
t.Error("portfolio_test.go - GetPortfolioByExchange error")
|
||||
}
|
||||
|
||||
if result != 0.05 {
|
||||
t.Error("Test Failed - portfolio_test.go - GetPortfolioByExchange result != 0.05")
|
||||
t.Error("portfolio_test.go - GetPortfolioByExchange result != 0.05")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,11 +343,11 @@ func TestGetExchangePortfolio(t *testing.T) {
|
||||
|
||||
result, ok := value[currency.LTC]
|
||||
if !ok {
|
||||
t.Error("Test Failed - portfolio_test.go - GetExchangePortfolio error")
|
||||
t.Error("portfolio_test.go - GetExchangePortfolio error")
|
||||
}
|
||||
|
||||
if result != 0.08 {
|
||||
t.Error("Test Failed - portfolio_test.go - GetExchangePortfolio result != 0.08")
|
||||
t.Error("portfolio_test.go - GetExchangePortfolio result != 0.08")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,11 +361,11 @@ func TestGetPersonalPortfolio(t *testing.T) {
|
||||
value := portfolio.GetPersonalPortfolio()
|
||||
result, ok := value[currency.N2O]
|
||||
if !ok {
|
||||
t.Error("Test Failed - portfolio_test.go - GetPersonalPortfolio error")
|
||||
t.Error("portfolio_test.go - GetPersonalPortfolio error")
|
||||
}
|
||||
|
||||
if result != 0.05 {
|
||||
t.Error("Test Failed - portfolio_test.go - GetPersonalPortfolio result != 0.05")
|
||||
t.Error("portfolio_test.go - GetPersonalPortfolio result != 0.05")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,19 +399,19 @@ func TestGetPortfolioSummary(t *testing.T) {
|
||||
}
|
||||
|
||||
if getTotalsVal(currency.LTC).Coin != currency.LTC {
|
||||
t.Error("Test Failed - portfolio_test.go - TestGetPortfolioSummary error")
|
||||
t.Error("portfolio_test.go - TestGetPortfolioSummary error")
|
||||
}
|
||||
|
||||
if getTotalsVal(currency.ETH).Coin == currency.LTC {
|
||||
t.Error("Test Failed - portfolio_test.go - TestGetPortfolioSummary error")
|
||||
t.Error("portfolio_test.go - TestGetPortfolioSummary error")
|
||||
}
|
||||
|
||||
if getTotalsVal(currency.LTC).Balance != 23 {
|
||||
t.Error("Test Failed - portfolio_test.go - TestGetPortfolioSummary error")
|
||||
t.Error("portfolio_test.go - TestGetPortfolioSummary error")
|
||||
}
|
||||
|
||||
if getTotalsVal(currency.BTC).Balance != 200 {
|
||||
t.Error("Test Failed - portfolio_test.go - TestGetPortfolioSummary error")
|
||||
t.Error("portfolio_test.go - TestGetPortfolioSummary error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@ func TestGetPortfolioGroupedCoin(t *testing.T) {
|
||||
portfolio.Seed(newbase)
|
||||
value := portfolio.GetPortfolioGroupedCoin()
|
||||
if value[currency.LTC][0] != "someaddress" && len(value[currency.LTC][0]) != 1 {
|
||||
t.Error("Test Failed - portfolio_test.go - GetPortfolioGroupedCoin error")
|
||||
t.Error("portfolio_test.go - GetPortfolioGroupedCoin error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ func TestSeed(t *testing.T) {
|
||||
portfolio.Seed(newbase)
|
||||
|
||||
if !portfolio.AddressExists("someaddress") {
|
||||
t.Error("Test Failed - portfolio_test.go - Seed error")
|
||||
t.Error("portfolio_test.go - Seed error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ func TestStartPortfolioWatcher(t *testing.T) {
|
||||
portfolio.Seed(newBase)
|
||||
|
||||
if !portfolio.AddressExists("LX2LMYXtuv5tiYEMztSSoEZcafFPYJFRK1") {
|
||||
t.Error("Test Failed - portfolio_test.go - TestStartPortfolioWatcher")
|
||||
t.Error("portfolio_test.go - TestStartPortfolioWatcher")
|
||||
}
|
||||
|
||||
go StartPortfolioWatcher()
|
||||
@@ -463,6 +463,6 @@ func TestStartPortfolioWatcher(t *testing.T) {
|
||||
func TestGetPortfolio(t *testing.T) {
|
||||
ptrBASE := GetPortfolio()
|
||||
if reflect.TypeOf(ptrBASE).String() != "*portfolio.Base" {
|
||||
t.Error("Test Failed - portfolio_test.go - GetoPortfolio error")
|
||||
t.Error("portfolio_test.go - GetoPortfolio error")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user