From a4c996b34640865b6c027c26e9aa6dff93e6f3a3 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Wed, 23 Aug 2017 14:57:03 +1000 Subject: [PATCH] Add exchange GetAvailableCurrencies function --- exchanges/exchange.go | 6 ++++++ exchanges/exchange_test.go | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/exchanges/exchange.go b/exchanges/exchange.go index 71a79c8f197..3eb08590ad1 100644 --- a/exchanges/exchange.go +++ b/exchanges/exchange.go @@ -85,6 +85,12 @@ func (e *Base) GetEnabledCurrencies() []string { return e.EnabledPairs } +// GetAvailableCurrencies is a method that returns the available currency pairs +// of the exchange base +func (e *Base) GetAvailableCurrencies() []string { + return e.AvailablePairs +} + // FormatCurrency is a method that formats and returns a currency pair // based on the user currency display preferences func FormatCurrency(p pair.CurrencyPair) pair.CurrencyItem { diff --git a/exchanges/exchange_test.go b/exchanges/exchange_test.go index c0406f64b36..bc17f371246 100644 --- a/exchanges/exchange_test.go +++ b/exchanges/exchange_test.go @@ -32,6 +32,19 @@ func TestGetEnabledCurrencies(t *testing.T) { } } +func TestGetAvailableCurrencies(t *testing.T) { + availablePairs := []string{"BTCUSD", "BTCAUD", "LTCUSD", "LTCAUD"} + GetEnabledCurrencies := Base{ + Name: "TESTNAME", + AvailablePairs: availablePairs, + } + + enCurr := GetEnabledCurrencies.GetAvailableCurrencies() + if enCurr[0] != "BTCUSD" { + t.Error("Test Failed - Exchange GetAvailableCurrencies() incorrect string") + } +} + func TestFormatCurrency(t *testing.T) { cfg := config.GetConfig() err := cfg.LoadConfig(config.ConfigTestFile)