2018-11-17 21:58:27 +00:00
|
|
|
# pragma pylint: disable=missing-docstring
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
2019-12-15 09:39:52 +00:00
|
|
|
from tests.conftest import get_patched_freqtradebot
|
|
|
|
|
2018-11-17 21:58:27 +00:00
|
|
|
|
|
|
|
def test_sync_wallet_at_boot(mocker, default_conf):
|
2018-11-23 09:17:10 +00:00
|
|
|
default_conf['dry_run'] = False
|
2018-11-17 21:58:27 +00:00
|
|
|
mocker.patch.multiple(
|
|
|
|
'freqtrade.exchange.Exchange',
|
|
|
|
get_balances=MagicMock(return_value={
|
|
|
|
"BNT": {
|
|
|
|
"free": 1.0,
|
|
|
|
"used": 2.0,
|
|
|
|
"total": 3.0
|
|
|
|
},
|
|
|
|
"GAS": {
|
|
|
|
"free": 0.260739,
|
|
|
|
"used": 0.0,
|
|
|
|
"total": 0.260739
|
|
|
|
},
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
|
|
|
|
2019-02-28 22:26:29 +00:00
|
|
|
assert len(freqtrade.wallets._wallets) == 2
|
|
|
|
assert freqtrade.wallets._wallets['BNT'].free == 1.0
|
|
|
|
assert freqtrade.wallets._wallets['BNT'].used == 2.0
|
|
|
|
assert freqtrade.wallets._wallets['BNT'].total == 3.0
|
|
|
|
assert freqtrade.wallets._wallets['GAS'].free == 0.260739
|
|
|
|
assert freqtrade.wallets._wallets['GAS'].used == 0.0
|
|
|
|
assert freqtrade.wallets._wallets['GAS'].total == 0.260739
|
2018-11-26 05:22:53 +00:00
|
|
|
assert freqtrade.wallets.get_free('BNT') == 1.0
|
2018-11-21 16:54:14 +00:00
|
|
|
|
|
|
|
mocker.patch.multiple(
|
|
|
|
'freqtrade.exchange.Exchange',
|
|
|
|
get_balances=MagicMock(return_value={
|
|
|
|
"BNT": {
|
|
|
|
"free": 1.2,
|
|
|
|
"used": 1.9,
|
|
|
|
"total": 3.5
|
|
|
|
},
|
|
|
|
"GAS": {
|
|
|
|
"free": 0.270739,
|
|
|
|
"used": 0.1,
|
|
|
|
"total": 0.260439
|
|
|
|
},
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
freqtrade.wallets.update()
|
|
|
|
|
2019-02-28 22:26:29 +00:00
|
|
|
assert len(freqtrade.wallets._wallets) == 2
|
|
|
|
assert freqtrade.wallets._wallets['BNT'].free == 1.2
|
|
|
|
assert freqtrade.wallets._wallets['BNT'].used == 1.9
|
|
|
|
assert freqtrade.wallets._wallets['BNT'].total == 3.5
|
|
|
|
assert freqtrade.wallets._wallets['GAS'].free == 0.270739
|
|
|
|
assert freqtrade.wallets._wallets['GAS'].used == 0.1
|
|
|
|
assert freqtrade.wallets._wallets['GAS'].total == 0.260439
|
2018-11-26 05:22:53 +00:00
|
|
|
assert freqtrade.wallets.get_free('GAS') == 0.270739
|
2018-11-30 17:23:16 +00:00
|
|
|
assert freqtrade.wallets.get_used('GAS') == 0.1
|
|
|
|
assert freqtrade.wallets.get_total('GAS') == 0.260439
|
2018-11-21 18:47:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_sync_wallet_missing_data(mocker, default_conf):
|
2018-11-23 09:17:10 +00:00
|
|
|
default_conf['dry_run'] = False
|
2018-11-21 18:47:28 +00:00
|
|
|
mocker.patch.multiple(
|
|
|
|
'freqtrade.exchange.Exchange',
|
|
|
|
get_balances=MagicMock(return_value={
|
|
|
|
"BNT": {
|
|
|
|
"free": 1.0,
|
|
|
|
"used": 2.0,
|
|
|
|
"total": 3.0
|
|
|
|
},
|
|
|
|
"GAS": {
|
|
|
|
"free": 0.260739,
|
|
|
|
"total": 0.260739
|
|
|
|
},
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
|
|
|
|
2019-02-28 22:26:29 +00:00
|
|
|
assert len(freqtrade.wallets._wallets) == 2
|
|
|
|
assert freqtrade.wallets._wallets['BNT'].free == 1.0
|
|
|
|
assert freqtrade.wallets._wallets['BNT'].used == 2.0
|
|
|
|
assert freqtrade.wallets._wallets['BNT'].total == 3.0
|
|
|
|
assert freqtrade.wallets._wallets['GAS'].free == 0.260739
|
|
|
|
assert freqtrade.wallets._wallets['GAS'].used is None
|
|
|
|
assert freqtrade.wallets._wallets['GAS'].total == 0.260739
|
2018-11-26 05:22:53 +00:00
|
|
|
assert freqtrade.wallets.get_free('GAS') == 0.260739
|