Skip to content

Commit f8f5b89

Browse files
author
Roman
committed
convert wait_for_new_nonce to sync
1 parent 77c5321 commit f8f5b89

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/e2e_tests/utils/chain_interactions.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
these are not present in btsdk but are required for e2e tests
44
"""
55

6+
import time
67
import asyncio
78
import contextlib
89
from typing import Union, Optional, TYPE_CHECKING
@@ -160,22 +161,25 @@ async def use_and_wait_for_next_nonce(
160161

161162
yield
162163

163-
async def wait_for_new_nonce():
164+
def wait_for_new_nonce():
165+
now = time.time()
164166
while nonce == subtensor.substrate.get_account_next_index(
165167
wallet.hotkey.ss58_address
166168
):
169+
if time.time() - now > timeout:
170+
raise TimeoutError(f"Timeout waiting for new nonce.")
167171
logging.console.info(
168172
f"Waiting for new nonce. Current nonce: {nonce} for wallet {wallet.hotkey.ss58_address}"
169173
)
170-
await asyncio.sleep(sleep)
174+
time.sleep(sleep)
171175

172176
# give the chain 3 tries to reveal a new nonce after latest extrinsic call
173177
max_retries = 3
174178
for attempt in range(max_retries):
175179
try:
176-
await asyncio.wait_for(wait_for_new_nonce(), timeout)
180+
wait_for_new_nonce()
177181
break
178-
except asyncio.TimeoutError:
182+
except TimeoutError:
179183
logging.warning(f"Attempt {attempt + 1} of {max_retries} timed out.")
180184
if attempt + 1 == max_retries:
181185
raise

0 commit comments

Comments
 (0)