Skip to content

Commit d6bce54

Browse files
fix: wait_epoch didn't take tempo +1 into account when called with times arg
1 parent 9730f51 commit d6bce54

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/e2e_tests/utils/chain_interactions.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def sudo_set_hyperparameter_values(
7474
return response.is_success
7575

7676

77-
async def wait_epoch(subtensor: "Subtensor", netuid: int = 1, times: int = 1):
77+
async def wait_epoch(subtensor: "Subtensor", netuid: int = 1, **kwargs):
7878
"""
7979
Waits for the next epoch to start on a specific subnet.
8080
@@ -90,7 +90,7 @@ async def wait_epoch(subtensor: "Subtensor", netuid: int = 1, times: int = 1):
9090
raise Exception("could not determine tempo")
9191
tempo = q_tempo[0].value
9292
logging.info(f"tempo = {tempo}")
93-
await wait_interval(tempo * times, subtensor, netuid)
93+
await wait_interval(tempo, subtensor, netuid, **kwargs)
9494

9595

9696
def next_tempo(current_block: int, tempo: int, netuid: int) -> int:
@@ -117,6 +117,7 @@ async def wait_interval(
117117
netuid: int = 1,
118118
reporting_interval: int = 1,
119119
sleep: float = 0.25,
120+
times: int = 1,
120121
):
121122
"""
122123
Waits until the next tempo interval starts for a specific subnet.
@@ -126,7 +127,11 @@ async def wait_interval(
126127
the current block number until the next tempo interval starts.
127128
"""
128129
current_block = subtensor.get_current_block()
129-
next_tempo_block_start = next_tempo(current_block, tempo, netuid)
130+
next_tempo_block_start = current_block
131+
132+
for _ in range(times):
133+
next_tempo_block_start = next_tempo(next_tempo_block_start, tempo, netuid)
134+
130135
last_reported = None
131136

132137
while current_block < next_tempo_block_start:

0 commit comments

Comments
 (0)