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:
Ryan O'Hara-Reid
2021-11-17 15:41:21 +11:00
committed by GitHub
parent 7c7aebe22f
commit da3402476e
67 changed files with 878 additions and 239 deletions

View File

@@ -5,6 +5,7 @@ import (
"errors"
"log"
"os"
"sync"
"testing"
"time"
@@ -53,6 +54,20 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}
func TestStart(t *testing.T) {
t.Parallel()
err := b.Start(nil)
if !errors.Is(err, common.ErrNilPointer) {
t.Fatalf("received: '%v' but expected: '%v'", err, common.ErrNilPointer)
}
var testWg sync.WaitGroup
err = b.Start(&testWg)
if err != nil {
t.Fatal(err)
}
testWg.Wait()
}
func TestGetTradablePairs(t *testing.T) {
t.Parallel()
_, err := b.GetTradablePairs(context.Background())

View File

@@ -148,11 +148,15 @@ func (b *Bithumb) SetDefaults() {
// Setup takes in the supplied exchange configuration details and sets params
func (b *Bithumb) Setup(exch *config.Exchange) error {
err := exch.Validate()
if err != nil {
return err
}
if !exch.Enabled {
b.SetEnabled(false)
return nil
}
err := b.SetupDefaults(exch)
err = b.SetupDefaults(exch)
if err != nil {
return err
}
@@ -187,12 +191,16 @@ func (b *Bithumb) Setup(exch *config.Exchange) error {
}
// Start starts the Bithumb go routine
func (b *Bithumb) Start(wg *sync.WaitGroup) {
func (b *Bithumb) Start(wg *sync.WaitGroup) error {
if wg == nil {
return fmt.Errorf("%T %w", wg, common.ErrNilPointer)
}
wg.Add(1)
go func() {
b.Run()
wg.Done()
}()
return nil
}
// Run implements the Bithumb wrapper
@@ -658,6 +666,9 @@ func (b *Bithumb) WithdrawFiatFundsToInternationalBank(_ context.Context, _ *wit
// GetFeeByType returns an estimate of fee based on type of transaction
func (b *Bithumb) GetFeeByType(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error) {
if feeBuilder == nil {
return 0, fmt.Errorf("%T %w", feeBuilder, common.ErrNilPointer)
}
if !b.AllowAuthenticatedRequest() && // Todo check connection status
feeBuilder.FeeType == exchange.CryptocurrencyTradeFee {
feeBuilder.FeeType = exchange.OfflineTradeFee