@@ -1257,12 +1257,16 @@ fn test_swap_parent_hotkey_childkey_maps() {
1257
1257
let parent_old = U256 :: from ( 1 ) ;
1258
1258
let coldkey = U256 :: from ( 2 ) ;
1259
1259
let child = U256 :: from ( 3 ) ;
1260
+ let child_other = U256 :: from ( 4 ) ;
1260
1261
let parent_new = U256 :: from ( 4 ) ;
1261
1262
add_network ( netuid, 1 , 0 ) ;
1262
1263
SubtensorModule :: create_account_if_non_existent ( & coldkey, & parent_old) ;
1263
1264
1264
1265
// Set child and verify state maps
1265
1266
mock_set_children ( & coldkey, & parent_old, netuid, & [ ( u64:: MAX , child) ] ) ;
1267
+ // Schedule some pending child keys.
1268
+ mock_schedule_children ( & coldkey, & parent_old, netuid, & [ ( u64:: MAX , child_other) ] ) ;
1269
+
1266
1270
assert_eq ! (
1267
1271
ParentKeys :: <Test >:: get( child, netuid) ,
1268
1272
vec![ ( u64 :: MAX , parent_old) ]
@@ -1271,6 +1275,8 @@ fn test_swap_parent_hotkey_childkey_maps() {
1271
1275
ChildKeys :: <Test >:: get( parent_old, netuid) ,
1272
1276
vec![ ( u64 :: MAX , child) ]
1273
1277
) ;
1278
+ let existing_pending_child_keys = PendingChildKeys :: < Test > :: get ( netuid, parent_old) ;
1279
+ assert_eq ! ( existing_pending_child_keys. 0 , vec![ ( u64 :: MAX , child_other) ] ) ;
1274
1280
1275
1281
// Swap
1276
1282
let mut weight = Weight :: zero ( ) ;
@@ -1290,6 +1296,10 @@ fn test_swap_parent_hotkey_childkey_maps() {
1290
1296
ChildKeys :: <Test >:: get( parent_new, netuid) ,
1291
1297
vec![ ( u64 :: MAX , child) ]
1292
1298
) ;
1299
+ assert_eq ! (
1300
+ PendingChildKeys :: <Test >:: get( netuid, parent_new) ,
1301
+ existing_pending_child_keys // Entry under new hotkey.
1302
+ ) ;
1293
1303
} )
1294
1304
}
1295
1305
@@ -1307,6 +1317,8 @@ fn test_swap_child_hotkey_childkey_maps() {
1307
1317
1308
1318
// Set child and verify state maps
1309
1319
mock_set_children ( & coldkey, & parent, netuid, & [ ( u64:: MAX , child_old) ] ) ;
1320
+ // Schedule some pending child keys.
1321
+ mock_schedule_children ( & coldkey, & parent, netuid, & [ ( u64:: MAX , child_old) ] ) ;
1310
1322
1311
1323
assert_eq ! (
1312
1324
ParentKeys :: <Test >:: get( child_old, netuid) ,
@@ -1316,6 +1328,8 @@ fn test_swap_child_hotkey_childkey_maps() {
1316
1328
ChildKeys :: <Test >:: get( parent, netuid) ,
1317
1329
vec![ ( u64 :: MAX , child_old) ]
1318
1330
) ;
1331
+ let existing_pending_child_keys = PendingChildKeys :: < Test > :: get ( netuid, parent) ;
1332
+ assert_eq ! ( existing_pending_child_keys. 0 , vec![ ( u64 :: MAX , child_old) ] ) ;
1319
1333
1320
1334
// Swap
1321
1335
let mut weight = Weight :: zero ( ) ;
@@ -1335,5 +1349,9 @@ fn test_swap_child_hotkey_childkey_maps() {
1335
1349
ChildKeys :: <Test >:: get( parent, netuid) ,
1336
1350
vec![ ( u64 :: MAX , child_new) ]
1337
1351
) ;
1352
+ assert_eq ! (
1353
+ PendingChildKeys :: <Test >:: get( netuid, parent) ,
1354
+ ( vec![ ( u64 :: MAX , child_new) ] , existing_pending_child_keys. 1 ) // Same cooldown block.
1355
+ ) ;
1338
1356
} )
1339
1357
}
0 commit comments