Remove credentials whenever dry-run is set from within the exchange
This commit is contained in:
@@ -32,8 +32,6 @@ def test_setup_utils_configuration():
|
||||
config = setup_utils_configuration(get_args(args), RunMode.OTHER)
|
||||
assert "exchange" in config
|
||||
assert config['dry_run'] is True
|
||||
assert config['exchange']['key'] == ''
|
||||
assert config['exchange']['secret'] == ''
|
||||
|
||||
|
||||
def test_start_trading_fail(mocker, caplog):
|
||||
|
@@ -54,7 +54,7 @@ EXCHANGES = {
|
||||
def exchange_conf():
|
||||
config = get_default_conf((Path(__file__).parent / "testdata").resolve())
|
||||
config['exchange']['pair_whitelist'] = []
|
||||
config['dry_run'] = False
|
||||
# config['dry_run'] = False
|
||||
return config
|
||||
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import copy
|
||||
import logging
|
||||
from copy import deepcopy
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from math import isclose
|
||||
from random import randint
|
||||
@@ -14,7 +15,7 @@ from freqtrade.exceptions import (DDosProtection, DependencyException, InvalidOr
|
||||
OperationalException, PricingError, TemporaryError)
|
||||
from freqtrade.exchange import Binance, Bittrex, Exchange, Kraken
|
||||
from freqtrade.exchange.common import (API_FETCH_ORDER_RETRY_COUNT, API_RETRY_COUNT,
|
||||
calculate_backoff)
|
||||
calculate_backoff, remove_credentials)
|
||||
from freqtrade.exchange.exchange import (market_is_active, timeframe_to_minutes, timeframe_to_msecs,
|
||||
timeframe_to_next_date, timeframe_to_prev_date,
|
||||
timeframe_to_seconds)
|
||||
@@ -78,6 +79,22 @@ def test_init(default_conf, mocker, caplog):
|
||||
assert log_has('Instance is running with dry_run enabled', caplog)
|
||||
|
||||
|
||||
def test_remove_credentials(default_conf, caplog) -> None:
|
||||
conf = deepcopy(default_conf)
|
||||
conf['dry_run'] = False
|
||||
remove_credentials(conf)
|
||||
|
||||
assert conf['exchange']['key'] != ''
|
||||
assert conf['exchange']['secret'] != ''
|
||||
|
||||
conf['dry_run'] = True
|
||||
remove_credentials(conf)
|
||||
assert conf['exchange']['key'] == ''
|
||||
assert conf['exchange']['secret'] == ''
|
||||
assert conf['exchange']['password'] == ''
|
||||
assert conf['exchange']['uid'] == ''
|
||||
|
||||
|
||||
def test_init_ccxt_kwargs(default_conf, mocker, caplog):
|
||||
mocker.patch('freqtrade.exchange.Exchange._load_markets', MagicMock(return_value={}))
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_stakecurrency')
|
||||
|
@@ -11,8 +11,7 @@ import pytest
|
||||
from jsonschema import ValidationError
|
||||
|
||||
from freqtrade.commands import Arguments
|
||||
from freqtrade.configuration import (Configuration, check_exchange, remove_credentials,
|
||||
validate_config_consistency)
|
||||
from freqtrade.configuration import Configuration, check_exchange, validate_config_consistency
|
||||
from freqtrade.configuration.config_validation import validate_config_schema
|
||||
from freqtrade.configuration.deprecated_settings import (check_conflicting_settings,
|
||||
process_deprecated_setting,
|
||||
@@ -617,18 +616,6 @@ def test_check_exchange(default_conf, caplog) -> None:
|
||||
check_exchange(default_conf)
|
||||
|
||||
|
||||
def test_remove_credentials(default_conf, caplog) -> None:
|
||||
conf = deepcopy(default_conf)
|
||||
conf['dry_run'] = False
|
||||
remove_credentials(conf)
|
||||
|
||||
assert conf['dry_run'] is True
|
||||
assert conf['exchange']['key'] == ''
|
||||
assert conf['exchange']['secret'] == ''
|
||||
assert conf['exchange']['password'] == ''
|
||||
assert conf['exchange']['uid'] == ''
|
||||
|
||||
|
||||
def test_cli_verbose_with_params(default_conf, mocker, caplog) -> None:
|
||||
patched_configuration_load_config_file(mocker, default_conf)
|
||||
|
||||
|
Reference in New Issue
Block a user