Fix calculate_backoff implementation

This commit is contained in:
Matthias 2020-06-28 19:40:33 +02:00
parent cbcbb4bdb5
commit 6362bfc36e
2 changed files with 11 additions and 11 deletions

View File

@ -91,11 +91,11 @@ MAP_EXCHANGE_CHILDCLASS = {
}
def calculate_backoff(retry, max_retries):
def calculate_backoff(retrycount, max_retries):
"""
Calculate backoff
"""
return retry ** 2 + 1
return (max_retries - retrycount) ** 2 + 1
def retrier_async(f):

View File

@ -2298,13 +2298,13 @@ def test_calculate_fee_rate(mocker, default_conf, order, expected) -> None:
assert ex.calculate_fee_rate(order) == expected
@pytest.mark.parametrize('retry,max_retries,expected', [
(0, 3, 1),
(1, 3, 2),
(2, 3, 5),
(3, 3, 10),
(0, 1, 1),
(1, 1, 2),
@pytest.mark.parametrize('retrycount,max_retries,expected', [
(0, 3, 10),
(1, 3, 5),
(2, 3, 2),
(3, 3, 1),
(0, 1, 2),
(1, 1, 1),
])
def test_calculate_backoff(retry, max_retries, expected):
assert calculate_backoff(retry, max_retries) == expected
def test_calculate_backoff(retrycount, max_retries, expected):
assert calculate_backoff(retrycount, max_retries) == expected