@@ -478,20 +478,33 @@ fn test_migrate_fix_pending_emissions() {
478
478
let datura_old_hk_account: AccountId = get_account_id_from_ss58 ( datura_old_hotkey) ;
479
479
let datura_new_hk_account: AccountId = get_account_id_from_ss58 ( datura_new_hotkey) ;
480
480
481
+ // "Issue" the TAO we're going to insert to stake
482
+ let null_stake_datura = 123_456_789 ;
483
+ let null_stake_tao_stats = 123_456_789 ;
484
+ let null_stake_total = null_stake_datura + null_stake_tao_stats;
485
+ SubtensorModule :: set_total_issuance ( null_stake_total) ;
486
+ TotalStake :: < Test > :: put ( null_stake_total) ;
487
+ TotalColdkeyStake :: < Test > :: insert ( null_account, null_stake_total) ;
488
+ TotalHotkeyStake :: < Test > :: insert ( datura_old_hk_account, null_stake_datura) ;
489
+ TotalHotkeyStake :: < Test > :: insert ( taostats_old_hk_account, null_stake_tao_stats) ;
490
+
481
491
// Setup the old Datura hotkey with a pending emission
482
492
PendingdHotkeyEmission :: < Test > :: insert ( datura_old_hk_account, 10_000 ) ;
483
493
// Setup the NEW Datura hotkey with a pending emission
484
- PendingdHotkeyEmission :: < Test > :: insert ( datura_new_hk_account, 123_456_789 ) ;
494
+ PendingdHotkeyEmission :: < Test > :: insert ( datura_new_hk_account, null_stake_datura ) ;
485
495
Stake :: < Test > :: insert ( datura_old_hk_account, null_account, 123_456_789 ) ;
486
- let expected_datura_new_hk_pending_emission: u64 = 123_456_789 + 10_000 + 123_456_789 ;
496
+ let expected_datura_new_hk_pending_emission: u64 = 123_456_789 + 10_000 + null_stake_datura ;
487
497
488
498
// Setup the old TaoStats hotkey with a pending emission
489
499
PendingdHotkeyEmission :: < Test > :: insert ( taostats_old_hk_account, 987_654 ) ;
490
500
// Setup the new TaoStats hotkey with a pending emission
491
501
PendingdHotkeyEmission :: < Test > :: insert ( taostats_new_hk_account, 100_000 ) ;
492
502
// Setup the old TaoStats hotkey with a null-key stake entry
493
- Stake :: < Test > :: insert ( taostats_old_hk_account, null_account, 123_456_789 ) ;
494
- let expected_taostats_new_hk_pending_emission: u64 = 987_654 + 100_000 + 123_456_789 ;
503
+ Stake :: < Test > :: insert ( taostats_old_hk_account, null_account, null_stake_tao_stats) ;
504
+ let expected_taostats_new_hk_pending_emission: u64 =
505
+ 987_654 + 100_000 + null_stake_tao_stats;
506
+
507
+ let total_issuance_before = SubtensorModule :: get_total_issuance ( ) ;
495
508
496
509
// Run migration
497
510
let first_weight = run_pending_emissions_migration_and_check ( migration_name) ;
@@ -523,5 +536,18 @@ fn test_migrate_fix_pending_emissions() {
523
536
// Check the stake entry is removed
524
537
assert_eq ! ( Stake :: <Test >:: get( datura_old_hk_account, null_account) , 0 ) ;
525
538
assert_eq ! ( Stake :: <Test >:: get( taostats_old_hk_account, null_account) , 0 ) ;
539
+
540
+ // Check the total issuance is decreased by the null stake removed
541
+ let expected_total_issuance = total_issuance_before - null_stake_total;
542
+ assert_eq ! (
543
+ SubtensorModule :: get_total_issuance( ) ,
544
+ expected_total_issuance
545
+ ) ;
546
+
547
+ // Check total stake is decreased by the null stake removed
548
+ assert_eq ! ( TotalStake :: <Test >:: get( ) , expected_total_issuance) ;
549
+ assert_eq ! ( TotalColdkeyStake :: <Test >:: get( null_account) , 0 ) ;
550
+ assert_eq ! ( TotalHotkeyStake :: <Test >:: get( datura_old_hk_account) , 0 ) ;
551
+ assert_eq ! ( TotalHotkeyStake :: <Test >:: get( taostats_old_hk_account) , 0 ) ;
526
552
} )
527
553
}
0 commit comments