mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-06 23:16:53 +00:00
tool/exchange_wrapper_coverage: fix regression and implement reflection (#837)
* cmd/tools/exchange: fix regression and implement reflection so as this can dynamically scale to our interface * exchanges: add comment and fix whoopsie * exchanges: fix linter issues * wrapper_cov_tool: add actual full interface method count to get a better perceived deployment * exchanges/tool: addr glorious nits * kraken: remove string in test * exchange_template_tool: fix tmpl issue
This commit is contained in:
@@ -2,9 +2,11 @@ package itbit
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"net/url"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -52,6 +54,20 @@ func TestMain(m *testing.M) {
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func TestStart(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := i.Start(nil)
|
||||
if !errors.Is(err, common.ErrNilPointer) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, common.ErrNilPointer)
|
||||
}
|
||||
var testWg sync.WaitGroup
|
||||
err = i.Start(&testWg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
testWg.Wait()
|
||||
}
|
||||
|
||||
func TestGetTicker(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := i.GetTicker(context.Background(), "XBTUSD")
|
||||
|
||||
@@ -107,6 +107,9 @@ func (i *ItBit) SetDefaults() {
|
||||
|
||||
// Setup sets the exchange parameters from exchange config
|
||||
func (i *ItBit) Setup(exch *config.Exchange) error {
|
||||
if err := exch.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
if !exch.Enabled {
|
||||
i.SetEnabled(false)
|
||||
return nil
|
||||
@@ -115,12 +118,16 @@ func (i *ItBit) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
// Start starts the ItBit go routine
|
||||
func (i *ItBit) Start(wg *sync.WaitGroup) {
|
||||
func (i *ItBit) Start(wg *sync.WaitGroup) error {
|
||||
if wg == nil {
|
||||
return fmt.Errorf("%T %w", wg, common.ErrNilPointer)
|
||||
}
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
i.Run()
|
||||
wg.Done()
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
// Run implements the ItBit wrapper
|
||||
@@ -505,6 +512,9 @@ func (i *ItBit) WithdrawFiatFundsToInternationalBank(_ context.Context, _ *withd
|
||||
|
||||
// GetFeeByType returns an estimate of fee based on type of transaction
|
||||
func (i *ItBit) GetFeeByType(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error) {
|
||||
if feeBuilder == nil {
|
||||
return 0, fmt.Errorf("%T %w", feeBuilder, common.ErrNilPointer)
|
||||
}
|
||||
if !i.AllowAuthenticatedRequest() && // Todo check connection status
|
||||
feeBuilder.FeeType == exchange.CryptocurrencyTradeFee {
|
||||
feeBuilder.FeeType = exchange.OfflineTradeFee
|
||||
|
||||
Reference in New Issue
Block a user