Skip to content

Commit eefb2fe

Browse files
authored
Merge branch 'staging' into feat/roman/add-timelock
2 parents 999c51b + 2e67a4a commit eefb2fe

File tree

4 files changed

+159
-2
lines changed

4 files changed

+159
-2
lines changed

bittensor/core/chain_data/metagraph_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _chr_str(codes: tuple[int]) -> str:
2525
def process_nested(data: Union[tuple, dict], chr_transform):
2626
"""Processes nested data structures by applying a transformation function to their elements."""
2727
if isinstance(data, (list, tuple)):
28-
if len(data) > 0 and isinstance(data[0], dict):
28+
if len(data) > 0:
2929
return [
3030
{k: chr_transform(v) for k, v in item.items()}
3131
if item is not None

tests/e2e_tests/test_metagraph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def test_metagraph_info(subtensor, alice_wallet):
243243
bonds_moving_avg=4.87890977618477e-14,
244244
hotkeys=["5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM"],
245245
coldkeys=["5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM"],
246-
identities={},
246+
identities=[None],
247247
axons=(
248248
{
249249
"block": 0,

tests/unit_tests/chain_data/__init__.py

Whitespace-only changes.
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
from bittensor.core.chain_data.metagraph_info import process_nested, _chr_str
2+
3+
4+
def test_process_nested():
5+
"""Tests process_nested function."""
6+
# Preps
7+
data = (
8+
None,
9+
{
10+
"name": (
11+
89,
12+
117,
13+
109,
14+
97,
15+
44,
16+
32,
17+
97,
18+
32,
19+
68,
20+
67,
21+
71,
22+
32,
23+
67,
24+
111,
25+
109,
26+
112,
27+
97,
28+
110,
29+
121,
30+
),
31+
"url": (
32+
104,
33+
116,
34+
116,
35+
112,
36+
115,
37+
58,
38+
47,
39+
47,
40+
121,
41+
117,
42+
109,
43+
97,
44+
97,
45+
105,
46+
46,
47+
99,
48+
111,
49+
109,
50+
47,
51+
),
52+
"github_repo": (),
53+
"image": (
54+
104,
55+
116,
56+
116,
57+
112,
58+
115,
59+
58,
60+
47,
61+
47,
62+
116,
63+
105,
64+
110,
65+
121,
66+
117,
67+
114,
68+
108,
69+
46,
70+
99,
71+
111,
72+
109,
73+
47,
74+
50,
75+
121,
76+
121,
77+
120,
78+
100,
79+
106,
80+
98,
81+
112,
82+
),
83+
"discord": (),
84+
"description": (
85+
89,
86+
117,
87+
109,
88+
97,
89+
32,
90+
112,
91+
111,
92+
119,
93+
101,
94+
114,
95+
115,
96+
32,
97+
116,
98+
114,
99+
97,
100+
110,
101+
115,
102+
102,
103+
111,
104+
114,
105+
109,
106+
97,
107+
116,
108+
105,
109+
118,
110+
101,
111+
32,
112+
112,
113+
114,
114+
111,
115+
106,
116+
101,
117+
99,
118+
116,
119+
115,
120+
32,
121+
111,
122+
110,
123+
32,
124+
66,
125+
105,
126+
116,
127+
116,
128+
101,
129+
110,
130+
115,
131+
111,
132+
114,
133+
46,
134+
),
135+
"additional": (),
136+
},
137+
None,
138+
)
139+
expected_result = [
140+
None,
141+
{
142+
"additional": "",
143+
"description": "Yuma powers transformative projects on Bittensor.",
144+
"discord": "",
145+
"github_repo": "",
146+
"image": "https://tinyurl.com/2yyxdjbp",
147+
"name": "Yuma, a DCG Company",
148+
"url": "https://yumaai.com/",
149+
},
150+
None,
151+
]
152+
153+
# Call
154+
result = process_nested(data, _chr_str)
155+
156+
# Asserts
157+
assert result == expected_result

0 commit comments

Comments
 (0)