@@ -116,56 +116,6 @@ fn test_swap_total_hotkey_stake() {
116
116
} ) ;
117
117
}
118
118
119
- // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey -- test_swap_last_tx_block --exact --nocapture
120
- #[ test]
121
- fn test_swap_last_tx_block ( ) {
122
- new_test_ext ( 1 ) . execute_with ( || {
123
- let old_hotkey = U256 :: from ( 1 ) ;
124
- let new_hotkey = U256 :: from ( 2 ) ;
125
- let coldkey = U256 :: from ( 3 ) ;
126
- let mut weight = Weight :: zero ( ) ;
127
-
128
- LastTxBlock :: < Test > :: insert ( old_hotkey, 1000 ) ;
129
- assert_ok ! ( SubtensorModule :: perform_hotkey_swap(
130
- & old_hotkey,
131
- & new_hotkey,
132
- & coldkey,
133
- & mut weight
134
- ) ) ;
135
-
136
- assert ! ( !LastTxBlock :: <Test >:: contains_key( old_hotkey) ) ;
137
- assert_eq ! (
138
- LastTxBlock :: <Test >:: get( new_hotkey) ,
139
- SubtensorModule :: get_current_block_as_u64( )
140
- ) ;
141
- } ) ;
142
- }
143
-
144
- // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey -- test_swap_last_tx_block_delegate_take --exact --nocapture
145
- #[ test]
146
- fn test_swap_last_tx_block_delegate_take ( ) {
147
- new_test_ext ( 1 ) . execute_with ( || {
148
- let old_hotkey = U256 :: from ( 1 ) ;
149
- let new_hotkey = U256 :: from ( 2 ) ;
150
- let coldkey = U256 :: from ( 3 ) ;
151
- let mut weight = Weight :: zero ( ) ;
152
-
153
- crate :: LastTxBlockDelegateTake :: < Test > :: insert ( old_hotkey, 1000 ) ;
154
- assert_ok ! ( SubtensorModule :: perform_hotkey_swap(
155
- & old_hotkey,
156
- & new_hotkey,
157
- & coldkey,
158
- & mut weight
159
- ) ) ;
160
-
161
- assert ! ( !LastTxBlockDelegateTake :: <Test >:: contains_key( old_hotkey) ) ;
162
- assert_eq ! (
163
- LastTxBlockDelegateTake :: <Test >:: get( new_hotkey) ,
164
- SubtensorModule :: get_current_block_as_u64( )
165
- ) ;
166
- } ) ;
167
- }
168
-
169
119
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey -- test_swap_senate_members --exact --nocapture
170
120
#[ test]
171
121
fn test_swap_senate_members ( ) {
@@ -1387,3 +1337,39 @@ fn test_swap_hotkey_is_sn_owner_hotkey() {
1387
1337
assert_eq ! ( SubnetOwnerHotkey :: <Test >:: get( netuid) , new_hotkey) ;
1388
1338
} ) ;
1389
1339
}
1340
+
1341
+ // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey -- test_swap_hotkey_swap_rate_limits --exact --nocapture
1342
+ #[ test]
1343
+ fn test_swap_hotkey_swap_rate_limits ( ) {
1344
+ new_test_ext ( 1 ) . execute_with ( || {
1345
+ let old_hotkey = U256 :: from ( 1 ) ;
1346
+ let new_hotkey = U256 :: from ( 2 ) ;
1347
+ let coldkey = U256 :: from ( 3 ) ;
1348
+ let mut weight = Weight :: zero ( ) ;
1349
+
1350
+ let last_tx_block = 123 ;
1351
+ let delegate_take_block = 4567 ;
1352
+ let child_key_take_block = 8910 ;
1353
+
1354
+ // Set the last tx block for the old hotkey
1355
+ LastTxBlock :: < Test > :: insert ( old_hotkey, last_tx_block) ;
1356
+ // Set the last delegate take block for the old hotkey
1357
+ LastTxBlockDelegateTake :: < Test > :: insert ( old_hotkey, delegate_take_block) ;
1358
+ // Set last childkey take block for the old hotkey
1359
+ LastTxBlockChildKeyTake :: < Test > :: insert ( old_hotkey, child_key_take_block) ;
1360
+
1361
+ // Perform the swap
1362
+ SubtensorModule :: perform_hotkey_swap ( & old_hotkey, & new_hotkey, & coldkey, & mut weight) ;
1363
+
1364
+ // Check for new hotkey
1365
+ assert_eq ! ( LastTxBlock :: <Test >:: get( new_hotkey) , last_tx_block) ;
1366
+ assert_eq ! (
1367
+ LastTxBlockDelegateTake :: <Test >:: get( new_hotkey) ,
1368
+ delegate_take_block
1369
+ ) ;
1370
+ assert_eq ! (
1371
+ LastTxBlockChildKeyTake :: <Test >:: get( new_hotkey) ,
1372
+ child_key_take_block
1373
+ ) ;
1374
+ } ) ;
1375
+ }
0 commit comments