Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import scalecodec
from async_substrate_interface import AsyncSubstrateInterface
from async_substrate_interface.substrate_addons import RetryAsyncSubstrate
from async_substrate_interface.types import ScaleObj
from async_substrate_interface.utils.storage import StorageKey
from bittensor_drand import get_encrypted_commitment
from bittensor_wallet.utils import SS58_FORMAT
Expand Down Expand Up @@ -165,7 +166,6 @@

if TYPE_CHECKING:
from async_substrate_interface import AsyncQueryMapResult
from async_substrate_interface.types import ScaleObj
from bittensor_wallet import Keypair, Wallet

from bittensor.core.axon import Axon
Expand Down Expand Up @@ -5024,7 +5024,10 @@ async def is_fast_blocks(self) -> bool:
- <https://docs.learnbittensor.org/resources/glossary#fast-blocks>

"""
return await self.get_start_call_delay() == 10
slot_duration_obj = cast(
ScaleObj, await self.query_constant("Aura", "SlotDuration")
)
return slot_duration_obj.value == 250

async def is_hotkey_delegate(
self,
Expand Down
3 changes: 2 additions & 1 deletion bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4103,7 +4103,8 @@ def is_fast_blocks(self) -> bool:
- <https://docs.learnbittensor.org/resources/glossary#fast-blocks>

"""
return self.get_start_call_delay() == 10
slot_duration_obj = cast(ScaleObj, self.query_constant("Aura", "SlotDuration"))
return slot_duration_obj.value == 250

def is_hotkey_delegate(self, hotkey_ss58: str, block: Optional[int] = None) -> bool:
"""
Expand Down
11 changes: 6 additions & 5 deletions tests/unit_tests/test_async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6320,23 +6320,24 @@ async def test_mev_submit_encrypted_default_params(subtensor, fake_wallet, mocke
@pytest.mark.parametrize(
"fast_or_not, expected_result",
[
(10, True),
(5, False),
(250, True),
(12000, False),
],
)
@pytest.mark.asyncio
async def test_is_fast_blocks(subtensor, mocker, fast_or_not, expected_result):
"""Verifies that `is_fast_blocks` calls proper method with proper parameters."""
# Preps
mocked_get_start_call_delay = mocker.patch.object(
subtensor, "get_start_call_delay", return_value=fast_or_not
return_obj = mocker.Mock(value=fast_or_not)
mocked_query_constant = mocker.patch.object(
subtensor, "query_constant", return_value=return_obj
)

# Call
result = await subtensor.is_fast_blocks()

# Asserts
mocked_get_start_call_delay.assert_awaited_once()
mocked_query_constant.assert_awaited_once()
assert result == expected_result


Expand Down
11 changes: 6 additions & 5 deletions tests/unit_tests/test_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6435,22 +6435,23 @@ def test_mev_submit_encrypted_default_params(subtensor, fake_wallet, mocker):
@pytest.mark.parametrize(
"fast_or_not, expected_result",
[
(10, True),
(5, False),
(250, True),
(12000, False),
],
)
def test_is_fast_blocks(subtensor, mocker, fast_or_not, expected_result):
"""Verifies that `is_fast_blocks` calls proper method with proper parameters."""
# Preps
mocked_get_start_call_delay = mocker.patch.object(
subtensor, "get_start_call_delay", return_value=fast_or_not
return_obj = mocker.Mock(value=fast_or_not)
mocked_query_constant = mocker.patch.object(
subtensor, "query_constant", return_value=return_obj
)

# Call
result = subtensor.is_fast_blocks()

# Asserts
mocked_get_start_call_delay.assert_called_once()
mocked_query_constant.assert_called_once()
assert result == expected_result


Expand Down