mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Reuse sets of supported currencies
Reuse sets of supported currencies between pricenode classes and tests.
This commit is contained in:
parent
329188db1d
commit
7fc5191798
@ -56,11 +56,11 @@ import java.util.stream.Stream;
|
||||
*/
|
||||
public abstract class ExchangeRateProvider extends PriceProvider<Set<ExchangeRate>> {
|
||||
|
||||
private static final Set<String> supportedCryptoCurrencies = CurrencyUtil.getAllSortedCryptoCurrencies().stream()
|
||||
public static final Set<String> SUPPORTED_CRYPTO_CURRENCIES = CurrencyUtil.getAllSortedCryptoCurrencies().stream()
|
||||
.map(TradeCurrency::getCode)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
private static final Set<String> supportedFiatCurrencies = CurrencyUtil.getAllSortedFiatCurrencies().stream()
|
||||
public static final Set<String> SUPPORTED_FIAT_CURRENCIES = CurrencyUtil.getAllSortedFiatCurrencies().stream()
|
||||
.map(TradeCurrency::getCode)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
@ -116,13 +116,13 @@ public abstract class ExchangeRateProvider extends PriceProvider<Set<ExchangeRat
|
||||
// Find the desired fiat pairs (pair format is BTC-FIAT)
|
||||
List<CurrencyPair> desiredFiatPairs = allCurrencyPairsOnExchange.stream()
|
||||
.filter(cp -> cp.base.equals(Currency.BTC))
|
||||
.filter(cp -> supportedFiatCurrencies.contains(cp.counter.getCurrencyCode()))
|
||||
.filter(cp -> SUPPORTED_FIAT_CURRENCIES.contains(cp.counter.getCurrencyCode()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// Find the desired altcoin pairs (pair format is ALT-BTC)
|
||||
List<CurrencyPair> desiredCryptoPairs = allCurrencyPairsOnExchange.stream()
|
||||
.filter(cp -> cp.counter.equals(Currency.BTC))
|
||||
.filter(cp -> supportedCryptoCurrencies.contains(cp.base.getCurrencyCode()))
|
||||
.filter(cp -> SUPPORTED_CRYPTO_CURRENCIES.contains(cp.base.getCurrencyCode()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// Retrieve in bulk all tickers offered by the exchange
|
||||
|
@ -48,25 +48,19 @@ public abstract class AbstractExchangeRateProviderTest {
|
||||
.map(ExchangeRate::getCurrency)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Set<String> supportedCryptoCurrencies = CurrencyUtil.getAllSortedCryptoCurrencies().stream()
|
||||
.map(TradeCurrency::getCode)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Set<String> supportedFiatCurrencies = CurrencyUtil.getAllSortedFiatCurrencies().stream()
|
||||
.map(TradeCurrency::getCode)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Set<String> supportedFiatCurrenciesRetrieved = supportedFiatCurrencies.stream()
|
||||
Set<String> supportedFiatCurrenciesRetrieved = ExchangeRateProvider.SUPPORTED_FIAT_CURRENCIES.stream()
|
||||
.filter(f -> retrievedRatesCurrencies.contains(f))
|
||||
.collect(Collectors.toCollection(TreeSet::new));
|
||||
log.info("Retrieved rates for supported fiat currencies: " + supportedFiatCurrenciesRetrieved);
|
||||
|
||||
Set<String> supportedCryptoCurrenciesRetrieved = supportedCryptoCurrencies.stream()
|
||||
Set<String> supportedCryptoCurrenciesRetrieved = ExchangeRateProvider.SUPPORTED_CRYPTO_CURRENCIES.stream()
|
||||
.filter(c -> retrievedRatesCurrencies.contains(c))
|
||||
.collect(Collectors.toCollection(TreeSet::new));
|
||||
log.info("Retrieved rates for supported altcoins: " + supportedCryptoCurrenciesRetrieved);
|
||||
|
||||
Set<String> supportedCurrencies = Sets.union(supportedCryptoCurrencies, supportedFiatCurrencies);
|
||||
Set<String> supportedCurrencies = Sets.union(
|
||||
ExchangeRateProvider.SUPPORTED_CRYPTO_CURRENCIES,
|
||||
ExchangeRateProvider.SUPPORTED_FIAT_CURRENCIES);
|
||||
|
||||
Set unsupportedCurrencies = Sets.difference(retrievedRatesCurrencies, supportedCurrencies);
|
||||
assertTrue("Retrieved exchange rates contain unsupported currencies: " + unsupportedCurrencies,
|
||||
|
Loading…
Reference in New Issue
Block a user