mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-09 15:11:10 +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,8 +2,10 @@ package bitflyer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -49,6 +51,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 TestGetLatestBlockCA(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetLatestBlockCA(context.Background())
|
||||
|
||||
@@ -2,6 +2,7 @@ package bitflyer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -108,6 +109,9 @@ func (b *Bitflyer) SetDefaults() {
|
||||
|
||||
// Setup takes in the supplied exchange configuration details and sets params
|
||||
func (b *Bitflyer) Setup(exch *config.Exchange) error {
|
||||
if err := exch.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
if !exch.Enabled {
|
||||
b.SetEnabled(false)
|
||||
return nil
|
||||
@@ -116,12 +120,16 @@ func (b *Bitflyer) Setup(exch *config.Exchange) error {
|
||||
}
|
||||
|
||||
// Start starts the Bitflyer go routine
|
||||
func (b *Bitflyer) Start(wg *sync.WaitGroup) {
|
||||
func (b *Bitflyer) 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 Bitflyer wrapper
|
||||
@@ -443,6 +451,9 @@ func (b *Bitflyer) GetOrderHistory(_ context.Context, _ *order.GetOrdersRequest)
|
||||
|
||||
// GetFeeByType returns an estimate of fee based on the type of transaction
|
||||
func (b *Bitflyer) 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
|
||||
|
||||
Reference in New Issue
Block a user