|
7 | 7 | from tests.e2e_tests.utils.chain_interactions import (
|
8 | 8 | sudo_set_admin_utils,
|
9 | 9 | sudo_set_hyperparameter_bool,
|
| 10 | + use_and_wait_for_next_nonce, |
10 | 11 | wait_epoch,
|
11 | 12 | )
|
12 | 13 |
|
@@ -227,42 +228,44 @@ async def test_commit_weights_uses_next_nonce(local_chain, subtensor, alice_wall
|
227 | 228 | salt3[0] += 2 # Increment the first byte to produce a different commit hash
|
228 | 229 |
|
229 | 230 | # Commit all three salts
|
230 |
| - success, message = subtensor.commit_weights( |
231 |
| - alice_wallet, |
232 |
| - netuid, |
233 |
| - salt=salt, |
234 |
| - uids=weight_uids, |
235 |
| - weights=weight_vals, |
236 |
| - wait_for_inclusion=False, # Don't wait for inclusion, we are testing the nonce when there is a tx in the pool |
237 |
| - wait_for_finalization=False, |
238 |
| - ) |
239 |
| - |
240 |
| - assert success is True |
241 |
| - |
242 |
| - success, message = subtensor.commit_weights( |
243 |
| - alice_wallet, |
244 |
| - netuid, |
245 |
| - salt=salt2, |
246 |
| - uids=weight_uids, |
247 |
| - weights=weight_vals, |
248 |
| - wait_for_inclusion=False, |
249 |
| - wait_for_finalization=False, |
250 |
| - ) |
251 |
| - |
252 |
| - assert success is True |
253 |
| - |
254 |
| - # Commit the third salt |
255 |
| - success, message = subtensor.commit_weights( |
256 |
| - alice_wallet, |
257 |
| - netuid, |
258 |
| - salt=salt3, |
259 |
| - uids=weight_uids, |
260 |
| - weights=weight_vals, |
261 |
| - wait_for_inclusion=False, |
262 |
| - wait_for_finalization=False, |
263 |
| - ) |
264 |
| - |
265 |
| - assert success is True |
| 231 | + async with use_and_wait_for_next_nonce(subtensor, alice_wallet): |
| 232 | + success, message = subtensor.commit_weights( |
| 233 | + alice_wallet, |
| 234 | + netuid, |
| 235 | + salt=salt, |
| 236 | + uids=weight_uids, |
| 237 | + weights=weight_vals, |
| 238 | + wait_for_inclusion=False, # Don't wait for inclusion, we are testing the nonce when there is a tx in the pool |
| 239 | + wait_for_finalization=False, |
| 240 | + ) |
| 241 | + |
| 242 | + assert success is True |
| 243 | + |
| 244 | + async with use_and_wait_for_next_nonce(subtensor, alice_wallet): |
| 245 | + success, message = subtensor.commit_weights( |
| 246 | + alice_wallet, |
| 247 | + netuid, |
| 248 | + salt=salt2, |
| 249 | + uids=weight_uids, |
| 250 | + weights=weight_vals, |
| 251 | + wait_for_inclusion=False, |
| 252 | + wait_for_finalization=False, |
| 253 | + ) |
| 254 | + |
| 255 | + assert success is True |
| 256 | + |
| 257 | + async with use_and_wait_for_next_nonce(subtensor, alice_wallet): |
| 258 | + success, message = subtensor.commit_weights( |
| 259 | + alice_wallet, |
| 260 | + netuid, |
| 261 | + salt=salt3, |
| 262 | + uids=weight_uids, |
| 263 | + weights=weight_vals, |
| 264 | + wait_for_inclusion=False, |
| 265 | + wait_for_finalization=False, |
| 266 | + ) |
| 267 | + |
| 268 | + assert success is True |
266 | 269 |
|
267 | 270 | # Wait a few blocks
|
268 | 271 | await asyncio.sleep(10) # Wait for the txs to be included in the chain
|
|
0 commit comments