From 8fd713f3ae09d465d205501eda28c98d5e7addfc Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 30 Nov 2018 07:02:08 +0100 Subject: [PATCH] validate_whitelist should return the list again --- freqtrade/pairlist/StaticList.py | 10 ++++------ freqtrade/tests/test_acl_pair.py | 11 +++++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/freqtrade/pairlist/StaticList.py b/freqtrade/pairlist/StaticList.py index 8b0decdf6..225f89b2e 100644 --- a/freqtrade/pairlist/StaticList.py +++ b/freqtrade/pairlist/StaticList.py @@ -28,13 +28,13 @@ class StaticList(object): def blacklist(self) -> List[str]: return self._blacklist - def refresh_whitelist(self) -> bool: + def refresh_whitelist(self) -> None: """ Refreshes whitelist. """ - return self.validate_whitelist(self._config['exchange']['pair_whitelist']) + self._whitelist = self.validate_whitelist(self._config['exchange']['pair_whitelist']) - def validate_whitelist(self, whitelist: List[str]) -> bool: + def validate_whitelist(self, whitelist: List[str]) -> List[str]: """ Check available markets and remove pair from whitelist if necessary :param whitelist: the sorted list (based on BaseVolume) of pairs the user might want to @@ -65,6 +65,4 @@ class StaticList(object): ) # We need to remove pairs that are unknown - self._whitelist = [x for x in sanitized_whitelist if x in known_pairs] - - return True + return [x for x in sanitized_whitelist if x in known_pairs] diff --git a/freqtrade/tests/test_acl_pair.py b/freqtrade/tests/test_acl_pair.py index 58dd3dff2..6ec11e664 100644 --- a/freqtrade/tests/test_acl_pair.py +++ b/freqtrade/tests/test_acl_pair.py @@ -31,22 +31,21 @@ def test_refresh_market_pair_not_in_whitelist(mocker, markets, whitelist_conf): freqtradebot = get_patched_freqtradebot(mocker, whitelist_conf) mocker.patch('freqtrade.exchange.Exchange.get_markets', markets) - freqtradebot.pairlists.validate_whitelist( - whitelist_conf['exchange']['pair_whitelist'] + ['XXX/BTC'] - ) + freqtradebot.pairlists.refresh_whitelist() # List ordered by BaseVolume whitelist = ['ETH/BTC', 'TKN/BTC'] # Ensure all except those in whitelist are removed assert whitelist == freqtradebot.pairlists.whitelist + # Ensure config dict hasn't been changed + assert (whitelist_conf['exchange']['pair_whitelist'] == + freqtradebot.config['exchange']['pair_whitelist']) def test_refresh_whitelist(mocker, markets, whitelist_conf): freqtradebot = get_patched_freqtradebot(mocker, whitelist_conf) mocker.patch('freqtrade.exchange.Exchange.get_markets', markets) - freqtradebot.pairlists.validate_whitelist( - whitelist_conf['exchange']['pair_whitelist']) - + freqtradebot.pairlists.refresh_whitelist() # List ordered by BaseVolume whitelist = ['ETH/BTC', 'TKN/BTC'] # Ensure all except those in whitelist are removed