mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-06 07:26:47 +00:00
(Exchanges) Introduce validation method and small updates (#565)
* Remove pointer reference * Fix portfolio withdraw tests * Add nil protection in validator method to reduce prospective panics and for future outbound checking * Updated tests * ch order var to not ref package * rm comparison * Add order ID validation check * Add exchange name validation check * Add in test details * fix tests * fix linter issues * linter issues strikes again * linter rabbit hole * Addr nitterinos * Add validation variadic interface to define sets of functionality check POC * didn't want to add an amount other than 0, didn't want to add address to exchange withdraw, didn't want to whitlist, can change if need be * add coverage * Add validation method options for exchange wrappers and abstracted validation into its own package * Add validation code for structs in exchange template generation * remove extra validation call as this is done in wrapper * fix niterinos for examplerinos * Add template to documentation tool and regenerated documentation * Addr niticles * Fix tests due to validation update * Add more validation checks for modify/submit orders * update tests * fix more tests * Add asset type to submit variable in tests and rpc call. Regen funcs. * Add field to modify struct in tests * applied field asset to cancel struct across project * fix woopsy
This commit is contained in:
@@ -11,8 +11,6 @@ import (
|
||||
"github.com/thrasher-corp/gocryptotrader/engine"
|
||||
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -33,10 +31,11 @@ func main() {
|
||||
log.Printf("Loading exchanges..")
|
||||
var wg sync.WaitGroup
|
||||
for x := range exchange.Exchanges {
|
||||
name := exchange.Exchanges[x]
|
||||
err := engine.Bot.LoadExchange(name, true, &wg)
|
||||
err := engine.Bot.LoadExchange(exchange.Exchanges[x], true, &wg)
|
||||
if err != nil {
|
||||
log.Printf("Failed to load exchange %s. Err: %s", name, err)
|
||||
log.Printf("Failed to load exchange %s. Err: %s",
|
||||
exchange.Exchanges[x],
|
||||
err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -48,12 +47,12 @@ func main() {
|
||||
wg = sync.WaitGroup{}
|
||||
exchanges := engine.Bot.GetExchanges()
|
||||
for x := range exchanges {
|
||||
exch := exchanges[x]
|
||||
wg.Add(1)
|
||||
go func(num int) {
|
||||
name := exchanges[num].GetName()
|
||||
results[name] = testWrappers(exchanges[num])
|
||||
go func(e exchange.IBotExchange) {
|
||||
results[e.GetName()] = testWrappers(e)
|
||||
wg.Done()
|
||||
}(x)
|
||||
}(exch)
|
||||
}
|
||||
wg.Wait()
|
||||
log.Println("Done.")
|
||||
@@ -127,30 +126,22 @@ func testWrappers(e exchange.IBotExchange) []string {
|
||||
funcs = append(funcs, "GetFundingHistory")
|
||||
}
|
||||
|
||||
s := &order.Submit{
|
||||
Pair: p,
|
||||
Side: order.Buy,
|
||||
Type: order.Limit,
|
||||
Amount: 1000000,
|
||||
Price: 10000000000,
|
||||
ClientID: "meow",
|
||||
}
|
||||
_, err = e.SubmitOrder(s)
|
||||
_, err = e.SubmitOrder(nil)
|
||||
if err == common.ErrNotYetImplemented {
|
||||
funcs = append(funcs, "SubmitOrder")
|
||||
}
|
||||
|
||||
_, err = e.ModifyOrder(&order.Modify{})
|
||||
_, err = e.ModifyOrder(nil)
|
||||
if err == common.ErrNotYetImplemented {
|
||||
funcs = append(funcs, "ModifyOrder")
|
||||
}
|
||||
|
||||
err = e.CancelOrder(&order.Cancel{})
|
||||
err = e.CancelOrder(nil)
|
||||
if err == common.ErrNotYetImplemented {
|
||||
funcs = append(funcs, "CancelOrder")
|
||||
}
|
||||
|
||||
_, err = e.CancelAllOrders(&order.Cancel{})
|
||||
_, err = e.CancelAllOrders(nil)
|
||||
if err == common.ErrNotYetImplemented {
|
||||
funcs = append(funcs, "CancelAllOrders")
|
||||
}
|
||||
@@ -160,12 +151,12 @@ func testWrappers(e exchange.IBotExchange) []string {
|
||||
funcs = append(funcs, "GetOrderInfo")
|
||||
}
|
||||
|
||||
_, err = e.GetOrderHistory(&order.GetOrdersRequest{})
|
||||
_, err = e.GetOrderHistory(nil)
|
||||
if err == common.ErrNotYetImplemented {
|
||||
funcs = append(funcs, "GetOrderHistory")
|
||||
}
|
||||
|
||||
_, err = e.GetActiveOrders(&order.GetOrdersRequest{})
|
||||
_, err = e.GetActiveOrders(nil)
|
||||
if err == common.ErrNotYetImplemented {
|
||||
funcs = append(funcs, "GetActiveOrders")
|
||||
}
|
||||
@@ -175,16 +166,16 @@ func testWrappers(e exchange.IBotExchange) []string {
|
||||
funcs = append(funcs, "GetDepositAddress")
|
||||
}
|
||||
|
||||
_, err = e.WithdrawCryptocurrencyFunds(&withdraw.Request{})
|
||||
_, err = e.WithdrawCryptocurrencyFunds(nil)
|
||||
if err == common.ErrNotYetImplemented {
|
||||
funcs = append(funcs, "WithdrawCryptocurrencyFunds")
|
||||
}
|
||||
|
||||
_, err = e.WithdrawFiatFunds(&withdraw.Request{})
|
||||
_, err = e.WithdrawFiatFunds(nil)
|
||||
if err == common.ErrNotYetImplemented {
|
||||
funcs = append(funcs, "WithdrawFiatFunds")
|
||||
}
|
||||
_, err = e.WithdrawFiatFundsToInternationalBank(&withdraw.Request{})
|
||||
_, err = e.WithdrawFiatFundsToInternationalBank(nil)
|
||||
if err == common.ErrNotYetImplemented {
|
||||
funcs = append(funcs, "WithdrawFiatFundsToInternationalBank")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user