mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Tests: Use currency.NewBTCUSD and NewBTCUSDT (#1895)
* Tests: Use currency.NewUSD and NewUSDT Simple refactor to use the provided shortcut methods * Github: Add CI check to ensure NewPair not used Add a step to ensure NewPair(BTC, USD*) isn't used
This commit is contained in:
@@ -118,7 +118,7 @@ func (f *fakerino) GetAvailablePairs(_ asset.Item) (currency.Pairs, error) {
|
||||
if f.GetAvailablePairsError {
|
||||
return nil, errExchange
|
||||
}
|
||||
return currency.Pairs{currency.NewPair(currency.BTC, currency.USD)}, nil
|
||||
return currency.Pairs{currency.NewBTCUSD()}, nil
|
||||
}
|
||||
|
||||
func (f *fakerino) GetBase() *exchange.Base {
|
||||
|
||||
@@ -155,7 +155,7 @@ func TestUpsertJob(t *testing.T) {
|
||||
t.Errorf("error '%v', expected '%v'", err, errCurrencyNotEnabled)
|
||||
}
|
||||
|
||||
dhj.Pair = currency.NewPair(currency.BTC, currency.USD)
|
||||
dhj.Pair = currency.NewBTCUSD()
|
||||
err = m.UpsertJob(dhj, false)
|
||||
if !errors.Is(err, kline.ErrUnsupportedInterval) {
|
||||
t.Errorf("error '%v', expected '%v'", err, kline.ErrUnsupportedInterval)
|
||||
@@ -182,7 +182,7 @@ func TestUpsertJob(t *testing.T) {
|
||||
Nickname: dhj.Nickname,
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: startDate,
|
||||
EndDate: time.Now().Add(-time.Minute),
|
||||
Interval: kline.FifteenMin,
|
||||
@@ -217,7 +217,7 @@ func TestSetJobStatus(t *testing.T) {
|
||||
Nickname: "TestSetJobStatus",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: time.Now().Add(-time.Minute * 5),
|
||||
EndDate: time.Now(),
|
||||
Interval: kline.OneMin,
|
||||
@@ -295,7 +295,7 @@ func TestGetByNickname(t *testing.T) {
|
||||
Nickname: "TestGetByNickname",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: time.Now().Add(-time.Minute * 5),
|
||||
EndDate: time.Now(),
|
||||
Interval: kline.OneMin,
|
||||
@@ -338,7 +338,7 @@ func TestGetByID(t *testing.T) {
|
||||
Nickname: "TestGetByID",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: time.Now().Add(-time.Minute * 5),
|
||||
EndDate: time.Now(),
|
||||
Interval: kline.OneMin,
|
||||
@@ -382,7 +382,7 @@ func TestRetrieveJobs(t *testing.T) {
|
||||
Nickname: "TestRetrieveJobs",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: time.Now().Add(-time.Minute * 5),
|
||||
EndDate: time.Now(),
|
||||
Interval: kline.OneMin,
|
||||
@@ -421,7 +421,7 @@ func TestGetActiveJobs(t *testing.T) {
|
||||
Nickname: "TestGetActiveJobs",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: time.Now().Add(-time.Minute * 5),
|
||||
EndDate: time.Now(),
|
||||
Interval: kline.OneMin,
|
||||
@@ -487,7 +487,7 @@ func TestValidateJob(t *testing.T) {
|
||||
t.Errorf("error '%v', expected '%v'", err, errCurrencyNotEnabled)
|
||||
}
|
||||
|
||||
dhj.Pair = currency.NewPair(currency.BTC, currency.USD)
|
||||
dhj.Pair = currency.NewBTCUSD()
|
||||
err = m.validateJob(dhj)
|
||||
if !errors.Is(err, kline.ErrUnsupportedInterval) {
|
||||
t.Errorf("error '%v', expected '%v'", err, kline.ErrUnsupportedInterval)
|
||||
@@ -547,7 +547,7 @@ func TestGetAllJobStatusBetween(t *testing.T) {
|
||||
Nickname: "TestGetActiveJobs",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: time.Now().Add(-time.Minute * 5),
|
||||
EndDate: time.Now(),
|
||||
Interval: kline.OneMin,
|
||||
@@ -613,7 +613,7 @@ func TestCompareJobsToData(t *testing.T) {
|
||||
Nickname: "TestGenerateJobSummary",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: tt.Add(-time.Minute * 5),
|
||||
EndDate: tt,
|
||||
Interval: kline.OneMin,
|
||||
@@ -662,7 +662,7 @@ func TestRunJob(t *testing.T) { //nolint:tparallel // There is a race condition
|
||||
Nickname: "TestRunJobDataHistoryCandleDataType",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: tt.Add(-kline.FifteenMin.Duration()),
|
||||
EndDate: tt,
|
||||
Interval: kline.FifteenMin,
|
||||
@@ -672,7 +672,7 @@ func TestRunJob(t *testing.T) { //nolint:tparallel // There is a race condition
|
||||
Nickname: "TestRunJobDataHistoryTradeDataType",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: tt.Add(-kline.OneMin.Duration()),
|
||||
EndDate: tt,
|
||||
Interval: kline.OneMin,
|
||||
@@ -682,7 +682,7 @@ func TestRunJob(t *testing.T) { //nolint:tparallel // There is a race condition
|
||||
Nickname: "TestRunJobDataHistoryConvertCandlesDataType",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: tt.Add(-kline.OneHour.Duration()),
|
||||
EndDate: tt,
|
||||
Interval: kline.FifteenMin,
|
||||
@@ -693,7 +693,7 @@ func TestRunJob(t *testing.T) { //nolint:tparallel // There is a race condition
|
||||
Nickname: "TestRunJobDataHistoryConvertTradesDataType",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: tt.Add(-kline.OneHour.Duration()),
|
||||
EndDate: tt,
|
||||
Interval: kline.FifteenMin,
|
||||
@@ -704,7 +704,7 @@ func TestRunJob(t *testing.T) { //nolint:tparallel // There is a race condition
|
||||
Nickname: "TestRunJobDataHistoryCandleValidationDataType",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: tt.Add(-kline.OneHour.Duration()),
|
||||
EndDate: tt,
|
||||
Interval: kline.OneHour,
|
||||
@@ -714,7 +714,7 @@ func TestRunJob(t *testing.T) { //nolint:tparallel // There is a race condition
|
||||
Nickname: "TestRunJobDataHistoryCandleSecondaryValidationDataType",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: tt.Add(-kline.OneMin.Duration()),
|
||||
EndDate: tt,
|
||||
Interval: kline.OneMin,
|
||||
@@ -774,7 +774,7 @@ func TestGenerateJobSummaryTest(t *testing.T) {
|
||||
Nickname: "TestGenerateJobSummary",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: time.Now().Add(-time.Minute * 5),
|
||||
EndDate: time.Now(),
|
||||
Interval: kline.OneMin,
|
||||
@@ -842,7 +842,7 @@ func TestConverters(t *testing.T) {
|
||||
Nickname: "TestProcessJobs",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: time.Now().Add(-time.Hour * 24),
|
||||
EndDate: time.Now(),
|
||||
Interval: kline.OneHour,
|
||||
@@ -915,8 +915,8 @@ func createDHM(t *testing.T) (*DataHistoryManager, *datahistoryjob.DataHistoryJo
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("error '%v', expected '%v'", err, nil)
|
||||
}
|
||||
cp := currency.NewPair(currency.BTC, currency.USD)
|
||||
cp2 := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSD()
|
||||
cp2 := currency.NewBTCUSDT()
|
||||
exch.SetDefaults()
|
||||
b := exch.GetBase()
|
||||
b.CurrencyPairs.Pairs = make(map[asset.Item]*currency.PairStore)
|
||||
@@ -1011,7 +1011,7 @@ func TestProcessCandleData(t *testing.T) {
|
||||
Nickname: "",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: time.Now().Add(-kline.OneHour.Duration() * 2).Truncate(kline.OneHour.Duration()),
|
||||
EndDate: time.Now().Truncate(kline.OneHour.Duration()),
|
||||
Interval: kline.OneHour,
|
||||
@@ -1067,7 +1067,7 @@ func TestProcessTradeData(t *testing.T) {
|
||||
Nickname: "",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: time.Now().Add(-kline.OneHour.Duration() * 2).Truncate(kline.OneHour.Duration()),
|
||||
EndDate: time.Now().Truncate(kline.OneHour.Duration()),
|
||||
Interval: kline.OneHour,
|
||||
@@ -1122,7 +1122,7 @@ func TestConvertJobTradesToCandles(t *testing.T) {
|
||||
Nickname: "",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: time.Now().Add(-kline.OneHour.Duration() * 2),
|
||||
EndDate: time.Now(),
|
||||
Interval: kline.OneHour,
|
||||
@@ -1154,7 +1154,7 @@ func TestUpscaleJobCandleData(t *testing.T) {
|
||||
Nickname: "",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: time.Now().Add(-kline.OneHour.Duration() * 24),
|
||||
EndDate: time.Now(),
|
||||
Interval: kline.OneHour,
|
||||
@@ -1186,7 +1186,7 @@ func TestValidateCandles(t *testing.T) {
|
||||
Nickname: "",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: time.Now().Add(-kline.OneHour.Duration() * 2),
|
||||
EndDate: time.Now(),
|
||||
Interval: kline.OneHour,
|
||||
|
||||
@@ -284,7 +284,7 @@ func TestCheckEventCondition(t *testing.T) {
|
||||
err = em.Add(exch)
|
||||
require.NoError(t, err, "ExchangeManager Add must not error")
|
||||
|
||||
_, err = m.Add(testExchange, ItemPrice, cond, currency.NewPair(currency.BTC, currency.USD), asset.Spot, action)
|
||||
_, err = m.Add(testExchange, ItemPrice, cond, currency.NewBTCUSD(), asset.Spot, action)
|
||||
require.NoError(t, err, "eventManager Add must not error")
|
||||
|
||||
m.m.Lock()
|
||||
@@ -292,7 +292,7 @@ func TestCheckEventCondition(t *testing.T) {
|
||||
assert.ErrorIs(t, err, ticker.ErrTickerNotFound)
|
||||
m.m.Unlock()
|
||||
|
||||
_, err = exch.UpdateTicker(t.Context(), currency.NewPair(currency.BTC, currency.USD), asset.Spot)
|
||||
_, err = exch.UpdateTicker(t.Context(), currency.NewBTCUSD(), asset.Spot)
|
||||
require.NoError(t, err, "UpdateTicker must not error")
|
||||
|
||||
m.m.Lock()
|
||||
@@ -310,7 +310,7 @@ func TestCheckEventCondition(t *testing.T) {
|
||||
assert.ErrorIs(t, err, orderbook.ErrOrderbookNotFound)
|
||||
m.m.Unlock()
|
||||
|
||||
_, err = exch.UpdateOrderbook(t.Context(), currency.NewPair(currency.BTC, currency.USD), asset.Spot)
|
||||
_, err = exch.UpdateOrderbook(t.Context(), currency.NewBTCUSD(), asset.Spot)
|
||||
require.NoError(t, err, "UpdateOrderbook must not error")
|
||||
|
||||
m.m.Lock()
|
||||
|
||||
@@ -42,8 +42,8 @@ var testExchange = "Bitstamp"
|
||||
func CreateTestBot(tb testing.TB) *Engine {
|
||||
tb.Helper()
|
||||
cFormat := ¤cy.PairFormat{Uppercase: true}
|
||||
cp1 := currency.NewPair(currency.BTC, currency.USD)
|
||||
cp2 := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp1 := currency.NewBTCUSD()
|
||||
cp2 := currency.NewBTCUSDT()
|
||||
|
||||
pairs1 := map[asset.Item]*currency.PairStore{
|
||||
asset.Spot: {
|
||||
@@ -377,8 +377,8 @@ func TestGetSpecificAvailablePairs(t *testing.T) {
|
||||
CurrencyPairs: ¤cy.PairsManager{Pairs: map[asset.Item]*currency.PairStore{
|
||||
asset.Spot: {
|
||||
AssetEnabled: true,
|
||||
Enabled: currency.Pairs{currency.NewPair(currency.BTC, currency.USD), currency.NewPair(currency.BTC, c)},
|
||||
Available: currency.Pairs{currency.NewPair(currency.BTC, currency.USD), currency.NewPair(currency.BTC, c)},
|
||||
Enabled: currency.Pairs{currency.NewBTCUSD(), currency.NewPair(currency.BTC, c)},
|
||||
Available: currency.Pairs{currency.NewBTCUSD(), currency.NewPair(currency.BTC, c)},
|
||||
ConfigFormat: ¤cy.PairFormat{
|
||||
Uppercase: true,
|
||||
},
|
||||
@@ -390,7 +390,7 @@ func TestGetSpecificAvailablePairs(t *testing.T) {
|
||||
assetType := asset.Spot
|
||||
|
||||
result := e.GetSpecificAvailablePairs(true, true, true, true, assetType)
|
||||
btcUSD := currency.NewPair(currency.BTC, currency.USD)
|
||||
btcUSD := currency.NewBTCUSD()
|
||||
if !result.Contains(btcUSD, true) {
|
||||
t.Error("Unexpected result")
|
||||
}
|
||||
@@ -682,7 +682,7 @@ func TestMapCurrenciesByExchange(t *testing.T) {
|
||||
e := CreateTestBot(t)
|
||||
|
||||
pairs := []currency.Pair{
|
||||
currency.NewPair(currency.BTC, currency.USD),
|
||||
currency.NewBTCUSD(),
|
||||
currency.NewPair(currency.BTC, currency.EUR),
|
||||
}
|
||||
|
||||
@@ -956,11 +956,11 @@ func createDepositEngine(opts *fakeDepositExchangeOpts) *Engine {
|
||||
ps := currency.PairStore{
|
||||
AssetEnabled: true,
|
||||
Enabled: currency.Pairs{
|
||||
currency.NewPair(currency.BTC, currency.USDT),
|
||||
currency.NewBTCUSDT(),
|
||||
currency.NewPair(currency.XRP, currency.USDT),
|
||||
},
|
||||
Available: currency.Pairs{
|
||||
currency.NewPair(currency.BTC, currency.USDT),
|
||||
currency.NewBTCUSDT(),
|
||||
currency.NewPair(currency.XRP, currency.USDT),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ type omfExchange struct {
|
||||
exchange.IBotExchange
|
||||
}
|
||||
|
||||
var btcusdPair = currency.NewPair(currency.BTC, currency.USD)
|
||||
var btcusdPair = currency.NewBTCUSD()
|
||||
|
||||
// CancelOrder overrides testExchange's cancel order function
|
||||
// to do the bare minimum required with no API calls or credentials required
|
||||
@@ -1160,7 +1160,7 @@ func Test_getActiveOrders(t *testing.T) {
|
||||
func TestGetFuturesPositionsForExchange(t *testing.T) {
|
||||
t.Parallel()
|
||||
o := &OrderManager{}
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
_, err := o.GetFuturesPositionsForExchange("test", asset.Spot, cp)
|
||||
if !errors.Is(err, ErrSubSystemNotStarted) {
|
||||
t.Errorf("received '%v', expected '%v'", err, ErrSubSystemNotStarted)
|
||||
@@ -1208,7 +1208,7 @@ func TestGetFuturesPositionsForExchange(t *testing.T) {
|
||||
func TestClearFuturesPositionsForExchange(t *testing.T) {
|
||||
t.Parallel()
|
||||
o := &OrderManager{}
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
err := o.ClearFuturesTracking("test", asset.Spot, cp)
|
||||
if !errors.Is(err, ErrSubSystemNotStarted) {
|
||||
t.Errorf("received '%v', expected '%v'", err, ErrSubSystemNotStarted)
|
||||
@@ -1260,7 +1260,7 @@ func TestClearFuturesPositionsForExchange(t *testing.T) {
|
||||
func TestUpdateOpenPositionUnrealisedPNL(t *testing.T) {
|
||||
t.Parallel()
|
||||
o := &OrderManager{}
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
_, err := o.UpdateOpenPositionUnrealisedPNL("test", asset.Spot, cp, 1, time.Now())
|
||||
if !errors.Is(err, ErrSubSystemNotStarted) {
|
||||
t.Errorf("received '%v', expected '%v'", err, ErrSubSystemNotStarted)
|
||||
@@ -1395,7 +1395,7 @@ func TestUpdateExisting(t *testing.T) {
|
||||
od.Exchange = testExchange
|
||||
od.AssetType = asset.Futures
|
||||
od.OrderID = "123"
|
||||
od.Pair = currency.NewPair(currency.BTC, currency.USDT)
|
||||
od.Pair = currency.NewBTCUSDT()
|
||||
od.Side = order.Buy
|
||||
od.Type = order.Market
|
||||
od.Date = time.Now()
|
||||
|
||||
@@ -479,7 +479,7 @@ func RPCTestSetup(t *testing.T) *Engine {
|
||||
}
|
||||
exch.SetDefaults()
|
||||
b := exch.GetBase()
|
||||
cp := currency.NewPair(currency.BTC, currency.USD)
|
||||
cp := currency.NewBTCUSD()
|
||||
b.CurrencyPairs.Pairs = make(map[asset.Item]*currency.PairStore)
|
||||
b.CurrencyPairs.Pairs[asset.Spot] = ¤cy.PairStore{
|
||||
Available: currency.Pairs{cp},
|
||||
@@ -499,7 +499,7 @@ func RPCTestSetup(t *testing.T) *Engine {
|
||||
}
|
||||
exch.SetDefaults()
|
||||
b = exch.GetBase()
|
||||
cp = currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp = currency.NewBTCUSDT()
|
||||
b.CurrencyPairs.Pairs = make(map[asset.Item]*currency.PairStore)
|
||||
b.CurrencyPairs.Pairs[asset.Spot] = ¤cy.PairStore{
|
||||
Available: currency.Pairs{cp},
|
||||
@@ -774,7 +774,7 @@ func TestGetHistoricCandles(t *testing.T) {
|
||||
// error checks
|
||||
defaultStart := time.Date(2020, 0, 0, 0, 0, 0, 0, time.UTC)
|
||||
defaultEnd := time.Date(2020, 0, 0, 1, 0, 0, 0, time.UTC)
|
||||
cp := currency.NewPair(currency.BTC, currency.USD)
|
||||
cp := currency.NewBTCUSD()
|
||||
_, err := s.GetHistoricCandles(t.Context(), &gctrpc.GetHistoricCandlesRequest{
|
||||
Exchange: "",
|
||||
Pair: &gctrpc.CurrencyPair{
|
||||
@@ -935,7 +935,7 @@ func TestFindMissingSavedTradeIntervals(t *testing.T) {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
cp := currency.NewPair(currency.BTC, currency.USD)
|
||||
cp := currency.NewBTCUSD()
|
||||
// no data found response
|
||||
defaultStart := time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC).UTC()
|
||||
defaultEnd := time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC).UTC()
|
||||
@@ -1037,7 +1037,7 @@ func TestFindMissingSavedCandleIntervals(t *testing.T) {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
cp := currency.NewPair(currency.BTC, currency.USD)
|
||||
cp := currency.NewBTCUSD()
|
||||
// no data found response
|
||||
defaultStart := time.Date(2020, 0, 0, 0, 0, 0, 0, time.UTC)
|
||||
defaultEnd := time.Date(2020, 0, 0, 4, 0, 0, 0, time.UTC)
|
||||
@@ -1338,7 +1338,7 @@ func TestGetOrders(t *testing.T) {
|
||||
}
|
||||
exch.SetDefaults()
|
||||
b := exch.GetBase()
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
b.CurrencyPairs.Pairs = make(map[asset.Item]*currency.PairStore)
|
||||
b.CurrencyPairs.Pairs[asset.Spot] = ¤cy.PairStore{
|
||||
Available: currency.Pairs{cp},
|
||||
@@ -1449,7 +1449,7 @@ func TestGetOrder(t *testing.T) {
|
||||
}
|
||||
exch.SetDefaults()
|
||||
b := exch.GetBase()
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
b.CurrencyPairs.Pairs = make(map[asset.Item]*currency.PairStore)
|
||||
b.CurrencyPairs.Pairs[asset.Spot] = ¤cy.PairStore{
|
||||
Available: currency.Pairs{cp},
|
||||
@@ -1536,16 +1536,16 @@ func TestGetOrder(t *testing.T) {
|
||||
func TestCheckVars(t *testing.T) {
|
||||
t.Parallel()
|
||||
var e exchange.IBotExchange
|
||||
err := checkParams("Binance", e, asset.Spot, currency.NewPair(currency.BTC, currency.USDT))
|
||||
err := checkParams("Binance", e, asset.Spot, currency.NewBTCUSDT())
|
||||
assert.ErrorIs(t, err, errExchangeNotLoaded, "checkParams should error correctly")
|
||||
|
||||
e = &binance.Binance{}
|
||||
err = checkParams("Binance", e, asset.Spot, currency.NewPair(currency.BTC, currency.USDT))
|
||||
err = checkParams("Binance", e, asset.Spot, currency.NewBTCUSDT())
|
||||
assert.ErrorIs(t, err, errExchangeNotEnabled, "checkParams should error correctly")
|
||||
|
||||
e.SetEnabled(true)
|
||||
|
||||
err = checkParams("Binance", e, asset.Spot, currency.NewPair(currency.BTC, currency.USDT))
|
||||
err = checkParams("Binance", e, asset.Spot, currency.NewBTCUSDT())
|
||||
assert.ErrorIs(t, err, currency.ErrPairManagerNotInitialised, "checkParams should error correctly")
|
||||
|
||||
b := e.GetBase()
|
||||
@@ -1566,7 +1566,7 @@ func TestCheckVars(t *testing.T) {
|
||||
require.NoError(t, b.SetAssetPairStore(a, ps), "SetAssetPairStore must not error")
|
||||
}
|
||||
|
||||
err = checkParams("Binance", e, asset.Spot, currency.NewPair(currency.BTC, currency.USDT))
|
||||
err = checkParams("Binance", e, asset.Spot, currency.NewBTCUSDT())
|
||||
assert.ErrorIs(t, err, errCurrencyPairInvalid, "checkParams should error correctly")
|
||||
|
||||
data := []currency.Pair{
|
||||
@@ -1576,13 +1576,13 @@ func TestCheckVars(t *testing.T) {
|
||||
err = b.CurrencyPairs.StorePairs(asset.Spot, data, false)
|
||||
require.NoError(t, err, "StorePairs must not error")
|
||||
|
||||
err = checkParams("Binance", e, asset.Spot, currency.NewPair(currency.BTC, currency.USDT))
|
||||
err = checkParams("Binance", e, asset.Spot, currency.NewBTCUSDT())
|
||||
require.ErrorIs(t, err, errCurrencyNotEnabled, "checkParams must error correctly")
|
||||
|
||||
err = b.CurrencyPairs.EnablePair(asset.Spot, currency.Pair{Delimiter: currency.DashDelimiter, Base: currency.BTC, Quote: currency.USDT})
|
||||
require.NoError(t, err, "EnablePair must not error")
|
||||
|
||||
err = checkParams("Binance", e, asset.Spot, currency.NewPair(currency.BTC, currency.USDT))
|
||||
err = checkParams("Binance", e, asset.Spot, currency.NewBTCUSDT())
|
||||
require.NoError(t, err, "checkParams must not error")
|
||||
}
|
||||
|
||||
@@ -1658,7 +1658,7 @@ func TestRPCServerUpsertDataHistoryJob(t *testing.T) {
|
||||
}
|
||||
exch.SetDefaults()
|
||||
b := exch.GetBase()
|
||||
cp := currency.NewPair(currency.BTC, currency.USD)
|
||||
cp := currency.NewBTCUSD()
|
||||
b.CurrencyPairs.Pairs = make(map[asset.Item]*currency.PairStore)
|
||||
b.CurrencyPairs.Pairs[asset.Spot] = ¤cy.PairStore{
|
||||
Available: currency.Pairs{cp},
|
||||
@@ -1713,7 +1713,7 @@ func TestGetDataHistoryJobDetails(t *testing.T) {
|
||||
Nickname: "TestGetDataHistoryJobDetails",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: time.Now().UTC().Add(-time.Minute * 2),
|
||||
EndDate: time.Now().UTC(),
|
||||
Interval: kline.OneMin,
|
||||
@@ -1769,7 +1769,7 @@ func TestSetDataHistoryJobStatus(t *testing.T) {
|
||||
Nickname: "TestDeleteDataHistoryJob",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: time.Now().UTC().Add(-time.Minute * 2),
|
||||
EndDate: time.Now().UTC(),
|
||||
Interval: kline.OneMin,
|
||||
@@ -1827,7 +1827,7 @@ func TestGetActiveDataHistoryJobs(t *testing.T) {
|
||||
Nickname: "TestGetActiveDataHistoryJobs",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: time.Now().UTC().Add(-time.Minute * 2),
|
||||
EndDate: time.Now().UTC(),
|
||||
Interval: kline.OneMin,
|
||||
@@ -1855,7 +1855,7 @@ func TestGetDataHistoryJobsBetween(t *testing.T) {
|
||||
Nickname: "GetDataHistoryJobsBetween",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: time.Now().UTC().Add(-time.Minute * 2),
|
||||
EndDate: time.Now().UTC(),
|
||||
Interval: kline.OneMin,
|
||||
@@ -1900,7 +1900,7 @@ func TestGetDataHistoryJobSummary(t *testing.T) {
|
||||
Nickname: "TestGetDataHistoryJobSummary",
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
StartDate: time.Now().UTC().Add(-time.Minute * 2),
|
||||
EndDate: time.Now().UTC(),
|
||||
Interval: kline.OneMin,
|
||||
@@ -1929,7 +1929,7 @@ func TestGetManagedOrders(t *testing.T) {
|
||||
}
|
||||
exch.SetDefaults()
|
||||
b := exch.GetBase()
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
b.CurrencyPairs.Pairs = make(map[asset.Item]*currency.PairStore)
|
||||
b.CurrencyPairs.Pairs[asset.Spot] = ¤cy.PairStore{
|
||||
Available: currency.Pairs{cp},
|
||||
@@ -2002,7 +2002,7 @@ func TestGetManagedOrders(t *testing.T) {
|
||||
Side: order.Sell,
|
||||
Status: order.New,
|
||||
AssetType: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
}
|
||||
err = om.Add(&o)
|
||||
if err != nil {
|
||||
@@ -4254,8 +4254,8 @@ func TestGetCurrencyTradeURL(t *testing.T) {
|
||||
b.CurrencyPairs.Pairs = make(map[asset.Item]*currency.PairStore)
|
||||
err = b.CurrencyPairs.Store(asset.Spot, ¤cy.PairStore{
|
||||
AssetEnabled: true,
|
||||
Enabled: []currency.Pair{currency.NewPair(currency.BTC, currency.USDT)},
|
||||
Available: []currency.Pair{currency.NewPair(currency.BTC, currency.USDT)},
|
||||
Enabled: []currency.Pair{currency.NewBTCUSDT()},
|
||||
Available: []currency.Pair{currency.NewBTCUSDT()},
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
ConfigFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
})
|
||||
|
||||
@@ -170,7 +170,7 @@ func TestPrintTickerSummary(t *testing.T) {
|
||||
}
|
||||
atomic.StoreInt32(&m.started, 1)
|
||||
m.PrintTickerSummary(&ticker.Price{
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
}, "REST", nil)
|
||||
m.fiatDisplayCurrency = currency.USD
|
||||
m.PrintTickerSummary(&ticker.Price{
|
||||
|
||||
@@ -246,7 +246,7 @@ func TestWebsocketRoutineManagerHandleData(t *testing.T) {
|
||||
|
||||
err = m.websocketDataHandler(exchName, &orderbook.Base{
|
||||
Exchange: "Bitstamp",
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user