mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-02 07:26:53 +00:00
engine/exchanges: Add GetCurrencyTradeURL wrapper func/gRPC endpoint (#1521)
* beginning the concept * expands testing and implementations * test standardisation, expansion * more * finish remainder, add rpc func * lint * grammar? I barely know her! * wow i forgot something wow wow wow wow * rm SendPayload * enFixio! * improve binance long-dated support * update test design, update wrapper funcs * adds kraken futures, adds bybit support * fixes SIMPLE bugs * s is for sucks * fixed option url x2 * fixed silly test
This commit is contained in:
@@ -268,6 +268,10 @@ func (f fExchange) GetHistoricCandlesExtended(_ context.Context, p currency.Pair
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (f fExchange) GetCurrencyTradeURL(_ context.Context, _ asset.Item, _ currency.Pair) (string, error) {
|
||||
return "https://google.com", nil
|
||||
}
|
||||
|
||||
func (f fExchange) GetMarginRatesHistory(context.Context, *margin.RateHistoryRequest) (*margin.RateHistoryResponse, error) {
|
||||
leet := decimal.NewFromInt(1337)
|
||||
rates := []margin.Rate{
|
||||
@@ -4290,3 +4294,55 @@ func TestRPCProxyAuthClient(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCurrencyTradeURL(t *testing.T) {
|
||||
t.Parallel()
|
||||
em := NewExchangeManager()
|
||||
exch, err := em.NewExchangeByName("binance")
|
||||
require.NoError(t, err)
|
||||
|
||||
exch.SetDefaults()
|
||||
b := exch.GetBase()
|
||||
b.Name = fakeExchangeName
|
||||
b.Enabled = true
|
||||
b.CurrencyPairs.Pairs = make(map[asset.Item]*currency.PairStore)
|
||||
err = b.CurrencyPairs.Store(asset.Spot, ¤cy.PairStore{
|
||||
AssetEnabled: convert.BoolPtr(true),
|
||||
Enabled: []currency.Pair{currency.NewPair(currency.BTC, currency.USDT)},
|
||||
Available: []currency.Pair{currency.NewPair(currency.BTC, currency.USDT)},
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
ConfigFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
fakeExchange := fExchange{
|
||||
IBotExchange: exch,
|
||||
}
|
||||
err = em.Add(fakeExchange)
|
||||
require.NoError(t, err)
|
||||
|
||||
s := RPCServer{Engine: &Engine{ExchangeManager: em}}
|
||||
_, err = s.GetCurrencyTradeURL(context.Background(), nil)
|
||||
assert.ErrorIs(t, err, common.ErrNilPointer)
|
||||
|
||||
req := &gctrpc.GetCurrencyTradeURLRequest{}
|
||||
_, err = s.GetCurrencyTradeURL(context.Background(), req)
|
||||
assert.ErrorIs(t, err, ErrExchangeNameIsEmpty)
|
||||
|
||||
req.Exchange = fakeExchangeName
|
||||
_, err = s.GetCurrencyTradeURL(context.Background(), req)
|
||||
assert.ErrorIs(t, err, asset.ErrNotSupported)
|
||||
|
||||
req.Asset = "spot"
|
||||
_, err = s.GetCurrencyTradeURL(context.Background(), req)
|
||||
assert.ErrorIs(t, err, currency.ErrCurrencyPairEmpty)
|
||||
|
||||
req.Pair = &gctrpc.CurrencyPair{
|
||||
Delimiter: "-",
|
||||
Base: "btc",
|
||||
Quote: "usdt",
|
||||
}
|
||||
resp, err := s.GetCurrencyTradeURL(context.Background(), req)
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, resp.Url)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user