mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-18 15:10:03 +00:00
Add IsFiatPair function
This commit is contained in:
@@ -146,6 +146,11 @@ func IsCryptoFiatPair(p pair.CurrencyPair) bool {
|
||||
!IsCryptocurrency(p.FirstCurrency.String()) && IsCryptocurrency(p.SecondCurrency.String())
|
||||
}
|
||||
|
||||
// IsFiatPair checks to see if the pair is a fiar pair. For example. EURUSD
|
||||
func IsFiatPair(p pair.CurrencyPair) bool {
|
||||
return IsFiatCurrency(p.FirstCurrency.String()) && IsFiatCurrency(p.SecondCurrency.String())
|
||||
}
|
||||
|
||||
// Update updates the local crypto currency or base currency store
|
||||
func Update(input []string, cryptos bool) {
|
||||
for x := range input {
|
||||
|
||||
@@ -199,6 +199,28 @@ func TestIsCryptoFiatPair(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsFiatPair(t *testing.T) {
|
||||
CryptoCurrencies = []string{"BTC", "LTC", "DASH"}
|
||||
BaseCurrencies = []string{"USD", "AUD", "EUR"}
|
||||
|
||||
if !IsFiatPair(pair.NewCurrencyPair("AUD", "USD")) {
|
||||
t.Error("Test Failed. TestIsFiatPair. Expected true result")
|
||||
}
|
||||
|
||||
if IsFiatPair(pair.NewCurrencyPair("BTC", "AUD")) {
|
||||
t.Error("Test Failed. TestIsFiatPair. Expected false result")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsRelatablePairs(t *testing.T) {
|
||||
CryptoCurrencies = []string{"BTC", "XBT", "LTC", "DASH"}
|
||||
BaseCurrencies = []string{"USD", "AUD", "EUR"}
|
||||
|
||||
if !IsRelatablePairs(pair.NewCurrencyPair("XBT", "USD"), pair.NewCurrencyPair("BTC", "USD")) {
|
||||
t.Error("Test Failed. TestIsFiatPair. Expected true result")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdate(t *testing.T) {
|
||||
CryptoCurrencies = []string{"BTC", "LTC", "DASH"}
|
||||
BaseCurrencies = []string{"USD", "AUD"}
|
||||
|
||||
Reference in New Issue
Block a user