@@ -1334,91 +1334,3 @@ fn test_swap_child_hotkey_childkey_maps() {
1334
1334
) ;
1335
1335
} )
1336
1336
}
1337
-
1338
- // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey -- test_hotkey_swap_stake_delta --exact --nocapture
1339
- #[ test]
1340
- fn test_hotkey_swap_stake_delta ( ) {
1341
- new_test_ext ( 1 ) . execute_with ( || {
1342
- let old_hotkey = U256 :: from ( 3 ) ;
1343
- let new_hotkey = U256 :: from ( 4 ) ;
1344
- let coldkey = U256 :: from ( 7 ) ;
1345
-
1346
- let coldkeys = [ U256 :: from ( 1 ) , U256 :: from ( 2 ) , U256 :: from ( 5 ) ] ;
1347
-
1348
- let mut weight = Weight :: zero ( ) ;
1349
-
1350
- // Set up initial state
1351
- // Add stake delta for each coldkey and the old_hotkey
1352
- for & coldkey in coldkeys. iter ( ) {
1353
- StakeDeltaSinceLastEmissionDrain :: < Test > :: insert (
1354
- old_hotkey,
1355
- coldkey,
1356
- ( 123 + coldkey. saturated_into :: < i128 > ( ) ) ,
1357
- ) ;
1358
-
1359
- StakingHotkeys :: < Test > :: insert ( coldkey, vec ! [ old_hotkey] ) ;
1360
- }
1361
-
1362
- // Add stake delta for one coldkey and the new_hotkey
1363
- StakeDeltaSinceLastEmissionDrain :: < Test > :: insert ( new_hotkey, coldkeys[ 0 ] , 456 ) ;
1364
- // Add corresponding StakingHotkeys
1365
- StakingHotkeys :: < Test > :: insert ( coldkeys[ 0 ] , vec ! [ old_hotkey, new_hotkey] ) ;
1366
-
1367
- // Perform the swap
1368
- SubtensorModule :: perform_hotkey_swap ( & old_hotkey, & new_hotkey, & coldkey, & mut weight) ;
1369
-
1370
- // Ensure the stake delta is correctly transferred for each coldkey
1371
- // -- coldkey[0] maintains its stake delta from the new_hotkey and the old_hotkey
1372
- assert_eq ! (
1373
- StakeDeltaSinceLastEmissionDrain :: <Test >:: get( new_hotkey, coldkeys[ 0 ] ) ,
1374
- 123 + coldkeys[ 0 ] . saturated_into:: <i128 >( ) + 456
1375
- ) ;
1376
- // -- coldkey[1..] maintains its stake delta from the old_hotkey
1377
- for & coldkey in coldkeys[ 1 ..] . iter ( ) {
1378
- assert_eq ! (
1379
- StakeDeltaSinceLastEmissionDrain :: <Test >:: get( new_hotkey, coldkey) ,
1380
- 123 + coldkey. saturated_into:: <i128 >( )
1381
- ) ;
1382
- assert ! ( !StakeDeltaSinceLastEmissionDrain :: <Test >:: contains_key(
1383
- old_hotkey, coldkey
1384
- ) ) ;
1385
- }
1386
- } ) ;
1387
- }
1388
-
1389
- // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey -- test_swap_hotkey_with_pending_emissions --exact --nocapture
1390
- #[ test]
1391
- fn test_swap_hotkey_with_pending_emissions ( ) {
1392
- new_test_ext ( 1 ) . execute_with ( || {
1393
- let old_hotkey = U256 :: from ( 1 ) ;
1394
- let new_hotkey = U256 :: from ( 2 ) ;
1395
- let coldkey = U256 :: from ( 3 ) ;
1396
- let netuid = 0u16 ;
1397
- let mut weight = Weight :: zero ( ) ;
1398
-
1399
- let pending_emission = 123_456_789u64 ;
1400
-
1401
- // Set up initial state
1402
- add_network ( netuid, 0 , 1 ) ;
1403
-
1404
- // Set up pending emissions
1405
- PendingdHotkeyEmission :: < Test > :: insert ( old_hotkey, pending_emission) ;
1406
- // Verify the pending emissions are set
1407
- assert_eq ! (
1408
- PendingdHotkeyEmission :: <Test >:: get( old_hotkey) ,
1409
- pending_emission
1410
- ) ;
1411
- // Verify the new hotkey does not have any pending emissions
1412
- assert ! ( !PendingdHotkeyEmission :: <Test >:: contains_key( new_hotkey) ) ;
1413
-
1414
- // Perform the swap
1415
- SubtensorModule :: perform_hotkey_swap ( & old_hotkey, & new_hotkey, & coldkey, & mut weight) ;
1416
-
1417
- // Verify the pending emissions are transferred
1418
- assert_eq ! (
1419
- PendingdHotkeyEmission :: <Test >:: get( new_hotkey) ,
1420
- pending_emission
1421
- ) ;
1422
- assert ! ( !PendingdHotkeyEmission :: <Test >:: contains_key( old_hotkey) ) ;
1423
- } ) ;
1424
- }
0 commit comments