@@ -30,17 +30,22 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
3030 Raises:
3131 AssertionError: If any of the checks or verifications fail
3232 """
33- BLOCK_TIME = 0.25 # 12 for non-fast-block, 0.25 for fast block
34- netuid = 2
33+ BLOCK_TIME = (
34+ 0.25 if subtensor .is_fast_blocks () else 12.0
35+ ) # 12 for non-fast-block, 0.25 for fast block
36+ netuid = subtensor .get_total_subnets () # 2
37+
3538 logging .console .info ("Testing test_commit_and_reveal_weights" )
3639
3740 # Register root as Alice
3841 assert subtensor .register_subnet (alice_wallet ), "Unable to register the subnet"
3942
4043 # Verify subnet 2 created successfully
41- assert subtensor .subnet_exists (netuid ), "Subnet wasn't created successfully"
44+ assert subtensor .subnet_exists (netuid ), (
45+ f"Subnet { netuid } wasn't created successfully"
46+ )
4247
43- logging .console .info ( "Subnet 2 is registered" )
48+ logging .console .success ( f "Subnet { netuid } is registered" )
4449
4550 # Enable commit_reveal on the subnet
4651 assert sudo_set_hyperparameter_bool (
@@ -74,7 +79,7 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
7479 logging .console .info ("sudo_set_weights_set_rate_limit executed: set to 0" )
7580
7681 # Change the tempo of the subnet
77- tempo_set = 50
82+ tempo_set = 50 if subtensor . is_fast_blocks () else 10
7883 assert (
7984 sudo_set_admin_utils (
8085 local_chain ,
@@ -103,7 +108,7 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
103108 )
104109
105110 # Wait for 2 tempos to pass as CR3 only reveals weights after 2 tempos + 1
106- subtensor .wait_for_block (( tempo_set * 2 ) + 1 )
111+ subtensor .wait_for_block (tempo_set * 2 + 1 )
107112
108113 # Lower than this might mean weights will get revealed before we can check them
109114 if upcoming_tempo - current_block < 3 :
@@ -117,7 +122,7 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
117122 latest_drand_round = subtensor .last_drand_round ()
118123 upcoming_tempo = next_tempo (current_block , tempo )
119124 logging .console .info (
120- f"Post first wait_interval (to ensure window isnt too low): { current_block } , next tempo: { upcoming_tempo } , drand: { latest_drand_round } "
125+ f"Post first wait_interval (to ensure window isn't too low): { current_block } , next tempo: { upcoming_tempo } , drand: { latest_drand_round } "
121126 )
122127
123128 # Commit weights
@@ -171,6 +176,7 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
171176 subtensor ,
172177 netuid = netuid ,
173178 reporting_interval = 1 ,
179+ sleep = BLOCK_TIME ,
174180 )
175181
176182 # Fetch the latest drand pulse
0 commit comments