@@ -48,35 +48,35 @@ def test_metagraph(subtensor, alice_wallet, bob_wallet, dave_wallet):
48
48
logging .console .info ("Testing test_metagraph_command" )
49
49
alice_subnet_netuid = 2
50
50
51
- # Register the subnet through Alice
51
+ logging . console . info ( " Register the subnet through Alice" )
52
52
assert subtensor .register_subnet (alice_wallet , True , True ), (
53
53
"Unable to register the subnet"
54
54
)
55
55
56
- # Verify subnet was created successfully
56
+ logging . console . info ( " Verify subnet was created successfully" )
57
57
assert subtensor .subnet_exists (alice_subnet_netuid ), (
58
58
"Subnet wasn't created successfully"
59
59
)
60
60
61
- # make sure we passed start_call limit (10 blocks)
61
+ logging . console . info ( "Make sure we passed start_call limit (10 blocks)" )
62
62
subtensor .wait_for_block (subtensor .block + 10 )
63
63
assert subtensor .start_call (alice_wallet , alice_subnet_netuid , True , True )[0 ]
64
64
65
- # Initialize metagraph
65
+ logging . console . info ( " Initialize metagraph" )
66
66
metagraph = subtensor .metagraph (netuid = alice_subnet_netuid )
67
67
68
- # Assert metagraph has only Alice (owner)
68
+ logging . console . info ( " Assert metagraph has only Alice (owner)" )
69
69
assert len (metagraph .uids ) == 1 , "Metagraph doesn't have exactly 1 neuron"
70
70
71
- # Register Bob to the subnet
71
+ logging . console . info ( " Register Bob to the subnet" )
72
72
assert subtensor .burned_register (bob_wallet , alice_subnet_netuid ), (
73
73
"Unable to register Bob as a neuron"
74
74
)
75
75
76
- # Refresh the metagraph
76
+ logging . console . info ( " Refresh the metagraph" )
77
77
metagraph .sync (subtensor = subtensor )
78
78
79
- # Assert metagraph has Alice and Bob neurons
79
+ logging . console . info ( " Assert metagraph has Alice and Bob neurons" )
80
80
assert len (metagraph .uids ) == 2 , "Metagraph doesn't have exactly 2 neurons"
81
81
assert metagraph .hotkeys [0 ] == alice_wallet .hotkey .ss58_address , (
82
82
"Alice's hotkey doesn't match in metagraph"
@@ -89,36 +89,33 @@ def test_metagraph(subtensor, alice_wallet, bob_wallet, dave_wallet):
89
89
assert metagraph .n .min () == 2 , "Metagraph's min n is not 2"
90
90
assert len (metagraph .addresses ) == 2 , "Metagraph doesn't have exactly 2 address"
91
91
92
- # Fetch UID of Bob
92
+ logging . console . info ( " Fetch UID of Bob" )
93
93
uid = subtensor .get_uid_for_hotkey_on_subnet (
94
94
bob_wallet .hotkey .ss58_address , netuid = alice_subnet_netuid
95
95
)
96
96
97
- # Fetch neuron info of Bob through subtensor and metagraph
97
+ logging . console . info ( " Fetch neuron info of Bob through subtensor and metagraph" )
98
98
neuron_info_bob = subtensor .neuron_for_uid (uid , netuid = alice_subnet_netuid )
99
- print ( ">>> neuron_info_bob" , neuron_info_bob )
99
+
100
100
metagraph_dict = neuron_to_dict (metagraph .neurons [uid ])
101
101
subtensor_dict = neuron_to_dict (neuron_info_bob )
102
102
103
- print (">>> metagraph_dict" , metagraph_dict )
104
- print (">>> subtensor_dict" , subtensor_dict )
105
-
106
- # Verify neuron info is the same in both objects
103
+ logging .console .info ("Verify neuron info is the same in both objects" )
107
104
assert metagraph_dict == subtensor_dict , (
108
105
"Neuron info of Bob doesn't match b/w metagraph & subtensor"
109
106
)
110
107
111
- # Create pre_dave metagraph for future verifications
108
+ logging . console . info ( " Create pre_dave metagraph for future verifications" )
112
109
metagraph_pre_dave = subtensor .metagraph (netuid = alice_subnet_netuid )
113
110
114
- # Register Dave as a neuron
111
+ logging . console . info ( " Register Dave as a neuron" )
115
112
assert subtensor .burned_register (dave_wallet , alice_subnet_netuid ), (
116
113
"Unable to register Dave as a neuron"
117
114
)
118
115
119
116
metagraph .sync (subtensor = subtensor )
120
117
121
- # Assert metagraph now includes Dave's neuron
118
+ logging . console . info ( " Assert metagraph now includes Dave's neuron" )
122
119
assert len (metagraph .uids ) == 3 , (
123
120
"Metagraph doesn't have exactly 3 neurons post Dave"
124
121
)
@@ -132,7 +129,7 @@ def test_metagraph(subtensor, alice_wallet, bob_wallet, dave_wallet):
132
129
assert metagraph .n .min () == 3 , "Metagraph's min n is not 3 post Dave"
133
130
assert len (metagraph .addresses ) == 3 , "Metagraph doesn't have 3 addresses post Dave"
134
131
135
- # Add stake by Bob
132
+ logging . console . info ( " Add stake by Bob" )
136
133
tao = Balance .from_tao (10_000 )
137
134
alpha , _ = subtensor .subnet (alice_subnet_netuid ).tao_to_alpha_with_slippage (tao )
138
135
assert subtensor .add_stake (
@@ -143,13 +140,13 @@ def test_metagraph(subtensor, alice_wallet, bob_wallet, dave_wallet):
143
140
wait_for_finalization = True ,
144
141
), "Failed to add stake for Bob"
145
142
146
- # Assert stake is added after updating metagraph
143
+ logging . console . info ( " Assert stake is added after updating metagraph" )
147
144
metagraph .sync (subtensor = subtensor )
148
145
assert 0.95 < metagraph .neurons [1 ].stake .rao / alpha .rao < 1.05 , (
149
146
"Bob's stake not updated in metagraph"
150
147
)
151
148
152
- # Test the save() and load() mechanism
149
+ logging . console . info ( " Test the save() and load() mechanism" )
153
150
# We save the metagraph and pre_dave loads it
154
151
# We do this in the /tmp dir to avoid interfering or interacting with user data
155
152
metagraph_save_root_dir = ["/" , "tmp" , "bittensor-e2e" , "metagraphs" ]
@@ -161,7 +158,7 @@ def test_metagraph(subtensor, alice_wallet, bob_wallet, dave_wallet):
161
158
finally :
162
159
shutil .rmtree (os .path .join (* metagraph_save_root_dir ))
163
160
164
- # Ensure data is synced between two metagraphs
161
+ logging . console . info ( " Ensure data is synced between two metagraphs" )
165
162
assert len (metagraph .uids ) == len (metagraph_pre_dave .uids ), (
166
163
"UID count mismatch after save and load"
167
164
)
0 commit comments