Skip to content

Commit

Permalink
Increase delay and retries in account tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samtin0x committed Jun 24, 2024
1 parent 4a358b7 commit 01a6d45
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
7 changes: 6 additions & 1 deletion v4-client-py-v2/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async def wallet(node_client, private_key, test_address):
return await get_wallet(node_client, private_key, test_address)


def retry_on_forbidden(max_retries=3, delay=1):
def retry_on_forbidden(max_retries=3, delay=1, skip=False):
def decorator(func):
@wraps(func)
async def wrapper(*args, **kwargs):
Expand All @@ -115,6 +115,11 @@ async def wrapper(*args, **kwargs):
if attempt < max_retries - 1:
await asyncio.sleep(delay)
continue
else:
if skip:
pytest.skip("403 Forbidden error. Skipping the test.")
else:
raise
raise
raise httpx.HTTPStatusError(
request=e.request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@pytest.mark.asyncio
@retry_on_forbidden(max_retries=3, delay=1)
@retry_on_forbidden(max_retries=3, delay=1, skip=True)
async def test_subaccounts(indexer_rest_client, test_address):
response = await indexer_rest_client.account.get_subaccounts(test_address)
subaccounts = response["subaccounts"]
Expand All @@ -17,7 +17,7 @@ async def test_subaccounts(indexer_rest_client, test_address):


@pytest.mark.asyncio
@retry_on_forbidden(max_retries=3, delay=1)
@retry_on_forbidden(max_retries=3, delay=1, skip=True)
async def test_subaccount_0(indexer_rest_client, test_address):
response = await indexer_rest_client.account.get_subaccount(test_address, 0)
subaccount = response["subaccount"]
Expand All @@ -27,7 +27,7 @@ async def test_subaccount_0(indexer_rest_client, test_address):


@pytest.mark.asyncio
@retry_on_forbidden(max_retries=3, delay=1)
@retry_on_forbidden(max_retries=3, delay=1, skip=True)
async def test_asset_positions(indexer_rest_client, test_address):
response = await indexer_rest_client.account.get_subaccount_asset_positions(
test_address, 0
Expand All @@ -41,7 +41,7 @@ async def test_asset_positions(indexer_rest_client, test_address):


@pytest.mark.asyncio
@retry_on_forbidden(max_retries=3, delay=1)
@retry_on_forbidden(max_retries=3, delay=1, skip=True)
async def test_perpetual_positions(indexer_rest_client, test_address):
response = await indexer_rest_client.account.get_subaccount_perpetual_positions(
test_address, 0
Expand All @@ -55,7 +55,7 @@ async def test_perpetual_positions(indexer_rest_client, test_address):


@pytest.mark.asyncio
@retry_on_forbidden(max_retries=3, delay=1)
@retry_on_forbidden(max_retries=3, delay=1, skip=True)
async def test_transfers(indexer_rest_client, test_address):
response = await indexer_rest_client.account.get_subaccount_transfers(
test_address, 0
Expand All @@ -69,7 +69,7 @@ async def test_transfers(indexer_rest_client, test_address):


@pytest.mark.asyncio
@retry_on_forbidden(max_retries=3, delay=1)
@retry_on_forbidden(max_retries=3, delay=1, skip=True)
async def test_orders(indexer_rest_client, test_address):
response = await indexer_rest_client.account.get_subaccount_orders(test_address, 0)
assert response is not None
Expand All @@ -81,7 +81,7 @@ async def test_orders(indexer_rest_client, test_address):


@pytest.mark.asyncio
@retry_on_forbidden(max_retries=3, delay=1)
@retry_on_forbidden(max_retries=3, delay=1, skip=True)
async def test_fills(indexer_rest_client, test_address):
response = await indexer_rest_client.account.get_subaccount_fills(test_address, 0)
assert response is not None
Expand All @@ -93,7 +93,7 @@ async def test_fills(indexer_rest_client, test_address):


@pytest.mark.asyncio
@retry_on_forbidden(max_retries=3, delay=1)
@retry_on_forbidden(max_retries=3, delay=1, skip=True)
async def test_historical_pnl(indexer_rest_client, test_address):
response = await indexer_rest_client.account.get_subaccount_historical_pnls(
test_address, 0
Expand All @@ -107,7 +107,7 @@ async def test_historical_pnl(indexer_rest_client, test_address):


@pytest.mark.asyncio
@retry_on_forbidden(max_retries=3, delay=1)
@retry_on_forbidden(max_retries=3, delay=1, skip=True)
async def test_historical_block_trading_rewards(indexer_rest_client, test_address):
limit = 10
response = await indexer_rest_client.account.get_historical_block_trading_rewards(
Expand All @@ -124,7 +124,7 @@ async def test_historical_block_trading_rewards(indexer_rest_client, test_addres


@pytest.mark.asyncio
@retry_on_forbidden(max_retries=3, delay=1)
@retry_on_forbidden(max_retries=3, delay=1, skip=True)
async def test_historical_trading_rewards_aggregated(indexer_rest_client, test_address):
period = TradingRewardAggregationPeriod.DAILY
limit = 10
Expand Down

0 comments on commit 01a6d45

Please sign in to comment.