1
+ import datetime
1
2
import unittest .mock as mock
2
3
3
4
import pytest
5
+ from async_substrate_interface .types import ScaleObj
4
6
from bittensor_wallet import Wallet
5
7
6
8
from bittensor import u64_normalized_float
@@ -1231,9 +1233,9 @@ async def test_get_delegated_no_block_hash_no_reuse(subtensor, mocker):
1231
1233
# Preps
1232
1234
fake_coldkey_ss58 = "fake_ss58_address"
1233
1235
1234
- mocked_delegated_list_from_dicts = mocker .Mock ()
1235
- async_subtensor . DelegateInfo . delegated_list_from_dicts = (
1236
- mocked_delegated_list_from_dicts
1236
+ mocked_delegated_list_from_dicts = mocker .patch . object (
1237
+ async_subtensor . DelegatedInfo ,
1238
+ "list_from_dicts" ,
1237
1239
)
1238
1240
1239
1241
# Call
@@ -1259,9 +1261,9 @@ async def test_get_delegated_with_block_hash(subtensor, mocker):
1259
1261
fake_coldkey_ss58 = "fake_ss58_address"
1260
1262
fake_block_hash = "fake_block_hash"
1261
1263
1262
- mocked_delegated_list_from_dicts = mocker .Mock ()
1263
- async_subtensor . DelegateInfo . delegated_list_from_dicts = (
1264
- mocked_delegated_list_from_dicts
1264
+ mocked_delegated_list_from_dicts = mocker .patch . object (
1265
+ async_subtensor . DelegatedInfo ,
1266
+ "list_from_dicts" ,
1265
1267
)
1266
1268
1267
1269
# Call
@@ -1289,9 +1291,9 @@ async def test_get_delegated_with_reuse_block(subtensor, mocker):
1289
1291
fake_coldkey_ss58 = "fake_ss58_address"
1290
1292
reuse_block = True
1291
1293
1292
- mocked_delegated_list_from_dicts = mocker .Mock ()
1293
- async_subtensor . DelegateInfo . delegated_list_from_dicts = (
1294
- mocked_delegated_list_from_dicts
1294
+ mocked_delegated_list_from_dicts = mocker .patch . object (
1295
+ async_subtensor . DelegatedInfo ,
1296
+ "list_from_dicts" ,
1295
1297
)
1296
1298
1297
1299
# Call
@@ -2714,3 +2716,15 @@ async def test_get_all_neuron_certificates(mocker, subtensor):
2714
2716
block_hash = None ,
2715
2717
reuse_block_hash = False ,
2716
2718
)
2719
+
2720
+
2721
+ @pytest .mark .asyncio
2722
+ async def test_get_timestamp (mocker , subtensor ):
2723
+ fake_block = 1000
2724
+ mocked_query = mocker .AsyncMock (return_value = ScaleObj (1740586018 * 1000 ))
2725
+ mocker .patch .object (subtensor .substrate , "query" , mocked_query )
2726
+ expected_result = datetime .datetime (
2727
+ 2025 , 2 , 26 , 16 , 6 , 58 , tzinfo = datetime .timezone .utc
2728
+ )
2729
+ actual_result = await subtensor .get_timestamp (block = fake_block )
2730
+ assert expected_result == actual_result
0 commit comments