@@ -89,12 +89,16 @@ fn test_coinbase_tao_issuance_base() {
8989 let subnet_owner_ck = U256 :: from ( 1001 ) ;
9090 let subnet_owner_hk = U256 :: from ( 1002 ) ;
9191 let netuid = add_dynamic_network ( & subnet_owner_hk, & subnet_owner_ck) ;
92+ let total_issuance_before = TotalIssuance :: < Test > :: get ( ) ;
9293 SubnetMovingPrice :: < Test > :: insert ( netuid, I96F32 :: from ( 3141 ) / I96F32 :: from ( 1000 ) ) ;
9394 let tao_in_before = SubnetTAO :: < Test > :: get ( netuid) ;
9495 let total_stake_before = TotalStake :: < Test > :: get ( ) ;
9596 SubtensorModule :: run_coinbase ( U96F32 :: from_num ( emission) ) ;
9697 assert_eq ! ( SubnetTAO :: <Test >:: get( netuid) , tao_in_before + emission) ;
97- assert_eq ! ( TotalIssuance :: <Test >:: get( ) , emission) ;
98+ assert_eq ! (
99+ TotalIssuance :: <Test >:: get( ) ,
100+ total_issuance_before + emission
101+ ) ;
98102 assert_eq ! ( TotalStake :: <Test >:: get( ) , total_stake_before + emission) ;
99103 } ) ;
100104}
@@ -3317,3 +3321,86 @@ fn test_mining_emission_distribution_with_root_sell() {
33173321 ) ;
33183322 } ) ;
33193323}
3324+
3325+ // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::coinbase::test_pending_emission_start_call_not_done --exact --show-output --nocapture
3326+ #[ test]
3327+ fn test_pending_emission_start_call_not_done ( ) {
3328+ new_test_ext ( 1 ) . execute_with ( || {
3329+ let validator_coldkey = U256 :: from ( 1 ) ;
3330+ let validator_hotkey = U256 :: from ( 2 ) ;
3331+ let subnet_tempo = 10 ;
3332+ let stake: u64 = 100_000_000_000 ;
3333+ let root_stake: u64 = 200_000_000_000 ; // 200 TAO
3334+
3335+ // Create root network
3336+ NetworksAdded :: < Test > :: insert ( NetUid :: ROOT , true ) ;
3337+ // enabled root
3338+ SubtokenEnabled :: < Test > :: insert ( NetUid :: ROOT , true ) ;
3339+
3340+ // Add network, register hotkeys, and setup network parameters
3341+ let owner_hotkey = U256 :: from ( 10 ) ;
3342+ let owner_coldkey = U256 :: from ( 11 ) ;
3343+ let netuid = add_dynamic_network ( & owner_hotkey, & owner_coldkey) ;
3344+ // Remove FirstEmissionBlockNumber
3345+ FirstEmissionBlockNumber :: < Test > :: remove ( netuid) ;
3346+ Tempo :: < Test > :: insert ( netuid, subnet_tempo) ;
3347+
3348+ register_ok_neuron ( netuid, validator_hotkey, validator_coldkey, 0 ) ;
3349+ SubtensorModule :: add_balance_to_coldkey_account (
3350+ & validator_coldkey,
3351+ stake + ExistentialDeposit :: get ( ) ,
3352+ ) ;
3353+ SubtensorModule :: set_weights_set_rate_limit ( netuid, 0 ) ;
3354+ step_block ( subnet_tempo) ;
3355+ SubnetOwnerCut :: < Test > :: set ( u16:: MAX / 10 ) ;
3356+ // There are two validators and three neurons
3357+ MaxAllowedUids :: < Test > :: set ( netuid, 3 ) ;
3358+ SubtensorModule :: set_max_allowed_validators ( netuid, 2 ) ;
3359+
3360+ // Add stake to validator so it has root stake
3361+ SubtensorModule :: add_balance_to_coldkey_account ( & validator_coldkey, root_stake. into ( ) ) ;
3362+ // init root
3363+ assert_ok ! ( SubtensorModule :: add_stake(
3364+ RuntimeOrigin :: signed( validator_coldkey) ,
3365+ validator_hotkey,
3366+ NetUid :: ROOT ,
3367+ root_stake. into( )
3368+ ) ) ;
3369+ // Set tao weight non zero
3370+ SubtensorModule :: set_tao_weight ( u64:: MAX / 10 ) ;
3371+
3372+ // Make root sell happen
3373+ // Set moving price > 1.0
3374+ // Set price > 1.0
3375+ pallet_subtensor_swap:: AlphaSqrtPrice :: < Test > :: insert (
3376+ netuid,
3377+ U64F64 :: saturating_from_num ( 10.0 ) ,
3378+ ) ;
3379+
3380+ SubnetMovingPrice :: < Test > :: insert ( netuid, I96F32 :: from_num ( 2 ) ) ;
3381+
3382+ // Make sure we are root selling, so we have root alpha divs.
3383+ let root_sell_flag = SubtensorModule :: get_network_root_sell_flag ( & [ netuid] ) ;
3384+ assert ! ( root_sell_flag, "Root sell flag should be true" ) ;
3385+
3386+ // !!! Check that the subnet FirstEmissionBlockNumber is None -- no entry
3387+ assert ! ( FirstEmissionBlockNumber :: <Test >:: get( netuid) . is_none( ) ) ;
3388+
3389+ // Run run_coinbase until emissions are accumulated
3390+ step_block ( subnet_tempo - 2 ) ;
3391+
3392+ // Verify that all pending emissions are zero
3393+ assert_eq ! (
3394+ PendingServerEmission :: <Test >:: get( netuid) ,
3395+ AlphaCurrency :: ZERO
3396+ ) ;
3397+ assert_eq ! (
3398+ PendingValidatorEmission :: <Test >:: get( netuid) ,
3399+ AlphaCurrency :: ZERO
3400+ ) ;
3401+ assert_eq ! (
3402+ PendingRootAlphaDivs :: <Test >:: get( netuid) ,
3403+ AlphaCurrency :: ZERO
3404+ ) ;
3405+ } ) ;
3406+ }
0 commit comments