Skip to content

Commit

Permalink
Fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thewhaleking committed Feb 7, 2025
1 parent 5fd0682 commit 89ac1c3
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ def get_commitment(self, netuid: int, uid: int, block: Optional[int] = None) ->
)
return ""

metadata = get_metadata(self, netuid, hotkey, block)
metadata = cast(dict, get_metadata(self, netuid, hotkey, block))
try:
return decode_metadata(metadata)

Expand Down
140 changes: 136 additions & 4 deletions tests/unit_tests/test_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ def test_query_map(subtensor, mocker):
params=None,
block_hash=None,
)
assert result == subtensor.substrate.query_map.return_value.value
assert result == subtensor.substrate.query_map.return_value


def test_query_constant(subtensor, mocker):
Expand Down Expand Up @@ -1682,16 +1682,148 @@ def test_get_commitment(subtensor, mocker):
fake_uid = 2
fake_block = 3
fake_hotkey = "hotkey"
fake_hex_data = "0x010203"
expected_result = bytes.fromhex(fake_hex_data[2:]).decode()
expected_result = (
"{'peer_id': '12D3KooWFWnHBmUFxvfL6PfZ5eGHdhgsEqNnsxuN1HE9EtfW8THi', "
"'model_huggingface_id': 'kmfoda/gpt2-1b-miner-3'}"
)

mocked_metagraph = mocker.MagicMock()
subtensor.metagraph = mocked_metagraph
mocked_metagraph.return_value.hotkeys = {fake_uid: fake_hotkey}

mocked_get_metadata = mocker.patch.object(subtensor_module, "get_metadata")
mocked_get_metadata.return_value = {
"info": {"fields": [{fake_hex_data: fake_hex_data}]}
"deposit": 0,
"block": 3843930,
"info": {
"fields": (
(
{
"Raw117": (
(
123,
39,
112,
101,
101,
114,
95,
105,
100,
39,
58,
32,
39,
49,
50,
68,
51,
75,
111,
111,
87,
70,
87,
110,
72,
66,
109,
85,
70,
120,
118,
102,
76,
54,
80,
102,
90,
53,
101,
71,
72,
100,
104,
103,
115,
69,
113,
78,
110,
115,
120,
117,
78,
49,
72,
69,
57,
69,
116,
102,
87,
56,
84,
72,
105,
39,
44,
32,
39,
109,
111,
100,
101,
108,
95,
104,
117,
103,
103,
105,
110,
103,
102,
97,
99,
101,
95,
105,
100,
39,
58,
32,
39,
107,
109,
102,
111,
100,
97,
47,
103,
112,
116,
50,
45,
49,
98,
45,
109,
105,
110,
101,
114,
45,
51,
39,
125,
),
)
},
),
)
},
}

# Call
Expand Down

0 comments on commit 89ac1c3

Please sign in to comment.