|
| 1 | +import asyncio |
| 2 | +import time |
| 3 | + |
| 4 | +import pytest |
| 5 | + |
| 6 | +from tests.e2e_tests.utils import ( |
| 7 | + AdminUtils, |
| 8 | + TestSubnet, |
| 9 | + ACTIVATE_SUBNET, |
| 10 | + REGISTER_SUBNET, |
| 11 | + SUDO_SET_START_CALL_DELAY, |
| 12 | +) |
| 13 | + |
| 14 | + |
| 15 | +def test_start_call_with_delay(subtensor, alice_wallet, eve_wallet): |
| 16 | + """Test for start call with delay. |
| 17 | +
|
| 18 | + Steps: |
| 19 | + - Prepare root subnet and eve subnet |
| 20 | + - Check initial start call delay value |
| 21 | + - Set new start call delay via sudo call |
| 22 | + - Verify the new start call delay is applied |
| 23 | + - Register and activate eve subnet to verify it works with a new delay |
| 24 | + """ |
| 25 | + # Preps |
| 26 | + sn_root = TestSubnet(subtensor, netuid=0) |
| 27 | + eve_sn = TestSubnet(subtensor) |
| 28 | + |
| 29 | + # Set a new start call delay |
| 30 | + new_start_call_delay = 20 |
| 31 | + |
| 32 | + # Check the initial start call delay |
| 33 | + initial_start_call = subtensor.inner_subtensor.query_subtensor( |
| 34 | + name="StartCallDelay" |
| 35 | + ) |
| 36 | + assert initial_start_call == subtensor.chain.get_start_call_delay() |
| 37 | + |
| 38 | + # Set a new start call delay via sudo call |
| 39 | + sn_root.execute_one( |
| 40 | + SUDO_SET_START_CALL_DELAY(alice_wallet, AdminUtils, True, new_start_call_delay) |
| 41 | + ) |
| 42 | + |
| 43 | + # Check a new start call delay is set |
| 44 | + assert subtensor.chain.get_start_call_delay() == new_start_call_delay |
| 45 | + |
| 46 | + # Verify eve subnet can be activated with a new start call delay |
| 47 | + eve_sn.execute_steps( |
| 48 | + [ |
| 49 | + REGISTER_SUBNET(eve_wallet), |
| 50 | + ACTIVATE_SUBNET(eve_wallet), |
| 51 | + ] |
| 52 | + ) |
| 53 | + |
| 54 | + |
| 55 | +@pytest.mark.asyncio |
| 56 | +async def test_start_call_with_delay_async(async_subtensor, alice_wallet, eve_wallet): |
| 57 | + """Async test for start call with delay. |
| 58 | +
|
| 59 | + Steps: |
| 60 | + - Prepare root subnet and eve subnet |
| 61 | + - Check initial start call delay value |
| 62 | + - Set new start call delay via sudo call |
| 63 | + - Verify the new start call delay is applied |
| 64 | + - Register and activate eve subnet to verify it works with a new delay |
| 65 | + """ |
| 66 | + # Preps |
| 67 | + sn_root = TestSubnet(async_subtensor, netuid=0) |
| 68 | + eve_sn = TestSubnet(async_subtensor) |
| 69 | + |
| 70 | + # Set a new start call delay |
| 71 | + new_start_call_delay = 20 |
| 72 | + |
| 73 | + # Check the initial start call delay |
| 74 | + initial_start_call = await async_subtensor.inner_subtensor.query_subtensor( |
| 75 | + name="StartCallDelay" |
| 76 | + ) |
| 77 | + assert initial_start_call == await async_subtensor.chain.get_start_call_delay() |
| 78 | + |
| 79 | + # Set a new start call delay via sudo call |
| 80 | + await sn_root.async_execute_one( |
| 81 | + SUDO_SET_START_CALL_DELAY(alice_wallet, AdminUtils, True, new_start_call_delay) |
| 82 | + ) |
| 83 | + |
| 84 | + # Check a new start call delay is set |
| 85 | + assert await async_subtensor.chain.get_start_call_delay() == new_start_call_delay |
| 86 | + |
| 87 | + # Verify eve subnet can be activated with a new start call delay |
| 88 | + await eve_sn.async_execute_steps( |
| 89 | + [ |
| 90 | + REGISTER_SUBNET(eve_wallet), |
| 91 | + ACTIVATE_SUBNET(eve_wallet), |
| 92 | + ] |
| 93 | + ) |
0 commit comments